@@ -33,6 +33,7 @@ public static IEnumerable<object[]> AllLevels()
3333 var maidataTxt = File . ReadAllText ( maidataPath , Encoding . UTF8 ) ;
3434 var maidata = new Maidata ( maidataTxt ) ;
3535 foreach ( var id in maidata . Levels . Keys . OrderBy ( k => k ) )
36+ // if (maidataPath.Contains("系ぎて") && id == 3)
3637 yield return [ new TestInput ( maidataPath , id ) ] ;
3738 }
3839 }
@@ -108,15 +109,15 @@ static IEnumerable<Entry> Canon(IReadOnlyList<Entry> e) =>
108109 Assert . Equal ( expected [ i ] . Time , actual [ i ] . Time ) ;
109110 AssertNoteEqual ( expected [ i ] . Text , actual [ i ] . Text , i , actual [ i ] . Time , chart ) ;
110111 }
111- catch ( Xunit . Sdk . XunitException e )
112+ catch ( Xunit . Sdk . XunitException )
112113 {
113114 output ? . WriteLine ( FormatNeighborhood ( expected , actual , i ) . TrimEnd ( ) ) ;
114115 throw ;
115116 }
116117 }
117118 }
118119
119- [ GeneratedRegex ( @"\[(?:(\d+) :(\d+)|(?:([\d\.]+)#)?# ([\d\.]+))\]" ) ]
120+ [ GeneratedRegex ( @"\[(?:([\d\.]+)##)?(? :(\d+):(\d+)|#? ([\d\.]+))\]" ) ]
120121 private static partial Regex DurationStrRegex ( ) ;
121122
122123 private static bool Near ( double a , double b ) => Math . Abs ( a - b ) < 1e-3 ;
@@ -139,28 +140,29 @@ private static void AssertNoteEqual(string expected, string actual, int noteIdx,
139140 var expTime = DurationStrRegex ( ) . Match ( exp ) ;
140141 var actTime = DurationStrRegex ( ) . Match ( act ) ;
141142 var bpm = chart . BpmList . Find ( time ) . Bpm ;
142- if ( expTime . Groups [ 1 ] . Success && actTime . Groups [ 4 ] . Success )
143+ if ( expTime . Groups [ 2 ] . Success && actTime . Groups [ 4 ] . Success )
143144 { // exp中是分数时间、act中是小数时间的情况
144145 // 小数时间化为分数时间,看看是否对的上
145- var numer = decimal . Parse ( actTime . Groups [ 4 ] . Value ) / ( 240 / bpm ) * int . Parse ( expTime . Groups [ 1 ] . Value ) ;
146- if ( Math . Round ( numer ) == int . Parse ( expTime . Groups [ 2 ] . Value ) ) result = true ; // 如果对的上,则不判定为比较失败
147- if ( actTime . Groups [ 3 ] . Success )
148- { // 如果写了等待时间的话,等待时间必须为1拍
149- var oneBeatSec = 60 / ( Rational ) bpm ;
150- if ( ! Near ( double . Parse ( actTime . Groups [ 3 ] . Value ) , ( double ) oneBeatSec ) ) result = false ; // 如果等待时间对不上,则仍判定为比较失败
151- }
146+ var numer = decimal . Parse ( actTime . Groups [ 4 ] . Value ) / ( 240 / bpm ) * int . Parse ( expTime . Groups [ 2 ] . Value ) ;
147+ if ( Math . Round ( numer ) == int . Parse ( expTime . Groups [ 3 ] . Value ) ) result = true ; // 如果对的上,则不判定为比较失败
152148 }
153- else if ( actTime . Groups [ 1 ] . Success && expTime . Groups [ 4 ] . Success )
149+ else if ( actTime . Groups [ 2 ] . Success && expTime . Groups [ 4 ] . Success )
154150 { // exp中是小数时间、act中是分数时间的情况
155151 // 分数时间化为小数时间,看是否对的上(差距<1ms)
156- var sec = new Rational ( int . Parse ( actTime . Groups [ 2 ] . Value ) , int . Parse ( actTime . Groups [ 1 ] . Value ) ) * ( 240 / ( Rational ) bpm ) ;
152+ var sec = new Rational ( int . Parse ( actTime . Groups [ 3 ] . Value ) , int . Parse ( actTime . Groups [ 2 ] . Value ) ) * ( 240 / ( Rational ) bpm ) ;
157153 if ( Near ( ( double ) sec , double . Parse ( expTime . Groups [ 4 ] . Value ) ) ) result = true ; // 如果对的上,则不判定为比较失败
158- if ( expTime . Groups [ 3 ] . Success )
159- { // 如果写了等待时间的话,等待时间必须为1拍
160- var oneBeatSec = 60 / ( Rational ) bpm ;
161- if ( ! Near ( double . Parse ( expTime . Groups [ 3 ] . Value ) , ( double ) oneBeatSec ) ) result = false ; // 如果等待时间对不上,则仍判定为比较失败
162- }
163154 }
155+ else if ( actTime . Groups [ 4 ] . Success && expTime . Groups [ 4 ] . Success )
156+ { // exp中是小数时间、act中是小数时间的情况
157+ var expSec = double . Parse ( expTime . Groups [ 4 ] . Value ) ;
158+ var actSec = double . Parse ( actTime . Groups [ 4 ] . Value ) ;
159+ if ( Near ( expSec , actSec ) ) result = true ; // 如果对的上,则不判定为比较失败
160+ }
161+
162+ // 比较等待时间是否相等(没显式写出的就是1拍)
163+ var expWait = expTime . Groups [ 1 ] . Success ? double . Parse ( expTime . Groups [ 1 ] . Value ) : 60 / ( double ) bpm ;
164+ var actWait = actTime . Groups [ 1 ] . Success ? double . Parse ( actTime . Groups [ 1 ] . Value ) : 60 / ( double ) bpm ;
165+ if ( ! Near ( expWait , actWait ) ) result = false ; // 如果等待时间对不上,则仍判定为比较失败
164166 }
165167
166168 if ( ! result ) Assert . Fail (
0 commit comments