Skip to content

Commit

Permalink
Make the test case happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Dec 24, 2022
1 parent b4887f1 commit 480f58f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PageGeneratorTest : BaseBeatmapGeneratorTest<PageGenerator, Page[],
[TestCase(new[] { "[1000,3000]:karaoke" }, true)]
[TestCase(new[] { "[1000,3000]:karaoke", "[4000,6000]:karaoke" }, true)]
[TestCase(new[] { "[1000,3000]:karaoke", "[1000,3000]:karaoke" }, true)] // should still runnable even if lyric is overlapping.
[TestCase(new[] { "" }, false)] // should not be able to generate if lyric is empty.
[TestCase(new string[] { }, false)]
public void TestCanGenerate(string[] lyrics, bool canGenerate)
{
Expand All @@ -35,20 +36,6 @@ public void TestCanGenerate(string[] lyrics, bool canGenerate)
CheckCanGenerate(beatmap, canGenerate, config);
}

[Test]
public void TestGenerateWithZeroLyric()
{
var config = GeneratorDefaultConfig();
var beatmap = new KaraokeBeatmap
{
HitObjects = new List<KaraokeHitObject>()
};

var expectedPages = Array.Empty<Page>();

CheckGenerateResult(beatmap, expectedPages, config);
}

[TestCase("[1000,3000]:karaoke", new double[] { 1000, 3000 })]
[TestCase("[1000,23000]:karaoke", new[] { 1000, 1000 + max_interval, 1000 + max_interval * 2, 23000 })]
public void TestGenerateWithSingleLyric(string lyric, double[] expectedTimes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class NoteGeneratorTest : BaseLyricGeneratorTest<NoteGenerator, Note[], N
[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" }, false)]
[TestCase(new[] { "[0,start]:1000" }, false)] // should have at least two time-tags.
[TestCase(new[] { "[0,start]:" }, false)] // no-time.
[TestCase(new string[] { }, false)]
public void TestCanGenerate(string[] timeTags, bool canGenerate)
{
Expand All @@ -33,10 +34,6 @@ public void TestCanGenerate(string[] timeTags, bool canGenerate)
[TestCase(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }, new[] { "カ", "ラ", "オ", "ケ" })]
[TestCase(new[] { "[3,end]:1000", "[3,start]:2000", "[2,start]:3000", "[1,start]:4000", "[0,start]:5000" }, new string[] { })]
[TestCase(new[] { "[0,start]:1000", "[1,start]:1000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }, new[] { "カラ", "オ", "ケ" })] // will combine the note if time is duplicated.
[TestCase(new[] { "[0,start]:1000", "[1,start]:", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }, new[] { "カラ", "オ", "ケ" })] // will combine the note if got no time.
[TestCase(new[] { "[0,start]:", "[1,start]:1000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }, new[] { "ラ", "オ", "ケ" })]
[TestCase(new[] { "[0,start]:1000" }, new string[] { })]
[TestCase(new[] { "[0,start]:" }, new string[] { })]
public void TestGenerate(string[] timeTags, string[] expectedNotes)
{
var config = GeneratorConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ReferenceLyricDetectorTest : BaseLyricDetectorTest<ReferenceLyricDe
[TestCase("karaoke", "karaoke", true)]
[TestCase("karaoke", "karaoke -", false)] // should be able to detect only if two lyric text are the same.
[TestCase("- karaoke", "karaoke", false)] // should be able to detect only if two lyric text are the same.
[TestCase("karaoke", "カラオケ", false)] // should be able to detect only if two lyric text are the same.
public void TestCanDetect(string lyricText, string detectedLyricText, bool canDetect)
{
var detectedLyric = new Lyric
Expand Down Expand Up @@ -64,7 +65,6 @@ public void TestCanDetectWithIgnorePrefixAndPostfixSymbol(string lyricText, stri
}

[TestCase("karaoke", "karaoke", true)]
[TestCase("karaoke", "カラオケ", false)]
public void TestDetect(string firstLyricText, string secondLyricText, bool referenced)
{
var firstLyric = new Lyric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.RomajiTags
{
public class RomajiTagGeneratorSelectorTest : BaseLyricGeneratorSelectorTest<RomajiTagGeneratorSelector, RomajiTag[]>
{
[TestCase(17, "花火大会", true)]
[TestCase(17, "我是中文", true)] // only change the language code to decide should be able to generate or not.
[TestCase(17, "", false)] // will not able to generate the romaji if lyric is empty.
[TestCase(17, " ", false)]
[TestCase(17, null, false)]
[TestCase(1028, "はなび", false)] // Should not be able to generate if language is not supported.
public void TestCanGenerate(int lcid, string text, bool canGenerate)
{
var selector = CreateSelector();
var lyric = new Lyric
{
Language = new CultureInfo(lcid),
Text = text,
};

CheckCanGenerate(lyric, canGenerate, selector);
}

[TestCase(17, "花火大会", new[] { "[0,2]:hanabi", "[2,4]:taikai" })] // Japanese
[TestCase(1041, "はなび", new[] { "[0,3]:hanabi" })] // Japanese
[TestCase(1028, "はなび", new string[] { })] // Chinese(should not supported)
public void TestGenerate(int lcid, string text, string[] expectedRomajies)
{
var selector = CreateSelector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.RubyTags
{
public class RubyTagGeneratorSelectorTest : BaseLyricGeneratorSelectorTest<RubyTagGeneratorSelector, RubyTag[]>
{
[TestCase(17, "花火大会", true)]
[TestCase(17, "我是中文", true)] // only change the language code to decide should be able to generate or not.
[TestCase(17, "", false)] // will not able to generate the romaji if lyric is empty.
[TestCase(17, " ", false)]
[TestCase(17, null, false)]
[TestCase(1028, "はなび", false)] // Should not be able to generate if language is not supported.
public void TestCanGenerate(int lcid, string text, bool canGenerate)
{
var selector = CreateSelector();
var lyric = new Lyric
{
Language = new CultureInfo(lcid),
Text = text,
};

CheckCanGenerate(lyric, canGenerate, selector);
}

[TestCase(17, "花火大会", new[] { "[0,2]:はなび", "[2,4]:たいかい" })] // Japanese
[TestCase(1041, "はなび", new string[] { })] // Japanese
[TestCase(1028, "はなび", new string[] { })] // Chinese(should not supported)
public void TestGenerate(int lcid, string text, string[] expectedRubies)
{
var selector = CreateSelector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,27 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.TimeTags
{
public class TimeTagGeneratorSelectorTest : BaseLyricGeneratorSelectorTest<TimeTagGeneratorSelector, TimeTag[]>
{
[TestCase(17, "花火大会", true)]
[TestCase(1028, "喵", true)] // Support the chinese.
[TestCase(3081, "hello", false)] // English is not supported.
[TestCase(17, "", false)] // will not able to generate the romaji if lyric is empty.
[TestCase(17, " ", false)]
[TestCase(17, null, false)]
public void TestCanGenerate(int lcid, string text, bool canGenerate)
{
var selector = CreateSelector();
var lyric = new Lyric
{
Language = new CultureInfo(lcid),
Text = text,
};

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(3081, "hello", new string[] { })] // English
public void TestGenerate(int lcid, string text, string[] expectedTimeTags)
{
var selector = CreateSelector();
Expand Down

0 comments on commit 480f58f

Please sign in to comment.