Skip to content

Commit 405651d

Browse files
committed
More unit tests
1 parent ebd1be9 commit 405651d

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

video/gfx_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package video
2+
3+
import "testing"
4+
5+
func TestXYWHTo4points(t *testing.T) {
6+
type args struct {
7+
x float32
8+
y float32
9+
w float32
10+
h float32
11+
fbh float32
12+
}
13+
tests := []struct {
14+
name string
15+
args args
16+
wantX1 float32
17+
wantY1 float32
18+
wantX2 float32
19+
wantY2 float32
20+
wantX3 float32
21+
wantY3 float32
22+
wantX4 float32
23+
wantY4 float32
24+
}{
25+
{
26+
name: "Works",
27+
args: args{x: 30, y: 40, w: 500, h: 600, fbh: 800},
28+
wantX1: 30,
29+
wantX2: 30,
30+
wantX3: 530,
31+
wantX4: 530,
32+
wantY1: 160,
33+
wantY2: 760,
34+
wantY3: 160,
35+
wantY4: 760,
36+
},
37+
}
38+
for _, tt := range tests {
39+
t.Run(tt.name, func(t *testing.T) {
40+
gotX1, gotY1, gotX2, gotY2, gotX3, gotY3, gotX4, gotY4 := XYWHTo4points(tt.args.x, tt.args.y, tt.args.w, tt.args.h, tt.args.fbh)
41+
if gotX1 != tt.wantX1 {
42+
t.Errorf("XYWHTo4points() gotX1 = %v, want %v", gotX1, tt.wantX1)
43+
}
44+
if gotY1 != tt.wantY1 {
45+
t.Errorf("XYWHTo4points() gotY1 = %v, want %v", gotY1, tt.wantY1)
46+
}
47+
if gotX2 != tt.wantX2 {
48+
t.Errorf("XYWHTo4points() gotX2 = %v, want %v", gotX2, tt.wantX2)
49+
}
50+
if gotY2 != tt.wantY2 {
51+
t.Errorf("XYWHTo4points() gotY2 = %v, want %v", gotY2, tt.wantY2)
52+
}
53+
if gotX3 != tt.wantX3 {
54+
t.Errorf("XYWHTo4points() gotX3 = %v, want %v", gotX3, tt.wantX3)
55+
}
56+
if gotY3 != tt.wantY3 {
57+
t.Errorf("XYWHTo4points() gotY3 = %v, want %v", gotY3, tt.wantY3)
58+
}
59+
if gotX4 != tt.wantX4 {
60+
t.Errorf("XYWHTo4points() gotX4 = %v, want %v", gotX4, tt.wantX4)
61+
}
62+
if gotY4 != tt.wantY4 {
63+
t.Errorf("XYWHTo4points() gotY4 = %v, want %v", gotY4, tt.wantY4)
64+
}
65+
})
66+
}
67+
}

0 commit comments

Comments
 (0)