(t *testing.T, r Regex, m regexpMatch)
| 17 | } |
| 18 | |
| 19 | func 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 | |
| 40 | func TestDomainRegexp(t *testing.T) { |
| 41 | hostcases := []regexpMatch{ |
no test coverage detected
searching dependent graphs…