mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-19 16:22:14 +02:00
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:
@@ -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: 日本語の歌詞
|
||||
|
Reference in New Issue
Block a user