@@ -2,6 +2,9 @@ package goassert
2
2
3
3
import "testing"
4
4
5
+ /*
6
+ Asserts that the given slice is empty. The assertion fails if the given slice is nil
7
+ */
5
8
func EmptySlice [T any ](t testing.TB , s []T ) {
6
9
t .Helper ()
7
10
@@ -16,6 +19,9 @@ func EmptySlice[T any](t testing.TB, s []T) {
16
19
}
17
20
}
18
21
22
+ /*
23
+ Asserts that the given slice is not nil or empty
24
+ */
19
25
func NotEmptySlice [T any ](t testing.TB , s []T ) {
20
26
t .Helper ()
21
27
@@ -29,6 +35,9 @@ func NotEmptySlice[T any](t testing.TB, s []T) {
29
35
}
30
36
}
31
37
38
+ /*
39
+ Asserts that the given slice has length equal to the specified expected length
40
+ */
32
41
func SliceLength [T any ](t testing.TB , s []T , expectedLength int ) {
33
42
t .Helper ()
34
43
@@ -38,6 +47,9 @@ func SliceLength[T any](t testing.TB, s []T, expectedLength int) {
38
47
}
39
48
}
40
49
50
+ /*
51
+ Asserts that the given slice contains the given element. The element must be [comparable]
52
+ */
41
53
func SliceContains [K comparable ](t testing.TB , s []K , element K ) {
42
54
t .Helper ()
43
55
@@ -46,6 +58,9 @@ func SliceContains[K comparable](t testing.TB, s []K, element K) {
46
58
}
47
59
}
48
60
61
+ /*
62
+ Asserts that the given slice does not contain the given element. The element must be [comparable]
63
+ */
49
64
func SliceNotContains [K comparable ](t testing.TB , s []K , element K ) {
50
65
t .Helper ()
51
66
@@ -64,6 +79,9 @@ func sliceContains[K comparable](s []K, element K) bool {
64
79
return false
65
80
}
66
81
82
+ /*
83
+ Asserts that the given map is empty. The assertion will fail if the given map is nil
84
+ */
67
85
func EmptyMap [K comparable , V any ](t testing.TB , m map [K ]V ) {
68
86
t .Helper ()
69
87
@@ -78,6 +96,9 @@ func EmptyMap[K comparable, V any](t testing.TB, m map[K]V) {
78
96
}
79
97
}
80
98
99
+ /*
100
+ Asserts that the given map is not nil or empty
101
+ */
81
102
func NotEmptyMap [K comparable , V any ](t testing.TB , m map [K ]V ) {
82
103
t .Helper ()
83
104
@@ -91,6 +112,9 @@ func NotEmptyMap[K comparable, V any](t testing.TB, m map[K]V) {
91
112
}
92
113
}
93
114
115
+ /*
116
+ Asserts that the given map has length equal to the specified length
117
+ */
94
118
func MapLength [K comparable , V any ](t testing.TB , m map [K ]V , expectedLength int ) {
95
119
t .Helper ()
96
120
@@ -100,6 +124,9 @@ func MapLength[K comparable, V any](t testing.TB, m map[K]V, expectedLength int)
100
124
}
101
125
}
102
126
127
+ /*
128
+ Asserts that the given map contains the given key-value pair. The key and value must be [comparable]
129
+ */
103
130
func MapContains [K , V comparable ](t testing.TB , m map [K ]V , k K , v V ) {
104
131
t .Helper ()
105
132
@@ -115,6 +142,9 @@ func MapContains[K, V comparable](t testing.TB, m map[K]V, k K, v V) {
115
142
}
116
143
}
117
144
145
+ /*
146
+ Asserts that the given map does not contain the given key-value pair. The key and value must be [comparable]
147
+ */
118
148
func MapNotContains [K , V comparable ](t testing.TB , m map [K ]V , k K , v V ) {
119
149
t .Helper ()
120
150
0 commit comments