Skip to content

Commit

Permalink
Merge pull request #2073 from andy840119/refactor-the-test-case-helper
Browse files Browse the repository at this point in the history
Refactor the test case helper.
  • Loading branch information
andy840119 authored Jul 21, 2023
2 parents 0bc4a89 + 4017eb7 commit 6a9a5d8
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ private static Beatmap decode(string filename, out Beatmap encoded)

[TestCase(new[] { "[0,start]:1100", "[0,end]:2000", "[1,start]:2100", "[1,end]:3000" }, new double[] { 1100, 2000, 2100, 3000 })]
[TestCase(new[] { "[1,end]:3000", "[1,start]:2100", "[0,end]:2000", "[0,start]:1100" }, new double[] { 1100, 2000, 2100, 3000 })]
[TestCase(new[] { "[0,start]:", "[0,start]:", "[0,end]:2000", "[0,start]:1100" }, new double[] { 1100, 2000 })]
[TestCase(new[] { "[0,start]", "[0,start]", "[0,end]:2000", "[0,start]:1100" }, new double[] { 1100, 2000 })]
[TestCase(new[] { "[0,start]:1000", "[0,start]:1100", "[0,end]:2000", "[0,start]:1100" }, new double[] { 1000, 2000 })]
[TestCase(new[] { "[0,start]:", "[0,end]:", "[0,start]:", "[1,start]:", "[1,end]:" }, new double[] { })]
[TestCase(new[] { "[0,start]", "[0,end]", "[0,start]", "[1,start]", "[1,end]" }, new double[] { })]
[TestCase(new[] { "[0,start]:2000", "[0,end]:1000" }, new double[] { 2000, 2000 })]
[TestCase(new[] { "[0,start]:1100", "[0,end]:2100", "[1,start]:2000", "[1,end]:3000" }, new double[] { 1100, 2100, 2100, 3000 })]
[TestCase(new[] { "[0,start]:1000", "[0,end]:5000", "[1,start]:2000", "[1,end]:3000" }, new double[] { 1000, 5000, 5000, 5000 })]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public void TestCheckOverlapping(string text, string[] timeTags)
AssertNotOk<LyricTimeTagIssue, IssueTemplateLyricTimeTagOverlapping>(lyric);
}

