fix: add VUScale.spokenLevel with proper clamping and non-finite handling

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 15:27:29 +02:00
co-authored by Claude Sonnet 5.5
parent 114548f63b
commit d0f78f5165
3 changed files with 32 additions and 2 deletions
+23
View File
@@ -106,3 +106,26 @@ struct LEDBarTests {
#expect(LEDBar.litCount(forFraction: -1) == 0)
}
}
struct SpokenLevelTests {
@Test func nonFiniteInputReturnsStil() {
#expect(VUScale.spokenLevel(fromDbfs: -.infinity) == "stil")
#expect(VUScale.spokenLevel(fromDbfs: .nan) == "stil")
}
@Test func referenceLevel() {
#expect(VUScale.spokenLevel(fromDbfs: -20) == "0 VU")
}
@Test func negativeLevel() {
#expect(VUScale.spokenLevel(fromDbfs: -30) == "-9 VU")
}
@Test func clampedToMinimum() {
#expect(VUScale.spokenLevel(fromDbfs: -120) == "-20 VU")
}
@Test func clampedToMaximum() {
#expect(VUScale.spokenLevel(fromDbfs: 10) == "3 VU")
}
}