@@ -13,25 +13,72 @@ public class LrcTimedTextUtilsTest
1313 #region Decode
1414
1515 [ TestCase ( "<00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>" , "帰り道は" , new [ ] { "[0,start]:17970" , "[1,start]:18370" , "[2,start]:18550" , "[3,start]:18940" , "[3,end]:19220" } ) ]
16- [ TestCase ( " <00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>" , " 帰り道は" , new [ ] { "[1 ,start]:17970" , "[2 ,start]:18370" , "[3 ,start]:18550" , "[4 ,start]:18940" , "[4 ,end]:19220" } ) ]
17- [ TestCase ( "<00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22> " , "帰り道は " , new [ ] { "[0,start]:17970" , "[1,start]:18370" , "[2,start]:18550" , "[3,start]:18940" , "[3,end]:19220" } ) ]
18- [ TestCase ( "帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>" , "帰り道は" , new [ ] { "[1,start]:18370" , "[2,start]:18550" , "[3,start]:18940" , "[3,end]:19220" } ) ]
16+ [ TestCase ( " <00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>" , "帰り道は" , new [ ] { "[0 ,start]:17970" , "[1 ,start]:18370" , "[2 ,start]:18550" , "[3 ,start]:18940" , "[3 ,end]:19220" } ) ]
17+ [ TestCase ( "<00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22> " , "帰り道は" , new [ ] { "[0,start]:17970" , "[1,start]:18370" , "[2,start]:18550" , "[3,start]:18940" , "[3,end]:19220" } ) ]
18+ [ TestCase ( "帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>" , "帰り道は" , new [ ] { "[0,start]:0" , "[ 1,start]:18370", "[2,start]:18550" , "[3,start]:18940" , "[3,end]:19220" } ) ]
1919 [ TestCase ( "<00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は" , "帰り道は" , new [ ] { "[0,start]:17970" , "[1,start]:18370" , "[2,start]:18550" , "[3,start]:18940" } ) ]
2020 [ TestCase ( "帰り道は" , "帰り道は" , new string [ ] { } ) ]
2121 [ TestCase ( "" , "" , new string [ ] { } ) ]
22+ [ TestCase ( " " , "" , new string [ ] { } ) ]
2223 [ TestCase ( null , "" , new string [ ] { } ) ]
24+ [ TestCase ( "<00:51.00> <01:29.99><01:48.29> <02:31.00> <02:41.99>You gotta fight !" , "You gotta fight !" , new [ ] { "[0,start]:161990" } ) ] // multiple empty tags
25+ // Surrounding time tags
26+ [ TestCase (
27+ "<00:06.84> Every <00:07.20> <00:07.56> night <00:07.87> <00:08.19> that <00:08.46> <00:08.79> goes <00:09.19> <00:09.59> between" ,
28+ "Every night that goes between" ,
29+ new [ ] { "[0,start]:6840" , "[4,end]:7200" , "[6,start]:7560" , "[10,end]:7870" , "[12,start]:8190" , "[15,end]:8460" , "[17,start]:8790" , "[20,end]:9190" , "[22,start]:9590" }
30+ ) ]
31+ // Alternating time tags, spaced on both sides
32+ [ TestCase (
33+ "<00:06.84> Every <00:07.56> night <00:08.19> that <00:08.79> goes <00:09.59> between" , "Every night that goes between" ,
34+ new [ ] { "[0,start]:6840" , "[6,start]:7560" , "[12,start]:8190" , "[17,start]:8790" , "[22,start]:9590" }
35+ ) ]
36+ // Alternating time tags, unspaced
37+ [ TestCase (
38+ "<00:06.84>Every<00:07.56>night<00:08.19>that<00:08.79>goes<00:09.59>between" , "Everynightthatgoesbetween" ,
39+ new [ ] { "[0,start]:6840" , "[5,start]:7560" , "[10,start]:8190" , "[14,start]:8790" , "[18,start]:9590" }
40+ ) ]
41+ [ TestCase (
42+ "Every<00:07.56>night<00:08.19>that<00:08.79>goes<00:09.59>between" , "Everynightthatgoesbetween" ,
43+ new [ ] { "[0,start]:0" , "[5,start]:7560" , "[10,start]:8190" , "[14,start]:8790" , "[18,start]:9590" }
44+ ) ]
45+ // Alternating time tags, prefix spaced
46+ [ TestCase (
47+ "<00:06.84> Every<00:07.56> night<00:08.19> that<00:08.79> goes<00:09.59> between" , "Every night that goes between" ,
48+ new [ ] { "[0,start]:6840" , "[6,start]:7560" , "[12,start]:8190" , "[17,start]:8790" , "[22,start]:9590" }
49+ ) ]
50+ [ TestCase (
51+ "Every<00:07.56> night<00:08.19> that<00:08.79> goes<00:09.59> between" , "Every night that goes between" ,
52+ new [ ] { "[0,start]:0" , "[6,start]:7560" , "[12,start]:8190" , "[17,start]:8790" , "[22,start]:9590" }
53+ ) ]
54+ // Alternating time tags, postfix spaced
55+ [ TestCase (
56+ "<00:06.84>Every <00:07.56>night <00:08.19>that <00:08.79>goes <00:09.59>between" , "Every night that goes between" ,
57+ new [ ] { "[0,start]:6840" , "[6,start]:7560" , "[12,start]:8190" , "[17,start]:8790" , "[22,start]:9590" }
58+ ) ]
59+ [ TestCase (
60+ "Every <00:07.56>night <00:08.19>that <00:08.79>goes <00:09.59>between" , "Every night that goes between" ,
61+ new [ ] { "[0,start]:0" , "[6,start]:7560" , "[12,start]:8190" , "[17,start]:8790" , "[22,start]:9590" }
62+ ) ]
2363 public void TestDecode ( string text , string expectedText , string [ ] expectedTimeTags )
2464 {
25- var ( actualText , actualTimeTags ) = LrcTimedTextUtils . TimedTextToObject ( text ) ;
65+ var ( actualText , actualTimeTags ) = LrcTimedTextUtils . TimedTextToObject ( text , 0 ) ;
2666
2767 Assert . That ( actualText , Is . EqualTo ( expectedText ) ) ;
2868 Assert . That ( actualTimeTags , Is . EqualTo ( TestCaseTagHelper . ParseTimeTags ( expectedTimeTags ) ) ) ;
2969 }
3070
31- [ TestCase ( "<00:51.00><01:29.99><01:48.29><02:31.00><02:41.99>You gotta fight !" , "You gotta fight !" , new [ ] { "[0,start]:51000" } ) ] // decode with invalid format.
32- public void TestDecodeWithInvalidFormat ( string text , string expectedText , string [ ] expectedTimeTags )
71+ [ TestCase (
72+ "<00:06.84>Every<00:07.56>night<00:08.19>that<00:08.79>goes<00:09.59>between" , 6840 , "Everynightthatgoesbetween" ,
73+ new [ ] { "[0,start]:6840" , "[5,start]:7560" , "[10,start]:8190" , "[14,start]:8790" , "[18,start]:9590" }
74+ ) ]
75+ [ TestCase (
76+ "Every<00:07.56>night<00:08.19>that<00:08.79>goes<00:09.59>between" , 6840 , "Everynightthatgoesbetween" ,
77+ new [ ] { "[0,start]:6840" , "[5,start]:7560" , "[10,start]:8190" , "[14,start]:8790" , "[18,start]:9590" }
78+ ) ]
79+ public void TestDecodeWithStartTime ( string text , int lineStartTime , string expectedText , string [ ] expectedTimeTags )
3380 {
34- var ( actualText , actualTimeTags ) = LrcTimedTextUtils . TimedTextToObject ( text ) ;
81+ var ( actualText , actualTimeTags ) = LrcTimedTextUtils . TimedTextToObject ( text , lineStartTime ) ;
3582
3683 Assert . That ( actualText , Is . EqualTo ( expectedText ) ) ;
3784 Assert . That ( actualTimeTags , Is . EqualTo ( TestCaseTagHelper . ParseTimeTags ( expectedTimeTags ) ) ) ;
0 commit comments