Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src.csharp/AlphaTab.Test/Test/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ public class Expector<T> {
}

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<out Exception>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public class List<T> : Iterable<T> {
_data.add(item)
}

public fun fill(item: T) {
_data.fill(item)
}

public fun push(items: List<T>) {
_data.addAll(items._data)
}
Expand Down
1 change: 1 addition & 0 deletions src/model/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class Track {
// initialize lyrics list for beat if required
if (!beat.lyrics) {
beat.lyrics = new Array<string>(lyrics.length);
beat.lyrics.fill("");
}
// assign chunk
beat.lyrics[li] = lyric.chunks[ci];
Expand Down
Binary file added test-data/guitarpro7/lyrics-null.gp
Binary file not shown.
18 changes: 12 additions & 6 deletions test/exporter/Gp7Exporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand All @@ -30,7 +29,10 @@ describe('Gp7ExporterTest', () => {
return new Gp7Exporter().export(score, null);
};

const testRoundTripEqual: (name: string, ignoreKeys: string[] | null) => Promise<void> = async (name: string, ignoreKeys: string[] | null = null): Promise<void> => {
const testRoundTripEqual: (name: string, ignoreKeys: string[] | null) => Promise<void> = async (
name: string,
ignoreKeys: string[] | null = null
): Promise<void> => {
try {
const expected = await loadScore(name);
if (!expected) {
Expand All @@ -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);
Expand Down Expand Up @@ -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
]);
});

Expand All @@ -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, '<alphatex>', ['accidentalmode']);
});

it('gp7-lyrics-null', async () => {
await testRoundTripEqual('guitarpro7/lyrics-null.gp', null);
});
});