(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func TestNewPatternWithWrongOp(t *testing.T) { |
| 128 | for _, spec := range []struct { |
| 129 | ops []int |
| 130 | pool []string |
| 131 | verb string |
| 132 | }{ |
| 133 | { |
| 134 | // op code out of bound |
| 135 | ops: []int{-1, anything}, |
| 136 | }, |
| 137 | { |
| 138 | // op code out of bound |
| 139 | ops: []int{int(utilities.OpEnd), 0}, |
| 140 | }, |
| 141 | { |
| 142 | // odd number of items |
| 143 | ops: []int{int(utilities.OpPush)}, |
| 144 | }, |
| 145 | { |
| 146 | // negative index |
| 147 | ops: []int{int(utilities.OpLitPush), -1}, |
| 148 | pool: []string{"abc"}, |
| 149 | }, |
| 150 | { |
| 151 | // index out of bound |
| 152 | ops: []int{int(utilities.OpLitPush), 1}, |
| 153 | pool: []string{"abc"}, |
| 154 | }, |
| 155 | { |
| 156 | // negative # of segments |
| 157 | ops: []int{int(utilities.OpConcatN), -1}, |
| 158 | pool: []string{"abc"}, |
| 159 | }, |
| 160 | { |
| 161 | // negative index |
| 162 | ops: []int{int(utilities.OpCapture), -1}, |
| 163 | pool: []string{"abc"}, |
| 164 | }, |
| 165 | { |
| 166 | // index out of bound |
| 167 | ops: []int{int(utilities.OpCapture), 1}, |
| 168 | pool: []string{"abc"}, |
| 169 | }, |
| 170 | { |
| 171 | // pushM appears twice |
| 172 | ops: []int{ |
| 173 | int(utilities.OpPushM), anything, |
| 174 | int(utilities.OpLitPush), 0, |
| 175 | int(utilities.OpPushM), anything, |
| 176 | }, |
| 177 | pool: []string{"abc"}, |
| 178 | }, |
| 179 | } { |
| 180 | _, err := NewPattern(validVersion, spec.ops, spec.pool, spec.verb) |
| 181 | if err == nil { |
| 182 | t.Errorf("NewPattern(%d, %v, %q, %q) succeeded; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, ErrInvalidPattern) |
| 183 | continue |
| 184 | } |
nothing calls this directly
no test coverage detected