[TestCase("カラオケ", new[] { "[0,start]:", "[3,end]:1000" })] // empty start time-tag time.
[TestCase("カラオケ", new[] { "[0,start]:1000", "[3,end]:" })] // empty end time-tag time.
[TestCase("カラオケ", new[] { "[0,start]:1000", "[1,start]:", "[3,end]:2000" })] // empty center time-tag time.
[TestCase("カラオケ", new[] { "[0,start]", "[3,end]:1000" })] // empty start time-tag time.
[TestCase("カラオケ", new[] { "[0,start]:1000", "[3,end]" })] // empty end time-tag time.
[TestCase("カラオケ", new[] { "[0,start]:1000", "[1,start]", "[3,end]:2000" })] // empty center time-tag time.
public void TestCheckEmptyTime(string text, string[] timeTags)
{
var lyric = new Lyric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public void TestCheckMissingStartReferenceTimeTag(int referenceTimeTagIndex, str
AssertNotOk<NoteIssue, IssueTemplateNoteMissingStartReferenceTimeTag>(new HitObject[] { referencedLyric, note });
}

[TestCase(0, new[] { "[0,start]:", "[3,end]:5000" })]
[TestCase(0, new[] { "[0,start]:", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" })]
[TestCase(1, new[] { "[0,start]:1000", "[1,start]:", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" })]
[TestCase(0, new[] { "[0,start]", "[3,end]:5000" })]
[TestCase(0, new[] { "[0,start]", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" })]
[TestCase(1, new[] { "[0,start]:1000", "[1,start]", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" })]
public void TestCheckStartReferenceTimeTagMissingTime(int referenceTimeTagIndex, string[] timeTags)
{
var referencedLyric = new Lyric
Expand Down Expand Up @@ -146,9 +146,9 @@ public void TestCheckMissingEndReferenceTimeTag(int referenceTimeTagIndex, strin
AssertNotOk<NoteIssue, IssueTemplateNoteMissingEndReferenceTimeTag>(new HitObject[] { referencedLyric, note });
}

[TestCase(0, new[] { "[0,start]:1000", "[3,end]:" })]
[TestCase(3, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:" })]
[TestCase(2, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:", "[3,end]:5000" })]
[TestCase(0, new[] { "[0,start]:1000", "[3,end]" })]
[TestCase(3, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]" })]
[TestCase(2, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]", "[3,end]:5000" })]
public void TestCheckEndReferenceTimeTagMissingTime(int referenceTimeTagIndex, string[] timeTags)
{
var referencedLyric = new Lyric
Expand Down
28 changes: 14 additions & 14 deletions osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckNoteTimeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void TestCheckWithNoReferenceLyric()
AssertOk(new HitObject[] { note });
}

[TestCase(3, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:" })] // will missing start time-tag.
[TestCase(2, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:", "[3,end]:5000" })] // will missing end time-tag.
[TestCase(3, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]" })] // will missing start time-tag.
[TestCase(2, new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]", "[3,end]:5000" })] // will missing end time-tag.
public void TestCheckMissingStartOrEndTimeTag(int referenceTimeTagIndex, string[] timeTags)
{
var referencedLyric = new Lyric
Expand Down Expand Up @@ -88,17 +88,17 @@ public void TestCheckInvalidReferenceTimeTagTime(string startTimeTag, string end
AssertNotOk<NoteIssue, IssueTemplateNoteInvalidReferenceTimeTagTime>(new HitObject[] { referencedLyric, note });
}

[TestCase("[0,start]:", "[1,start]:")]
[TestCase("[0,end]:", "[1,end]:")]
[TestCase("[0,start]:", "[1,end]:")]
[TestCase("[0,end]:", "[1,start]:")]
[TestCase("[1,start]:", "[0,start]:")] // should have error even if time-tag index is not sorted. we did not care about the time-tag index in here.
[TestCase("[0,start]", "[1,start]")]
[TestCase("[0,end]", "[1,end]")]
[TestCase("[0,start]", "[1,end]")]
[TestCase("[0,end]", "[1,start]")]
[TestCase("[1,start]", "[0,start]")] // should have error even if time-tag index is not sorted. we did not care about the time-tag index in here.
public void TestCheckDurationTooShort(string startTimeTag, string endTimeTag)
{
var referencedLyric = new Lyric
{
Text = "カラオケ",
TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { $"{startTimeTag}0", $"{endTimeTag}{MIN_DURATION - 1}" }),
TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { $"{startTimeTag}:0", $"{endTimeTag}:{MIN_DURATION - 1}" }),
};
var note = new Note
{
Expand All @@ -110,17 +110,17 @@ public void TestCheckDurationTooShort(string startTimeTag, string endTimeTag)
AssertNotOk<NoteIssue, IssueTemplateNoteDurationTooShort>(new HitObject[] { referencedLyric, note });
}

[TestCase("[0,start]:", "[1,start]:")]
[TestCase("[0,end]:", "[1,end]:")]
[TestCase("[0,start]:", "[1,end]:")]
[TestCase("[0,end]:", "[1,start]:")]
[TestCase("[1,start]:", "[0,start]:")] // should have error even if time-tag index is not sorted. we did not care about the time-tag index in here.
[TestCase("[0,start]", "[1,start]")]
[TestCase("[0,end]", "[1,end]")]
[TestCase("[0,start]", "[1,end]")]
[TestCase("[0,end]", "[1,start]")]
[TestCase("[1,start]", "[0,start]")] // should have error even if time-tag index is not sorted. we did not care about the time-tag index in here.
public void TestCheckDurationTooLong(string startTimeTag, string endTimeTag)
{
var referencedLyric = new Lyric
{
Text = "カラオケ",
TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { $"{startTimeTag}0", $"{endTimeTag}{MAX_DURATION + 1}" }),
TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { $"{startTimeTag}:0", $"{endTimeTag}:{MAX_DURATION + 1}" }),
};
var note = new Note
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class NoteGeneratorTest : BaseLyricGeneratorTest<NoteGenerator, Note[], N
{
[TestCase(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }, true)]
[TestCase(new[] { "[0,start]:1000", "[1,start]:2000" }, true)]
[TestCase(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:" }, false)] // all time-tag should with time.
[TestCase(new[] { "[0,start]:1000", "[1,start]:" }, false)] // should have at least two time-tags with time.
[TestCase(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]" }, false)] // all time-tag should with time.
[TestCase(new[] { "[0,start]:1000", "[1,start]" }, false)] // should have at least two time-tags with time.
[TestCase(new[] { "[0,start]:1000" }, false)] // should have at least two time-tags.
[TestCase(new[] { "[0,start]:" }, false)] // no-time.
[TestCase(new[] { "[0,start]" }, false)] // no-time.
[TestCase(new string[] { }, false)]
public void TestCanGenerate(string[] timeTags, bool canGenerate)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,48 @@ public void TestCanGenerate(string text, bool canGenerate)
CheckCanGenerate(text, canGenerate, config);
}

[TestCase("がんばって", new[] { "[0,start]:", "[2,start]:", "[4,start]:" }, false)]
[TestCase("がんばって", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[4,start]:" }, true)]
[TestCase("がんばって", new[] { "[0,start]", "[2,start]", "[4,start]" }, false)]
[TestCase("がんばって", new[] { "[0,start]", "[1,start]", "[2,start]", "[4,start]" }, true)]
public void TestGenerateWithCheckWhiteCheckん(string lyric, string[] expectedTimeTags, bool applyConfig)
{
var config = GeneratorEmptyConfig(x => x.Checkん.Value = applyConfig);
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase("買って", new[] { "[0,start]:", "[2,start]:" }, false)]
[TestCase("買って", new[] { "[0,start]:", "[1,start]:", "[2,start]:" }, true)]
[TestCase("買って", new[] { "[0,start]", "[2,start]" }, false)]
[TestCase("買って", new[] { "[0,start]", "[1,start]", "[2,start]" }, true)]
public void TestGenerateWithCheckっ(string lyric, string[] expectedTimeTags, bool applyConfig)
{
var config = GeneratorEmptyConfig(x => x.Checkっ.Value = applyConfig);
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase(" ", new string[] { }, false)]
[TestCase(" ", new[] { "[0,start]:" }, true)]
[TestCase(" ", new[] { "[0,start]" }, true)]
public void TestGenerateWithCheckBlankLine(string lyric, string[] expectedTimeTags, bool applyConfig)
{
var config = GeneratorEmptyConfig(x => x.CheckBlankLine.Value = applyConfig);
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase("か", new[] { "[0,start]:" }, false)]
[TestCase("か", new[] { "[0,start]:", "[0,end]:" }, true)]
[TestCase("か", new[] { "[0,start]" }, false)]
[TestCase("か", new[] { "[0,start]", "[0,end]" }, true)]
public void TestGenerateWithCheckLineEndKeyUp(string lyric, string[] expectedTimeTags, bool applyConfig)
{
var config = GeneratorEmptyConfig(x => x.CheckLineEndKeyUp.Value = applyConfig);
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase("か ", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[3,start]:", "[4,start]:", "[5,start]:" }, false)]
[TestCase("か ", new[] { "[0,start]:", "[1,start]:" }, true)]
[TestCase("か ", new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]", "[5,start]" }, false)]
[TestCase("か ", new[] { "[0,start]", "[1,start]" }, true)]
public void TestGenerateWithCheckWhiteSpace(string lyric, string[] expectedTimeTags, bool applyConfig)
{
var config = GeneratorEmptyConfig(x => x.CheckWhiteSpace.Value = applyConfig);
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase("か ", new[] { "[0,start]:", "[1,start]:" }, false)]
[TestCase("か ", new[] { "[0,start]:", "[0,end]:" }, true)]
[TestCase("か ", new[] { "[0,start]", "[1,start]" }, false)]
[TestCase("か ", new[] { "[0,start]", "[0,end]" }, true)]
public void TestGenerateWithCheckWhiteSpaceKeyUp(string lyric, string[] expectedTimeTags, bool applyConfig)
{
var config = GeneratorEmptyConfig(x =>
Expand All @@ -73,12 +73,12 @@ public void TestGenerateWithCheckWhiteSpaceKeyUp(string lyric, string[] expected
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase("a b c", new[] { "[0,start]:", "[2,start]:", "[4,start]:" }, false, false)]
[TestCase("a b c", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[3,start]:", "[4,start]:" }, true, false)]
[TestCase("a b c", new[] { "[0,start]:", "[0,end]:", "[2,start]:", "[2,end]:", "[4,start]:" }, true, true)]
[TestCase("A B C", new[] { "[0,start]:", "[2,start]:", "[4,start]:" }, false, false)]
[TestCase("A B C", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[3,start]:", "[4,start]:" }, true, false)]
[TestCase("A B C", new[] { "[0,start]:", "[0,end]:", "[2,start]:", "[2,end]:", "[4,start]:" }, true, true)]
[TestCase("a b c", new[] { "[0,start]", "[2,start]", "[4,start]" }, false, false)]
[TestCase("a b c", new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]" }, true, false)]
[TestCase("a b c", new[] { "[0,start]", "[0,end]", "[2,start]", "[2,end]", "[4,start]" }, true, true)]
[TestCase("A B C", new[] { "[0,start]", "[2,start]", "[4,start]" }, false, false)]
[TestCase("A B C", new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]" }, true, false)]
[TestCase("A B C", new[] { "[0,start]", "[0,end]", "[2,start]", "[2,end]", "[4,start]" }, true, true)]
public void TestGenerateWithCheckWhiteSpaceAlphabet(string lyric, string[] expectedTimeTags, bool applyConfig, bool keyUp)
{
var config = GeneratorEmptyConfig(x =>
Expand All @@ -90,12 +90,12 @@ public void TestGenerateWithCheckWhiteSpaceAlphabet(string lyric, string[] expec
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase("0 1 2", new[] { "[0,start]:", "[2,start]:", "[4,start]:" }, false, false)]
[TestCase("0 1 2", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[3,start]:", "[4,start]:" }, true, false)]
[TestCase("0 1 2", new[] { "[0,start]:", "[0,end]:", "[2,start]:", "[2,end]:", "[4,start]:" }, true, true)]
[TestCase("0 1 2", new[] { "[0,start]:", "[2,start]:", "[4,start]:" }, false, false)]
[TestCase("0 1 2", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[3,start]:", "[4,start]:" }, true, false)]
[TestCase("0 1 2", new[] { "[0,start]:", "[0,end]:", "[2,start]:", "[2,end]:", "[4,start]:" }, true, true)]
[TestCase("0 1 2", new[] { "[0,start]", "[2,start]", "[4,start]" }, false, false)]
[TestCase("0 1 2", new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]" }, true, false)]
[TestCase("0 1 2", new[] { "[0,start]", "[0,end]", "[2,start]", "[2,end]", "[4,start]" }, true, true)]
[TestCase("0 1 2", new[] { "[0,start]", "[2,start]", "[4,start]" }, false, false)]
[TestCase("0 1 2", new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]" }, true, false)]
[TestCase("0 1 2", new[] { "[0,start]", "[0,end]", "[2,start]", "[2,end]", "[4,start]" }, true, true)]
public void TestGenerateWithCheckWhiteSpaceDigit(string lyric, string[] expectedTimeTags, bool applyConfig, bool keyUp)
{
var config = GeneratorEmptyConfig(x =>
Expand All @@ -107,9 +107,9 @@ public void TestGenerateWithCheckWhiteSpaceDigit(string lyric, string[] expected
CheckGenerateResult(lyric, expectedTimeTags, config);
}

[TestCase("! ! !", new[] { "[0,start]:", "[2,start]:", "[4,start]:" }, false, false)]
[TestCase("! ! !", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[3,start]:", "[4,start]:" }, true, false)]
[TestCase("! ! !", new[] { "[0,start]:", "[0,end]:", "[2,start]:", "[2,end]:", "[4,start]:" }, true, true)]
[TestCase("! ! !", new[] { "[0,start]", "[2,start]", "[4,start]" }, false, false)]
[TestCase("! ! !", new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]" }, true, false)]
[TestCase("! ! !", new[] { "[0,start]", "[0,end]", "[2,start]", "[2,end]", "[4,start]" }, true, true)]
public void TestGenerateWitCheckWhiteSpaceAsciiSymbol(string lyric, string[] expectedTimeTags, bool applyConfig, bool keyUp)
{
var config = GeneratorEmptyConfig(x =>
Expand Down Expand Up @@ -147,19 +147,19 @@ public void TestGenerateWithRubyLyric()

string[] expectedTimeTags =
{
"[0,start]:",
"[0,start]:",
"[0,start]:",
"[2,start]:",
"[4,start]:",
"[6,start]:",
"[7,start]:",
"[7,start]:",
"[8,start]:",
"[9,start]:",
"[10,start]:",
"[12,start]:",
"[13,start]:",
"[0,start]",
"[0,start]",
"[0,start]",
"[2,start]",
"[4,start]",
"[6,start]",
"[7,start]",
"[7,start]",
"[8,start]",
"[9,start]",
"[10,start]",
"[12,start]",
"[13,start]",
};
CheckGenerateResult(lyric, expectedTimeTags, config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public void TestCanGenerate(int lcid, string text, bool canGenerate)
CheckCanGenerate(lyric, canGenerate, selector);
}

[TestCase(17, "か", new[] { "[0,start]:", "[0,end]:" })] // Japanese
[TestCase(1041, "か", new[] { "[0,start]:", "[0,end]:" })] // Japanese
[TestCase(1028, "喵", new[] { "[0,start]:" })] // Chinese
[TestCase(17, "か", new[] { "[0,start]", "[0,end]" })] // Japanese
[TestCase(1041, "か", new[] { "[0,start]", "[0,end]" })] // Japanese
[TestCase(1028, "喵", new[] { "[0,start]" })] // Chinese
public void TestGenerate(int lcid, string text, string[] expectedTimeTags)
{
var selector = CreateSelector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public void TestCanGenerate(string text, bool canGenerate)
CheckCanGenerate(text, canGenerate, config);
}

[TestCase("測試一些歌詞", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[3,start]:", "[4,start]:", "[5,start]:", "[5,end]:" })]
[TestCase("拉拉拉~~~", new[] { "[0,start]:", "[1,start]:", "[2,start]:", "[5,end]:" })]
[TestCase("拉~拉~拉~", new[] { "[0,start]:", "[2,start]:", "[4,start]:", "[5,end]:" })]
[TestCase("測試一些歌詞", new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]", "[5,start]", "[5,end]" })]
[TestCase("拉拉拉~~~", new[] { "[0,start]", "[1,start]", "[2,start]", "[5,end]" })]
[TestCase("拉~拉~拉~", new[] { "[0,start]", "[2,start]", "[4,start]", "[5,end]" })]
public void TestGenerateWithCheckLineEndKeyUp(string lyric, string[] expectedTimeTags)
{
var config = GeneratorEmptyConfig(x => x.CheckLineEndKeyUp.Value = true);
Expand Down
Loading

0 comments on commit 6a9a5d8

Please sign in to comment.