-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
65 lines (50 loc) · 1020 Bytes
/
main_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
package main
import (
"testing"
)
func assert(t *testing.T, expected int, actual int) {
if actual != expected {
t.Errorf("%s() failed. Expecting: %d but got %d", t.Name(), expected, actual)
}
}
func TestMin(t *testing.T) {
var input = []int{
40, 42, 33, 45,
}
ans := Min(input, 2)
expected := 40
assert(t, expected, ans)
}
func TestMinMNotExists(t *testing.T) {
var input = []int{
3, 2, 9, 16, 11, 45,
}
ans := Min(input, 10)
expected := -1
assert(t, expected, ans)
}
func TestMinMNegative(t *testing.T) {
var input = []int{
3, 2, 9, 16, 11, 45,
}
ans := Min(input, -1)
expected := -1
assert(t, expected, ans)
}
func TestMinSameValue(t *testing.T) {
var input = []int{
3, 2, 9, 16, 3, 11, 45, 2,
}
ans := Min(input, 1)
expected := 2
assert(t, expected, ans)
}
func TestFindBoundary(t *testing.T) {
var input = []int{
3, 2, 9, 16, 11, 45,
}
max, min := FindBoundary(input)
expectedMax, expectedMin := 45, 2
assert(t, expectedMax, max)
assert(t, expectedMin, min)
}