input/gvctrl/gvctrl_test.go: added test for BitRate option function

This commit is contained in:
Saxon 2019-10-12 17:54:21 +10:30
parent ad83376cd6
commit 9e4ff72c48
1 changed files with 80 additions and 0 deletions

View File

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