-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_test.go
More file actions
79 lines (69 loc) · 1.24 KB
/
utils_test.go
File metadata and controls
79 lines (69 loc) · 1.24 KB
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
70
71
72
73
74
75
76
77
78
79
package gts
import "testing"
func TestUnpack(t *testing.T) {
a, b := 39, 42
p := [2]int{a, b}
x, y := Unpack(p)
if a != x || b != y {
t.Errorf("Unpack(%v) = (%d, %d), want (%d, %d)", p, x, y, a, b)
}
}
var absTests = [][2]int{
{-42, 42},
{42, 42},
}
func TestAbs(t *testing.T) {
for _, tt := range absTests {
in, exp := Unpack(tt)
out := Abs(in)
if out != exp {
t.Errorf("Abs(%d) = %d, want %d", in, out, exp)
}
}
}
var compareTests = []struct {
i, j int
out int
}{
{39, 42, -1},
{42, 39, 1},
{42, 42, 0},
}
func TestCompare(t *testing.T) {
for _, tt := range compareTests {
out := Compare(tt.i, tt.j)
if out != tt.out {
t.Errorf("Compare(%d, %d) = %d, want %d", tt.i, tt.j, out, tt.out)
}
}
}
var minTests = []struct {
i, j int
out int
}{
{39, 42, 39},
{42, 39, 39},
}
func TestMin(t *testing.T) {
for _, tt := range minTests {
out := Min(tt.i, tt.j)
if out != tt.out {
t.Errorf("Min(%d, %d) = %d, want %d", tt.i, tt.j, out, tt.out)
}
}
}
var maxTests = []struct {
i, j int
out int
}{
{39, 42, 42},
{42, 39, 42},
}
func TestMax(t *testing.T) {
for _, tt := range maxTests {
out := Max(tt.i, tt.j)
if out != tt.out {
t.Errorf("Max(%d, %d) = %d, want %d", tt.i, tt.j, out, tt.out)
}
}
}