-
Notifications
You must be signed in to change notification settings - Fork 0
/
assert_slice_test.go
147 lines (100 loc) · 3.25 KB
/
assert_slice_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package goassert
import "testing"
func Test_EmptySliceShouldPass_GivenEmptySlice(t *testing.T) {
tester := new(testing.T)
slice := make([]int, 0)
EmptySlice(tester, slice)
if tester.Failed() {
t.Error("EmptySlice did not pass when empty slice was given")
}
}
func Test_EmptySliceShouldFail_GivenNilSlice(t *testing.T) {
tester := new(testing.T)
EmptySlice[int](tester, nil)
if !tester.Failed() {
t.Error("EmptySlice did not fail when nil slice was given")
}
}
func Test_EmptySliceShouldFail_GivenNonEmptySlice(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 3, 5}
EmptySlice(tester, slice)
if !tester.Failed() {
t.Error("EmptySlice did not fail when non-empty slice was given")
}
}
func Test_NotEmptySliceShouldPass_GivenNonEmptySlice(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 16}
NotEmptySlice(tester, slice)
if tester.Failed() {
t.Error("NotEmptySlice did not pass when non-empty slice was given")
}
}
func Test_NotEmptySliceShouldFail_GivenNilSlice(t *testing.T) {
tester := new(testing.T)
NotEmptySlice[string](tester, nil)
if !tester.Failed() {
t.Error("NotEmptySlice did not fail when nil slice was given")
}
}
func Test_NotEmptySliceShouldFail_GivenEmptySlice(t *testing.T) {
tester := new(testing.T)
slice := make([]int, 0)
NotEmptySlice(tester, slice)
if !tester.Failed() {
t.Error("NotEmptySlice did not fail when empty slice was given")
}
}
func Test_SliceLengthShouldPass_IfGivenSliceLengthMatchesGivenLength(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 3, 5}
SliceLength(tester, slice, 3)
if tester.Failed() {
t.Error("SliceLength did not pass when given slice's length matches the expected length")
}
}
func Test_SliceLengthShouldFail_IfGivenSliceLengthDoesNotMatchGivenLength(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 3, 5}
SliceLength(tester, slice, 5)
if !tester.Failed() {
t.Error("SliceLength did not fail when given slice's length does not match the expected length")
}
}
func Test_SliceContainsShouldPass_IfGivenElementExistsInGivenSlice(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 5, 16, 3}
element := 5
SliceContains(tester, slice, element)
if tester.Failed() {
t.Error("SliceContains did not pass when given element is found within given slice")
}
}
func Test_SliceContainsShouldFail_IfGivenElementDoesNotExistInGivenSlice(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 5, 16, 3}
element := 7
SliceContains(tester, slice, element)
if !tester.Failed() {
t.Error("SliceContains did not fail when given element is not found within given slice")
}
}
func Test_SliceNotContainsShouldPass_IfGivenElementDoesNotExistInGivenSlice(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 5, 16, 3}
element := 7
SliceNotContains(tester, slice, element)
if tester.Failed() {
t.Error("SliceNotContains did not pass when given element is not found within given slice")
}
}
func Test_SliceNotContainsShouldFail_IfGivenElementExistsInGivenSlice(t *testing.T) {
tester := new(testing.T)
slice := []int{10, 5, 16, 3}
element := 10
SliceNotContains(tester, slice, element)
if !tester.Failed() {
t.Error("SliceNotContains did not fail when given element is not found within given slice")
}
}