Skip to content

Commit 3d0951c

Browse files
committed
Revert TextIndex End behavior change
1 parent c6aebda commit 3d0951c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

LrcParser.Tests/Parser/Lrc/Lines/LrcLyricParserTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void TestDecode(string lyric, LrcLyric expected)
3939
{
4040
Text = "帰り道は",
4141
StartTimes = [17000],
42-
TimeTags = TestCaseTagHelper.ParseTimeTags(["[0,start]:0", "[1,start]:1000", "[2,start]:2000", "[3,start]:3000", "[4,end]:4000"]),
42+
TimeTags = TestCaseTagHelper.ParseTimeTags(["[0,start]:0", "[1,start]:1000", "[2,start]:2000", "[3,start]:3000", "[3,end]:4000"]),
4343
},
4444
],
4545
[
@@ -48,7 +48,7 @@ public void TestDecode(string lyric, LrcLyric expected)
4848
{
4949
Text = "帰り道は",
5050
StartTimes = [17000],
51-
TimeTags = TestCaseTagHelper.ParseTimeTags(["[0,start]:17000", "[1,start]:1000", "[2,start]:2000", "[3,start]:3000", "[4,end]:4000"]),
51+
TimeTags = TestCaseTagHelper.ParseTimeTags(["[0,start]:17000", "[1,start]:1000", "[2,start]:2000", "[3,start]:3000", "[3,end]:4000"]),
5252
},
5353
],
5454
[

LrcParser.Tests/Parser/Lrc/LrcParserTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void TestDecode()
3131
{ new TextIndex(1), 18000 },
3232
{ new TextIndex(2), 19000 },
3333
{ new TextIndex(3), 20000 },
34-
{ new TextIndex(4, IndexState.End), 21000 },
34+
{ new TextIndex(3, IndexState.End), 21000 },
3535
},
3636
},
3737
],

LrcParser.Tests/Parser/Lrc/Utils/LrcTimedTextUtilsTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public class LrcTimedTextUtilsTest
1212
{
1313
#region Decode
1414

15-
[TestCase("<00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>", 0, "帰り道は", new[] { "[0,start]:17970", "[1,start]:18370", "[2,start]:18550", "[3,start]:18940", "[4,end]:19220" })]
16-
[TestCase(" <00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>", 0, "帰り道は", new[] { "[0,start]:17970", "[1,start]:18370", "[2,start]:18550", "[3,start]:18940", "[4,end]:19220" })]
17-
[TestCase("<00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22> ", 0, "帰り道は", new[] { "[0,start]:17970", "[1,start]:18370", "[2,start]:18550", "[3,start]:18940", "[4,end]:19220" })]
18-
[TestCase("帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>", 0, "帰り道は", new[] { "[0,start]:0", "[1,start]:18370", "[2,start]:18550", "[3,start]:18940", "[4,end]:19220" })]
15+
[TestCase("<00:17.97>帰<00:18.37>り<00:18.55>道<00:18.94>は<00:19.22>", 0, "帰り道は", 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>", 0, "帰り道は", 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> ", 0, "帰り道は", 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>", 0, "帰り道は", 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>は", 0, "帰り道は", new[] { "[0,start]:17970", "[1,start]:18370", "[2,start]:18550", "[3,start]:18940" })]
2020
[TestCase("帰り道は", 0, "帰り道は", new string[] { })]
2121
[TestCase("", 0, "", new string[] { })]
@@ -25,7 +25,7 @@ public class LrcTimedTextUtilsTest
2525
[TestCase(
2626
"<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", 6840,
2727
"Every night that goes between",
28-
new[] { "[0,start]:6840", "[5,end]:7200", "[6,start]:7560", "[11,end]:7870", "[12,start]:8190", "[16,end]:8460", "[17,start]:8790", "[21,end]:9190", "[22,start]:9590" }
28+
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" }
2929
)]
3030
// Alternating time tags, spaced on both sides
3131
[TestCase(

LrcParser/Parser/Lrc/Utils/LrcTimedTextUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal static Tuple<string, SortedDictionary<TextIndex, int>> TimedTextToObjec
5555
// The last segment was a start tag, and the next segment is empty, insert end tag
5656
if (lastTagWasStartTag)
5757
{
58-
timeTags.TryAdd(new TextIndex(lyricText.Length, IndexState.End), lastTimeTag);
58+
timeTags.TryAdd(new TextIndex(lyricText.Length - 1, IndexState.End), lastTimeTag);
5959
lastTagWasStartTag = false;
6060
}
6161

@@ -106,7 +106,7 @@ internal static Tuple<string, SortedDictionary<TextIndex, int>> TimedTextToObjec
106106
else
107107
{
108108
// No remaining text, last time tag was end tag
109-
timeTags.TryAdd(new TextIndex(lyricText.Length, IndexState.End), lastTimeTag);
109+
timeTags.TryAdd(new TextIndex(lyricText.Length - 1, IndexState.End), lastTimeTag);
110110
}
111111

112112
return new Tuple<string, SortedDictionary<TextIndex, int>>(lyricText.ToString(), timeTags);

0 commit comments

Comments
 (0)