github.com/derat/nup@v0.0.0-20230418113745-15592ba7c620/cmd/nup/mp3gain/gain_test.go (about) 1 // Copyright 2021 Daniel Erat. 2 // All rights reserved. 3 4 package mp3gain 5 6 import ( 7 "reflect" 8 "testing" 9 ) 10 11 func TestParseMP3GainOutput(t *testing.T) { 12 const out = `File MP3 gain dB gain Max Amplitude Max global_gain Min global_gain 13 /tmp/1.mp3 -6 -9.480000 35738.816406 210 101 14 /tmp/2.mp3 1 1.820000 20295.107422 210 132 15 /tmp/3.mp3 -5 -8.200000 36487.070312 210 77 16 /tmp/4.mp3 -2 -2.630000 28630.636719 210 45 17 /tmp/5.mp3 -5 -8.140000 36071.472656 210 113 18 "Album" -5 -8.220000 36487.070312 210 45 19 ` 20 want := map[string]Info{ 21 "/tmp/1.mp3": Info{-9.48, -8.22, 1.09070}, 22 "/tmp/2.mp3": Info{1.82, -8.22, 0.61938}, 23 "/tmp/3.mp3": Info{-8.20, -8.22, 1.11353}, 24 "/tmp/4.mp3": Info{-2.63, -8.22, 0.87376}, 25 "/tmp/5.mp3": Info{-8.14, -8.22, 1.10085}, 26 } 27 if got, err := parseMP3GainOutput(out); err != nil { 28 t.Fatal("parseMP3GainOutput failed: ", err) 29 } else if !reflect.DeepEqual(got, want) { 30 t.Errorf("parseMP3GainOutput returned %v; want %v", got, want) 31 } 32 }