fix(lyrics): align usability checks with shared fixtures

Trim after removing inline timestamps before matching speaker prefixes in Dart. Run one 21-case usability corpus through Dart, Go, and Kotlin tests.

Document the shared fixture and trigger Dart and Go CI when its resources change.
This commit is contained in:
zarzet
2026-09-06 14:05:09 +07:00
parent a89f786960
commit 1d96521c0f
8 changed files with 111 additions and 1 deletions
@@ -7,6 +7,29 @@ import org.junit.Assert.assertTrue
import org.junit.Test
class NativeFinalizationPolicyTest {
@Test
fun matchesSharedLyricUsabilityCases() {
val stream = checkNotNull(
javaClass.getResourceAsStream("/lyrics_usability_cases.tsv"),
)
stream.bufferedReader().useLines { lines ->
for (line in lines) {
if (line.isBlank() || line.startsWith("#")) continue
val fields = line.split('\t')
assertEquals("invalid shared fixture: $line", 3, fields.size)
val lyrics = fields[2]
.replace("\\n", "\n")
.replace("\\r", "\r")
.replace("\\t", "\t")
assertEquals(
fields[0],
fields[1].toBooleanStrict(),
NativeFinalizationPolicy.hasUsableLyricsContent(lyrics),
)
}
}
}
@Test
fun usableLyricsRejectsHeadersButKeepsRealAndInstrumentalContent() {
assertFalse(
@@ -0,0 +1,23 @@
# Shared Dart/Go/Kotlin lyric-usability cases.
# Columns: name<TAB>expected boolean<TAB>lyrics. Decode literal \n, \r, \t in lyrics.
empty false
whitespace false \t\r\n
metadata_only false [ar:Artist]\n[ti:Title]\n[offset:0]
metadata_case false [AR:Artist]\n[BY:SpotiFLAC]
instrumental true [Instrumental:TRUE]
timestamps_only false [00:01.00]\n<00:01.10>
multiple_timestamps false [00:01.00][01:02:500]
speaker_only false v1:\n V2:
inline_before_spaced_speaker false [00:00.00]<00:00.01> v1:
inline_before_tabbed_speaker false [00:00.00]<00:00.01>\tV2:\t
multiple_inline_speaker false [00:00.00]<00:00.01> <00:00.02> v2:
empty_background false [bg: ]
empty_timed_background false [bg:[00:00.00]<00:00.01> v1: ]
plain_text true First line\nSecond line
timed_text true [00:01.00]First line
timed_speaker_text true [00:02:500]<00:02.500> v2: Harmony line
background_text true [bg:Backing vocal]
timed_background_text true [BG:[00:00.00]<00:00.01> v1: Backing vocal]
multiple_timed_text true [00:01.00][00:02.00]Repeated line
metadata_and_text true [ti:Title]\n[00:00.00]Actual lyric
unicode_text true [00:00.00]<00:00.01> v1: 日本語の歌詞
1 # Shared Dart/Go/Kotlin lyric-usability cases.
2 # Columns: name<TAB>expected boolean<TAB>lyrics. Decode literal \n, \r, \t in lyrics.
3 empty false
4 whitespace false \t\r\n
5 metadata_only false [ar:Artist]\n[ti:Title]\n[offset:0]
6 metadata_case false [AR:Artist]\n[BY:SpotiFLAC]
7 instrumental true [Instrumental:TRUE]
8 timestamps_only false [00:01.00]\n<00:01.10>
9 multiple_timestamps false [00:01.00][01:02:500]
10 speaker_only false v1:\n V2:
11 inline_before_spaced_speaker false [00:00.00]<00:00.01> v1:
12 inline_before_tabbed_speaker false [00:00.00]<00:00.01>\tV2:\t
13 multiple_inline_speaker false [00:00.00]<00:00.01> <00:00.02> v2:
14 empty_background false [bg: ]
15 empty_timed_background false [bg:[00:00.00]<00:00.01> v1: ]
16 plain_text true First line\nSecond line
17 timed_text true [00:01.00]First line
18 timed_speaker_text true [00:02:500]<00:02.500> v2: Harmony line
19 background_text true [bg:Backing vocal]
20 timed_background_text true [BG:[00:00.00]<00:00.01> v1: Backing vocal]
21 multiple_timed_text true [00:01.00][00:02.00]Repeated line
22 metadata_and_text true [ti:Title]\n[00:00.00]Actual lyric
23 unicode_text true [00:00.00]<00:00.01> v1: 日本語の歌詞