-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath_test.go
69 lines (62 loc) · 1.49 KB
/
math_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package vbcore
import (
"testing"
)
func TestMinInt(t *testing.T) {
type args struct {
x int
y int
}
tests := []struct {
name string
args args
want int
}{
{"Positive zero (ASC)", args{0, 1}, 0},
{"Positive zero (DESC)", args{1, 0}, 0},
{"Positive one (ASC)", args{1, 2}, 1},
{"Positive one (DESC)", args{2, 1}, 1},
{"Mixed zero (ASC)", args{-1, 0}, -1},
{"Mixed zero (DESC)", args{0, -1}, -1},
{"Mixed one (ASC)", args{-1, 1}, -1},
{"Mixed one (DESC)", args{1, -1}, -1},
{"Negative (ASC)", args{-2, -1}, -2},
{"Negative (DESC)", args{-1, -2}, -2},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := MinInt(tt.args.x, tt.args.y); got != tt.want {
t.Errorf("MinInt() = %v, want %v", got, tt.want)
}
})
}
}
func TestMaxInt(t *testing.T) {
type args struct {
x int
y int
}
tests := []struct {
name string
args args
want int
}{
{"Positive zero (ASC)", args{0, 1}, 1},
{"Positive zero (DESC)", args{1, 0}, 1},
{"Positive one (ASC)", args{1, 2}, 2},
{"Positive one (DESC)", args{2, 1}, 2},
{"Mixed zero (ASC)", args{-1, 0}, 0},
{"Mixed zero (DESC)", args{0, -1}, 0},
{"Mixed one (ASC)", args{-1, 1}, 1},
{"Mixed one (DESC)", args{1, -1}, 1},
{"Negative (ASC)", args{-2, -1}, -1},
{"Negative (DESC)", args{-1, -2}, -1},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := MaxInt(tt.args.x, tt.args.y); got != tt.want {
t.Errorf("MaxInt() = %v, want %v", got, tt.want)
}
})
}
}