35 lines
648 B
Go
35 lines
648 B
Go
package mixer_test
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
|
|
"rhemawavetech.com/rhemawave/internal/mixer"
|
|
)
|
|
|
|
func TestConvertVolume(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input int
|
|
expected float64
|
|
}{
|
|
{"0 percent", 0, 0.0},
|
|
{"25 percent", 25, 0.25},
|
|
{"33 percent", 33, 0.33},
|
|
{"50 percent", 50, 0.50},
|
|
{"90 percent", 90, 0.90},
|
|
{"100 percent", 100, 1.0},
|
|
}
|
|
|
|
const epsilon = 1e-9
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := mixer.ConvertVolume(tt.input)
|
|
if math.Abs(got-tt.expected) > epsilon {
|
|
t.Errorf("ConvertVolume(%d) = %v, want %v", tt.input, got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|