(t *testing.T)
| 2165 | } |
| 2166 | |
| 2167 | func TestArray_NotFind(t *testing.T) { |
| 2168 | t.Run("no match", func(t *testing.T) { |
| 2169 | reporter := newMockReporter(t) |
| 2170 | array := NewArray(reporter, []interface{}{1, "foo", true, "bar"}) |
| 2171 | |
| 2172 | afterArray := array.NotFind(func(index int, value *Value) bool { |
| 2173 | return value.String().Raw() == "baz" |
| 2174 | }) |
| 2175 | |
| 2176 | assert.Same(t, array, afterArray) |
| 2177 | array.chain.assert(t, success) |
| 2178 | }) |
| 2179 | |
| 2180 | t.Run("have match", func(t *testing.T) { |
| 2181 | reporter := newMockReporter(t) |
| 2182 | array := NewArray(reporter, []interface{}{1, "foo", true, "bar"}) |
| 2183 | |
| 2184 | afterArray := array.NotFind(func(index int, value *Value) bool { |
| 2185 | return value.String().NotEmpty().Raw() == "bar" |
| 2186 | }) |
| 2187 | |
| 2188 | assert.Same(t, array, afterArray) |
| 2189 | array.chain.assert(t, failure) |
| 2190 | }) |
| 2191 | |
| 2192 | t.Run("empty array", func(t *testing.T) { |
| 2193 | reporter := newMockReporter(t) |
| 2194 | array := NewArray(reporter, []interface{}{}) |
| 2195 | |
| 2196 | afterArray := array.NotFind(func(index int, value *Value) bool { |
| 2197 | return value.Raw() == 2.0 |
| 2198 | }) |
| 2199 | |
| 2200 | assert.Same(t, array, afterArray) |
| 2201 | array.chain.assert(t, success) |
| 2202 | }) |
| 2203 | |
| 2204 | t.Run("predicate returns true, assertion fails, no match", func(t *testing.T) { |
| 2205 | reporter := newMockReporter(t) |
| 2206 | array := NewArray(reporter, []interface{}{1, 2}) |
| 2207 | |
| 2208 | afterArray := array.NotFind(func(index int, value *Value) bool { |
| 2209 | value.String() |
| 2210 | return true |
| 2211 | }) |
| 2212 | |
| 2213 | assert.Same(t, array, afterArray) |
| 2214 | array.chain.assert(t, success) |
| 2215 | }) |
| 2216 | |
| 2217 | t.Run("predicate returns true, assertion fails, have match", func(t *testing.T) { |
| 2218 | reporter := newMockReporter(t) |
| 2219 | array := NewArray(reporter, []interface{}{1, 2, "str"}) |
| 2220 | |
| 2221 | afterArray := array.NotFind(func(index int, value *Value) bool { |
| 2222 | value.String() |
| 2223 | return true |
| 2224 | }) |
nothing calls this directly
no test coverage detected
searching dependent graphs…