diff --git a/input/gvctrl/gvctrl_test.go b/input/gvctrl/gvctrl_test.go index 8a4a0dbb..906334fc 100644 --- a/input/gvctrl/gvctrl_test.go +++ b/input/gvctrl/gvctrl_test.go @@ -148,3 +148,83 @@ func TestHeight(t *testing.T) { } } } + +func TestBitrate(t *testing.T) { + tests := []struct { + r int + in settings + want settings + }{ + { + r: 7000, + in: settings{vbr: "1"}, + want: settings{ + vbr: "1", + bitRate: "6000000", + }, + }, + { + r: 7500, + in: settings{vbr: "1"}, + want: settings{ + vbr: "1", + bitRate: "8000000", + }, + }, + { + r: 600, + in: settings{ + vbr: "0", + res: res256, + }, + want: settings{ + vbr: "0", + res: res256, + bitRate: "512000", + }, + }, + { + r: 100, + in: settings{ + vbr: "0", + res: res256, + }, + want: settings{ + vbr: "0", + res: res256, + bitRate: "128000", + }, + }, + { + r: 2048, + in: settings{ + vbr: "0", + res: res360, + }, + want: settings{ + vbr: "0", + res: res360, + bitRate: "2048000", + }, + }, + { + r: 500, + in: settings{ + vbr: "0", + res: res720, + }, + want: settings{ + vbr: "0", + res: res720, + bitRate: "1024000", + }, + }, + } + + for i, test := range tests { + got, _ := BitRate(test.r)(test.in) + if got != test.want { + t.Errorf("did not get expected result for test: %d\nGot: %v\nWant: %v", i, got, test.want) + } + } +}