MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / TestNewPatternWithWrongOp

Function TestNewPatternWithWrongOp

runtime/pattern_test.go:127–190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func 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 }

Callers

nothing calls this directly

Calls 1

NewPatternFunction · 0.85

Tested by

no test coverage detected