@@ -16,23 +16,23 @@ func Slice[T any](got []T) FluentSlice[T] {
16
16
return FluentSlice [T ]{FluentAny [[]T ]{got }}
17
17
}
18
18
19
- // Empty banana .
19
+ // Empty tests if the slice is empty .
20
20
func (x FluentSlice [T ]) Empty () FailureMessage {
21
21
if len (x .Got ) == 0 {
22
22
return ""
23
23
}
24
24
return FailureMessage (fmt .Sprintf ("not an empty slice\n got: %+v" , x .Got ))
25
25
}
26
26
27
- // NotEmpty banana .
27
+ // NotEmpty tests if the slice is not empty .
28
28
func (x FluentSlice [T ]) NotEmpty () FailureMessage {
29
29
if len (x .Got ) > 0 {
30
30
return ""
31
31
}
32
32
return FailureMessage (fmt .Sprintf ("an empty slice\n got: %+v" , x .Got ))
33
33
}
34
34
35
- // Equivalent banana .
35
+ // Equivalent tests if the slice has the same element as want in any order .
36
36
func (x FluentSlice [T ]) Equivalent (want []T , opts ... cmp.Option ) FailureMessage {
37
37
extraGot , extraWant := x .diff (want , opts )
38
38
if len (extraGot ) == 0 && len (extraWant ) == 0 {
@@ -41,7 +41,7 @@ func (x FluentSlice[T]) Equivalent(want []T, opts ...cmp.Option) FailureMessage
41
41
return FailureMessage (fmt .Sprintf ("not equivalent\n extra got: %+v\n extra want: %+v" , extraGot , extraWant ))
42
42
}
43
43
44
- // NotEquivalent banana .
44
+ // NotEquivalent tests if the slice does not have the same element as want in any order .
45
45
func (x FluentSlice [T ]) NotEquivalent (want []T , opts ... cmp.Option ) FailureMessage {
46
46
extraGot , extraWant := x .diff (want , opts )
47
47
if len (extraGot ) != 0 || len (extraWant ) != 0 {
@@ -83,7 +83,7 @@ func (x FluentSlice[T]) diff(want []T, opts []cmp.Option) (extraGot, extraWant [
83
83
return
84
84
}
85
85
86
- // Contain banana .
86
+ // Contain tests if the slice contains the item .
87
87
func (x FluentSlice [T ]) Contain (item T , opts ... cmp.Option ) FailureMessage {
88
88
for _ , v := range x .Got {
89
89
if cmp .Equal (item , v , opts ... ) {
@@ -93,7 +93,7 @@ func (x FluentSlice[T]) Contain(item T, opts ...cmp.Option) FailureMessage {
93
93
return FailureMessage (fmt .Sprintf ("slice does not contain the item\n got: %+v\n item: %+v" , x .Got , item ))
94
94
}
95
95
96
- // NotContain banana .
96
+ // NotContain tests if the slice does not contain the item .
97
97
func (x FluentSlice [T ]) NotContain (item T , opts ... cmp.Option ) FailureMessage {
98
98
for _ , v := range x .Got {
99
99
if cmp .Equal (item , v , opts ... ) {
@@ -103,7 +103,7 @@ func (x FluentSlice[T]) NotContain(item T, opts ...cmp.Option) FailureMessage {
103
103
return ""
104
104
}
105
105
106
- // Any banana .
106
+ // Any tests if any of the slice's item meets the predicate criteria .
107
107
func (x FluentSlice [T ]) Any (predicate func (T ) bool ) FailureMessage {
108
108
for _ , v := range x .Got {
109
109
if predicate (v ) {
@@ -113,7 +113,7 @@ func (x FluentSlice[T]) Any(predicate func(T) bool) FailureMessage {
113
113
return FailureMessage (fmt .Sprintf ("none item does meet the predicate criteria\n got: %+v" , x .Got ))
114
114
}
115
115
116
- // All banana .
116
+ // All tests if all of the slice's items meets the predicate criteria .
117
117
func (x FluentSlice [T ]) All (predicate func (T ) bool ) FailureMessage {
118
118
for _ , v := range x .Got {
119
119
if ! predicate (v ) {
@@ -123,7 +123,7 @@ func (x FluentSlice[T]) All(predicate func(T) bool) FailureMessage {
123
123
return ""
124
124
}
125
125
126
- // None banana .
126
+ // None tests if all of the slice's item does not meet the predicate criteria .
127
127
func (x FluentSlice [T ]) None (predicate func (T ) bool ) FailureMessage {
128
128
for _ , v := range x .Got {
129
129
if predicate (v ) {
0 commit comments