From 9e4ff72c486bc962f83018cbba9a41d9afbf039d Mon Sep 17 00:00:00 2001 From: Saxon Date: Sat, 12 Oct 2019 17:54:21 +1030 Subject: [PATCH] input/gvctrl/gvctrl_test.go: added test for BitRate option function --- input/gvctrl/gvctrl_test.go | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) 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) + } + } +}