MCPcopy
hub / github.com/stretchr/testify / TestRegexpWrapper

Function TestRegexpWrapper

assert/forward_assertions_test.go:567–601  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

565}
566
567func TestRegexpWrapper(t *testing.T) {
568 t.Parallel()
569
570 assert := New(new(testing.T))
571
572 cases := []struct {
573 rx, str string
574 }{
575 {"^start", "start of the line"},
576 {"end$", "in the end"},
577 {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"},
578 }
579
580 for _, tc := range cases {
581 True(t, assert.Regexp(tc.rx, tc.str))
582 True(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str))
583 False(t, assert.NotRegexp(tc.rx, tc.str))
584 False(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str))
585 }
586
587 cases = []struct {
588 rx, str string
589 }{
590 {"^asdfastart", "Not the start of the line"},
591 {"end$", "in the end."},
592 {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"},
593 }
594
595 for _, tc := range cases {
596 False(t, assert.Regexp(tc.rx, tc.str), "Expected %q to not match %q", tc.rx, tc.str)
597 False(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str))
598 True(t, assert.NotRegexp(tc.rx, tc.str))
599 True(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str))
600 }
601}
602
603func TestZeroWrapper(t *testing.T) {
604 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
TrueFunction · 0.70
FalseFunction · 0.70
RegexpMethod · 0.45
NotRegexpMethod · 0.45

Tested by

no test coverage detected