diff --git a/input/gvctrl/gvctrl_test.go b/input/gvctrl/gvctrl_test.go index 15569cf3..d0dca01e 100644 --- a/input/gvctrl/gvctrl_test.go +++ b/input/gvctrl/gvctrl_test.go @@ -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) + } + } +}