mirror of https://bitbucket.org/ausocean/av.git
input/gvctrl/gvctrl_test.go: added test for convRate
This commit is contained in:
parent
caa46939b4
commit
de915bcb00
|
@ -76,3 +76,34 @@ func TestClosestValIdx(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvRate(t *testing.T) {
|
||||
tests := []struct {
|
||||
l []int
|
||||
v int
|
||||
want string
|
||||
}{
|
||||
{
|
||||
l: []int{512, 1024, 2048, 3072},
|
||||
v: 1400,
|
||||
want: "1024000",
|
||||
},
|
||||
{
|
||||
l: []int{512, 1024, 2048, 3072},
|
||||
v: 1900,
|
||||
want: "2048000",
|
||||
},
|
||||
{
|
||||
l: []int{512, 1024, 2048, 3072},
|
||||
v: 4000,
|
||||
want: "3072000",
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
got := convRate(test.v, test.l)
|
||||
if got != test.want {
|
||||
t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue