|
| 1 | +package operator |
| 2 | + |
| 3 | +import "testing" |
| 4 | + |
| 5 | +func TestNotContains(t *testing.T) { |
| 6 | + var inputs = []struct { |
| 7 | + title string |
| 8 | + value interface{} |
| 9 | + input interface{} |
| 10 | + want bool |
| 11 | + }{ |
| 12 | + {title: "contains-1", value: "word to", input: "my word to match", want: false}, |
| 13 | + {title: "contains-2", value: "my", input: "my word to match", want: false}, |
| 14 | + {title: "contains-3", value: "myword", input: "my word to match", want: true}, |
| 15 | + {title: "contains-4", value: 2, input: []int{1, 2, 3}, want: false}, |
| 16 | + {title: "contains-5", value: 2.5, input: []float64{2.0, 2.3, 2.5, 3}, want: false}, |
| 17 | + {title: "contains-6", value: "c", input: []string{"a", "b", "c"}, want: false}, |
| 18 | + {title: "contains-7", value: "d", input: []string{"a", "b", "c"}, want: true}, |
| 19 | + } |
| 20 | + |
| 21 | + for _, input := range inputs { |
| 22 | + t.Run(input.title, func(t *testing.T) { |
| 23 | + got := NotContains.Evaluate(input.input, input.value) |
| 24 | + if got != input.want { |
| 25 | + t.Errorf("%v not contains %v got: %t, want: %t", input.input, input.value, got, input.want) |
| 26 | + } |
| 27 | + }) |
| 28 | + } |
| 29 | +} |
0 commit comments