| 565 | } |
| 566 | |
| 567 | func 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 | |
| 603 | func TestZeroWrapper(t *testing.T) { |
| 604 | t.Parallel() |