From de915bcb009c44726b70509d90db12bb0803b957 Mon Sep 17 00:00:00 2001 From: Saxon Date: Sat, 12 Oct 2019 17:05:44 +1030 Subject: [PATCH] input/gvctrl/gvctrl_test.go: added test for convRate --- input/gvctrl/gvctrl_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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) + } + } +}