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

Function TestMatch

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

Source from the content-addressed store, hash-verified

216}
217
218func TestMatch(t *testing.T) {
219 for _, spec := range []struct {
220 ops []int
221 pool []string
222 verb string
223
224 match []string
225 notMatch []string
226 }{
227 {
228 match: []string{""},
229 notMatch: []string{"example"},
230 },
231 {
232 ops: []int{int(utilities.OpNop), anything},
233 match: []string{""},
234 notMatch: []string{"example", "path/to/example"},
235 },
236 {
237 ops: []int{int(utilities.OpPush), anything},
238 match: []string{"abc", "def"},
239 notMatch: []string{"", "abc/def"},
240 },
241 {
242 ops: []int{int(utilities.OpLitPush), 0},
243 pool: []string{"v1"},
244 match: []string{"v1"},
245 notMatch: []string{"", "v2"},
246 },
247 {
248 ops: []int{int(utilities.OpPushM), anything},
249 match: []string{"", "abc", "abc/def", "abc/def/ghi"},
250 },
251 {
252 ops: []int{
253 int(utilities.OpPushM), anything,
254 int(utilities.OpLitPush), 0,
255 },
256 pool: []string{"tail"},
257 match: []string{"tail", "abc/tail", "abc/def/tail"},
258 notMatch: []string{
259 "", "abc", "abc/def",
260 "tail/extra", "abc/tail/extra", "abc/def/tail/extra",
261 },
262 },
263 {
264 ops: []int{
265 int(utilities.OpLitPush), 0,
266 int(utilities.OpLitPush), 1,
267 int(utilities.OpPush), anything,
268 int(utilities.OpConcatN), 1,
269 int(utilities.OpCapture), 2,
270 },
271 pool: []string{"v1", "bucket", "name"},
272 match: []string{"v1/bucket/my-bucket", "v1/bucket/our-bucket"},
273 notMatch: []string{
274 "",
275 "v1",

Callers

nothing calls this directly

Calls 3

MatchMethod · 0.95
NewPatternFunction · 0.85
segmentsFunction · 0.85

Tested by

no test coverage detected