Skip to content

Commit ed175cd

Browse files
committed
fix test
1 parent 59802c9 commit ed175cd

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

tests/Simai转MA2测试.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,17 @@ private static void AssertTextEqual(string expected, string actual)
7777
var result = CompareLine(exp, act);
7878
if (!result)
7979
{
80-
// 尝试下面五行之内有无相同的,如果有,交换之
81-
for (int j = 1; j < Math.Min(expectedLines.Length, i+5); j++)
80+
// 尝试同一时刻的其他行有无相同的,如果有,交换之
81+
var j = i + 1;
82+
while (j < expectedLines.Length && IsSameTime(expectedLines[i], actualLines[j]))
8283
{
8384
if (CompareLine(expectedLines[j], act))
8485
{
8586
(expectedLines[j], expectedLines[i]) = (expectedLines[i], expectedLines[j]);
8687
result = true;
8788
break;
8889
}
90+
j++;
8991
}
9092
}
9193

tests/TestUtils.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public static DirectoryInfo FindRepoRoot()
5454
return null;
5555
}
5656

57+
public static (int, int) ExtractMa2Time(string ma2Line)
58+
{
59+
var para = ma2Line.Split('\t');
60+
return (int.Parse(para[1]), int.Parse(para[2]));
61+
}
62+
63+
public static bool IsSameTime(string ma2Line1, string ma2Line2) => ExtractMa2Time(ma2Line1) == ExtractMa2Time(ma2Line2);
64+
5765
/// <summary>
5866
/// 提取 MA2 音符段至 <c>T_REC</c> 之前:跳过头部与 <c>BPM</c> 行;若存在 <c>MET\t</c> 小节行则跳过该行;
5967
/// 部分旧官谱 golden 无 <c>MET</c>,则在 <c>BPM</c> 块后的首条非头行开始收集。与 <see cref="Simai片段测试"/> / <see cref="MA2_103测试"/> 断言用逻辑一致。

tests/testset/自制谱/Soranji/03.ma2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,11 +803,11 @@ CNSCL 43 226 6 0 14 5
803803
CNSCL 43 228 6 0 15 5
804804
CNSCL 43 234 5 0 18 4
805805
CNSCL 43 237 5 0 17 4
806-
NMSTR 43 240 3
807806
CNSCL 43 240 5 0 14 4
808807
CNSCL 43 240 5 0 15 4
809808
CNSCL 43 240 5 0 16 4
810809
BRSI_ 43 240 3 96 32 1
810+
NMSTR 43 240 3
811811
CNSCL 43 243 5 0 15 4
812812
CNSI_ 43 249 4 0 21 0
813813
CNSI_ 43 252 4 0 18 0

tests/testset/自制谱/時雨/03.ma2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,12 @@ NMTAP 48 240 7
436436
NMTAP 48 288 1
437437
NMTAP 48 336 0
438438
NMSTR 49 0 2
439-
NMSI_ 49 0 2 96 54 4
439+
NMSI_ 49 0 2 96 48 4
440440
NMTAP 49 48 0
441441
NMTAP 49 96 2
442442
NMTAP 49 144 7
443443
NMSTR 49 192 1
444-
NMSI_ 49 192 1 96 65 5
444+
NMSI_ 49 192 1 96 48 5
445445
NMTAP 49 240 7
446446
NMTAP 49 288 1
447447
NMTAP 49 336 6

tests/testset/自制谱/海神/03.ma2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,11 @@ NMHLD 46 0 2 96
470470
BRSTR 46 192 3
471471
NMSCL 46 192 3 96 48 0
472472
BRSTR 46 193 7
473-
NMSCL 46 193 7 96 48 4
473+
NMSCL 46 193 7 95 48 4
474474
BRSTR 46 288 3
475475
NMSUR 46 288 3 96 192 5
476476
BRSTR 46 289 7
477-
NMSUR 46 289 7 96 192 1
477+
NMSUR 46 289 7 95 192 1
478478
BRTAP 47 0 3
479479
BRTAP 47 0 7
480480
NMTAP 47 288 7

0 commit comments

Comments
 (0)