@@ -2,6 +2,54 @@ package goassert
2
2
3
3
import "testing"
4
4
5
+ func Test_EmptySliceShouldPass_GivenEmptySlice (t * testing.T ) {
6
+ tester := new (testing.T )
7
+
8
+ slice := make ([]int , 0 )
9
+
10
+ EmptySlice (tester , slice )
11
+
12
+ if tester .Failed () {
13
+ t .Error ("EmptySlice did not pass when empty slice was given" )
14
+ }
15
+ }
16
+
17
+ func Test_EmptySliceShouldFail_GivenNonEmptySlice (t * testing.T ) {
18
+ tester := new (testing.T )
19
+
20
+ slice := []int {10 , 3 , 5 }
21
+
22
+ EmptySlice (tester , slice )
23
+
24
+ if ! tester .Failed () {
25
+ t .Error ("EmptySlice did not fail when non-empty slice was given" )
26
+ }
27
+ }
28
+
29
+ func Test_SliceLengthShouldPass_IfGivenSliceLengthMatchesGivenLength (t * testing.T ) {
30
+ tester := new (testing.T )
31
+
32
+ slice := []int {10 , 3 , 5 }
33
+
34
+ SliceLength (tester , slice , 3 )
35
+
36
+ if tester .Failed () {
37
+ t .Error ("SliceLength did not pass when given slice's length matches the expected length" )
38
+ }
39
+ }
40
+
41
+ func Test_SliceLengthShouldFail_IfGivenSliceLengthDoesNotMatchGivenLength (t * testing.T ) {
42
+ tester := new (testing.T )
43
+
44
+ slice := []int {10 , 3 , 5 }
45
+
46
+ SliceLength (tester , slice , 5 )
47
+
48
+ if ! tester .Failed () {
49
+ t .Error ("SliceLength did not fail when given slice's length does not match the expected length" )
50
+ }
51
+ }
52
+
5
53
func Test_SliceContainsShouldPass_GivenElementInGivenSlice (t * testing.T ) {
6
54
tester := new (testing.T )
7
55
@@ -54,6 +102,63 @@ func Test_SliceNotContainsShouldFail_GivenElementInGivenSlice(t *testing.T) {
54
102
}
55
103
}
56
104
105
+ func Test_EmptyMapShouldPass_GivenEmptyMap (t * testing.T ) {
106
+ tester := new (testing.T )
107
+
108
+ m := make (map [int ]int , 0 )
109
+
110
+ EmptyMap (tester , m )
111
+
112
+ if tester .Failed () {
113
+ t .Error ("EmptyMap did not pass given empty map" )
114
+ }
115
+ }
116
+
117
+ func Test_EmptyMapShouldFail_GivenNonEmptyMap (t * testing.T ) {
118
+ tester := new (testing.T )
119
+
120
+ m := map [int ]int {
121
+ 10 : 10 ,
122
+ 5 : 5 ,
123
+ }
124
+
125
+ EmptyMap (tester , m )
126
+
127
+ if ! tester .Failed () {
128
+ t .Error ("EmptyMap did not fail given non-empty map" )
129
+ }
130
+ }
131
+
132
+ func Test_MapLengthShouldPass_IfGivenMapLengthMatchesGivenLength (t * testing.T ) {
133
+ tester := new (testing.T )
134
+
135
+ m := map [int ]int {
136
+ 10 : 10 ,
137
+ 5 : 5 ,
138
+ }
139
+
140
+ MapLength (tester , m , 2 )
141
+
142
+ if tester .Failed () {
143
+ t .Error ("MapLength did not pass when given map's length matches expected length" )
144
+ }
145
+ }
146
+
147
+ func Test_MapLengthShouldFail_IfGivenMapLengthDoesNotMatchGivenLength (t * testing.T ) {
148
+ tester := new (testing.T )
149
+
150
+ m := map [int ]int {
151
+ 10 : 10 ,
152
+ 5 : 5 ,
153
+ }
154
+
155
+ MapLength (tester , m , 10 )
156
+
157
+ if ! tester .Failed () {
158
+ t .Error ("MapLength did not fail when given map's length does not match expected length" )
159
+ }
160
+ }
161
+
57
162
func Test_MapContainsShouldPass_GivenKeyValuePairInGivenMap (t * testing.T ) {
58
163
tester := new (testing.T )
59
164
0 commit comments