MCPcopy Create free account
hub / github.com/containers/image / checkRegexp

Function checkRegexp

docker/reference/regexp_test.go:19–38  ·  view source on GitHub ↗
(t *testing.T, r Regex, m regexpMatch)

Source from the content-addressed store, hash-verified

17}
18
19func checkRegexp(t *testing.T, r Regex, m regexpMatch) {
20 matches := r.FindStringSubmatch(m.input)
21 if m.match && matches != nil {
22 if len(matches) != (r.NumSubexp()+1) || matches[0] != m.input {
23 t.Fatalf("Bad match result %#v for %q", matches, m.input)
24 }
25 if len(matches) < (len(m.subs) + 1) {
26 t.Errorf("Expected %d sub matches, only have %d for %q", len(m.subs), len(matches)-1, m.input)
27 }
28 for i := range m.subs {
29 if m.subs[i] != matches[i+1] {
30 t.Errorf("Unexpected submatch %d: %q, expected %q for %q", i+1, matches[i+1], m.subs[i], m.input)
31 }
32 }
33 } else if m.match {
34 t.Errorf("Expected match for %q", m.input)
35 } else if matches != nil {
36 t.Errorf("Unexpected match for %q", m.input)
37 }
38}
39
40func TestDomainRegexp(t *testing.T) {
41 hostcases := []regexpMatch{

Callers 4

TestDomainRegexpFunction · 0.85
TestFullNameRegexpFunction · 0.85
TestReferenceRegexpFunction · 0.85
TestIdentifierRegexpFunction · 0.85

Calls 2

FindStringSubmatchMethod · 0.80
NumSubexpMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…