-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
LyricTextEncoder
and LyricTextDecoder
to better location.
- Loading branch information
1 parent
c7c9feb
commit f9823b1
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
osu.Game.Rulesets.Karaoke.Tests/Integration/Formats/LyricTextDecoderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using NUnit.Framework; | ||
using osu.Game.Rulesets.Karaoke.Integration.Formats; | ||
using osu.Game.Rulesets.Karaoke.Tests.Helper; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Integration.Formats; | ||
|
||
public class LyricTextDecoderTest | ||
{ | ||
[TestCase("karaoke", new[] { "[0,0]:karaoke" })] // only one lyric. | ||
[TestCase("か\nら\nお\nけ", new[] { "[0,0]:か", "[0,0]:ら", "[0,0]:お", "[0,0]:け" })] // multi lyric. | ||
public void TestDecodeBeatmapToPureText(string expected, string[] lyrics) | ||
{ | ||
var decoder = new LyricTextDecoder(); | ||
var actual = decoder.Decode(expected); | ||
|
||
var expectedLyrics = TestCaseTagHelper.ParseLyrics(lyrics); | ||
Assert.AreEqual(expectedLyrics.Length, actual.Length); | ||
|
||
for (int i = 0; i < expectedLyrics.Length; i++) | ||
{ | ||
Assert.AreEqual(expectedLyrics[i].Text, actual[i].Text); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
osu.Game.Rulesets.Karaoke/Integration/Formats/LyricTextDecoder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Linq; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Integration.Formats; | ||
|
||
public class LyricTextDecoder : IDecoder<Lyric[]> | ||
{ | ||
public Lyric[] Decode(string source) | ||
{ | ||
return source.Split('\n').Select((text, index) => new Lyric | ||
{ | ||
Order = index + 1, // should create default order. | ||
Text = text, | ||
}).ToArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters