diff --git a/src.csharp/AlphaTab.Test/Test/Globals.cs b/src.csharp/AlphaTab.Test/Test/Globals.cs index 05660269e..13e2c6bb3 100644 --- a/src.csharp/AlphaTab.Test/Test/Globals.cs +++ b/src.csharp/AlphaTab.Test/Test/Globals.cs @@ -87,7 +87,14 @@ public void ToBeTrue() public void ToBeFalsy() { - Assert.AreEqual(default!, _actual, _message); + if (_actual is string s) + { + Assert.IsTrue(string.IsNullOrEmpty(s), _message); + } + else + { + Assert.AreEqual(default!, _actual, _message); + } } public void ToThrowError(Type expected) diff --git a/src.kotlin/alphaTab/alphaTab/src/androidTest/kotlin/alphaTab/test/Globals.kt b/src.kotlin/alphaTab/alphaTab/src/androidTest/kotlin/alphaTab/test/Globals.kt index 0f6d5ff93..b30652f2f 100644 --- a/src.kotlin/alphaTab/alphaTab/src/androidTest/kotlin/alphaTab/test/Globals.kt +++ b/src.kotlin/alphaTab/alphaTab/src/androidTest/kotlin/alphaTab/test/Globals.kt @@ -68,7 +68,12 @@ public class Expector { } public fun toBeFalsy() { - kotlin.test.assertNull(_actual, _message) + val actual = _actual; + if(actual is String){ + kotlin.test.assertTrue(actual.isEmpty(), _message) + } else { + kotlin.test.assertNull(_actual, _message) + } } public fun toThrowError(expected: KClass) { diff --git a/src.kotlin/alphaTab/alphaTab/src/commonMain/kotlin/alphaTab/collections/List.kt b/src.kotlin/alphaTab/alphaTab/src/commonMain/kotlin/alphaTab/collections/List.kt index d3068d39d..a131a50ae 100644 --- a/src.kotlin/alphaTab/alphaTab/src/commonMain/kotlin/alphaTab/collections/List.kt +++ b/src.kotlin/alphaTab/alphaTab/src/commonMain/kotlin/alphaTab/collections/List.kt @@ -39,6 +39,10 @@ public class List : Iterable { _data.add(item) } + public fun fill(item: T) { + _data.fill(item) + } + public fun push(items: List) { _data.addAll(items._data) } diff --git a/src/model/Track.ts b/src/model/Track.ts index 1fdb6282d..4ee42e73e 100644 --- a/src/model/Track.ts +++ b/src/model/Track.ts @@ -102,6 +102,7 @@ export class Track { // initialize lyrics list for beat if required if (!beat.lyrics) { beat.lyrics = new Array(lyrics.length); + beat.lyrics.fill(""); } // assign chunk beat.lyrics[li] = lyric.chunks[ci]; diff --git a/test-data/guitarpro7/lyrics-null.gp b/test-data/guitarpro7/lyrics-null.gp new file mode 100644 index 000000000..c9a3f91b1 Binary files /dev/null and b/test-data/guitarpro7/lyrics-null.gp differ diff --git a/test/exporter/Gp7Exporter.test.ts b/test/exporter/Gp7Exporter.test.ts index eb1245645..5f8e4b061 100644 --- a/test/exporter/Gp7Exporter.test.ts +++ b/test/exporter/Gp7Exporter.test.ts @@ -14,8 +14,7 @@ describe('Gp7ExporterTest', () => { const data = await TestPlatform.loadFile('test-data/' + name); try { return ScoreLoader.loadScoreFromBytes(data); - } - catch (e) { + } catch (e) { return null; } }; @@ -30,7 +29,10 @@ describe('Gp7ExporterTest', () => { return new Gp7Exporter().export(score, null); }; - const testRoundTripEqual: (name: string, ignoreKeys: string[] | null) => Promise = async (name: string, ignoreKeys: string[] | null = null): Promise => { + const testRoundTripEqual: (name: string, ignoreKeys: string[] | null) => Promise = async ( + name: string, + ignoreKeys: string[] | null = null + ): Promise => { try { const expected = await loadScore(name); if (!expected) { @@ -42,7 +44,7 @@ describe('Gp7ExporterTest', () => { const actual = prepareGp7ImporterWithBytes(exported).readScore(); const expectedJson = JsonConverter.scoreToJsObject(expected); - const actualJson = JsonConverter.scoreToJsObject(actual) + const actualJson = JsonConverter.scoreToJsObject(actual); if (!ComparisonHelpers.expectJsonEqual(expectedJson, actualJson, '<' + fileName + '>', ignoreKeys)) { await TestPlatform.saveFile(fileName, exported); @@ -109,7 +111,7 @@ describe('Gp7ExporterTest', () => { await testRoundTripEqual(`conversion/full-song.gpx`, [ 'accidentalmode', // gets upgraded from default 'percussionarticulations', // gets added - 'percussionarticulation', // gets added + 'percussionarticulation' // gets added ]); }); @@ -136,8 +138,12 @@ describe('Gp7ExporterTest', () => { const actual = prepareGp7ImporterWithBytes(exported).readScore(); const expectedJson = JsonConverter.scoreToJsObject(expected); - const actualJson = JsonConverter.scoreToJsObject(actual) + const actualJson = JsonConverter.scoreToJsObject(actual); ComparisonHelpers.expectJsonEqual(expectedJson, actualJson, '', ['accidentalmode']); }); + + it('gp7-lyrics-null', async () => { + await testRoundTripEqual('guitarpro7/lyrics-null.gp', null); + }); });