Files
yoloyolo/synth/config_test.go
T
gurix bb13527281 test(02-01): add failing tests for synth config, oscillator, and layer
- TestAllClassesHaveConfig, TestFrequenciesInRange, TestFrequenciesUnique
- TestHarmonicsNonEmpty, TestPanPositionsInRange
- TestOscillatorAdvance, TestOscillatorPhaseWrap, TestOscillatorDistinctFreqs
- TestEMAAmplitudeRise, TestEMAAmplitudeDecay, TestWhisperFloor, TestWhisperFloorNotSeenIsZero
2026-03-26 11:57:43 +01:00

51 lines
1.3 KiB
Go

package synth_test
import (
"testing"
"github.com/netsynth/netsynth/classify"
"github.com/netsynth/netsynth/synth"
)
func TestAllClassesHaveConfig(t *testing.T) {
for _, class := range classify.AllClasses() {
if _, ok := synth.ClassFreqConfigs[class]; !ok {
t.Errorf("class %q has no entry in ClassFreqConfigs", class)
}
}
}
func TestFrequenciesInRange(t *testing.T) {
for class, cfg := range synth.ClassFreqConfigs {
if cfg.BaseHz < 60 || cfg.BaseHz > 800 {
t.Errorf("class %q BaseHz=%.1f is out of range [60, 800]", class, cfg.BaseHz)
}
}
}
func TestFrequenciesUnique(t *testing.T) {
seen := make(map[float64]classify.TrafficClass)
for class, cfg := range synth.ClassFreqConfigs {
if prev, exists := seen[cfg.BaseHz]; exists {
t.Errorf("classes %q and %q share the same BaseHz=%.1f", prev, class, cfg.BaseHz)
}
seen[cfg.BaseHz] = class
}
}
func TestHarmonicsNonEmpty(t *testing.T) {
for class, cfg := range synth.ClassFreqConfigs {
if len(cfg.Harmonics) < 2 {
t.Errorf("class %q has fewer than 2 harmonics (got %d)", class, len(cfg.Harmonics))
}
}
}
func TestPanPositionsInRange(t *testing.T) {
for class, cfg := range synth.ClassFreqConfigs {
if cfg.Pan < -1.0 || cfg.Pan > 1.0 {
t.Errorf("class %q Pan=%.2f is out of range [-1.0, 1.0]", class, cfg.Pan)
}
}
}