forked from hashicorp/consul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath_test.go
49 lines (43 loc) · 1.08 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
package lib_test
import (
"testing"
"github.com/hashicorp/consul/lib"
)
func TestMathAbsInt(t *testing.T) {
tests := [][3]int{{1, 1}, {-1, 1}, {0, 0}}
for _, test := range tests {
if test[1] != lib.AbsInt(test[0]) {
t.Fatalf("expected %d, got %d", test[1], test[0])
}
}
}
func TestMathMaxInt(t *testing.T) {
tests := [][3]int{{1, 2, 2}, {-1, 1, 1}, {2, 0, 2}}
for _, test := range tests {
expected := test[2]
actual := lib.MaxInt(test[0], test[1])
if expected != actual {
t.Fatalf("expected %d, got %d", expected, actual)
}
}
}
func TestMathMinInt(t *testing.T) {
tests := [][3]int{{1, 2, 1}, {-1, 1, -1}, {2, 0, 0}}
for _, test := range tests {
expected := test[2]
actual := lib.MinInt(test[0], test[1])
if expected != actual {
t.Fatalf("expected %d, got %d", expected, actual)
}
}
}
func TestMathMaxUint64(t *testing.T) {
tests := [][3]uint64{{1, 2, 2}, {0, 1, 1}, {2, 0, 2}}
for _, test := range tests {
expected := test[2]
actual := lib.MaxUint64(test[0], test[1])
if expected != actual {
t.Fatalf("expected %d, got %d", expected, actual)
}
}
}