input/gvctrl/gvctrl_test.go: added test for convRate

This commit is contained in:
Saxon 2019-10-12 17:05:44 +10:30
parent caa46939b4
commit de915bcb00
1 changed files with 31 additions and 0 deletions

View File

@ -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)
}
}
}