(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestString(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | input string |
| 12 | s string |
| 13 | expected bool |
| 14 | expectedIndex int64 |
| 15 | }{ |
| 16 | { |
| 17 | input: "ABC", |
| 18 | s: "ABC", |
| 19 | expected: true, |
| 20 | expectedIndex: 3, |
| 21 | }, |
| 22 | { |
| 23 | input: "ABC", |
| 24 | s: "AB", |
| 25 | expected: true, |
| 26 | expectedIndex: 2, |
| 27 | }, |
| 28 | { |
| 29 | input: "ABC", |
| 30 | s: "DEF", |
| 31 | expected: false, |
| 32 | expectedIndex: 0, |
| 33 | }, |
| 34 | { |
| 35 | input: "ABC", |
| 36 | s: "BCD", |
| 37 | expected: false, |
| 38 | expectedIndex: 0, |
| 39 | }, |
| 40 | { |
| 41 | input: "ABD", |
| 42 | s: "ABC", |
| 43 | expected: false, |
| 44 | expectedIndex: 0, |
| 45 | }, |
| 46 | } |
| 47 | |
| 48 | for i, test := range tests { |
| 49 | pi := input.NewFromString(test.input) |
| 50 | parser := String(test.s) |
| 51 | result := parser(pi) |
| 52 | actual := result.Success |
| 53 | if actual != test.expected { |
| 54 | t.Errorf("test %v: for input '%v' expected %v but got %v", i, test.input, test.expected, actual) |
| 55 | } |
| 56 | if test.expectedIndex != pi.Index() { |
| 57 | t.Errorf("test %v: for input '%v' expected index %d, got %d", i, test.input, test.expectedIndex, pi.Index()) |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | func TestStringInsensitive(t *testing.T) { |
| 63 | tests := []struct { |
nothing calls this directly
no test coverage detected