| 519 | } |
| 520 | |
| 521 | func TestRegexpWrapper(t *testing.T) { |
| 522 | |
| 523 | assert := New(new(testing.T)) |
| 524 | |
| 525 | cases := []struct { |
| 526 | rx, str string |
| 527 | }{ |
| 528 | {"^start", "start of the line"}, |
| 529 | {"end$", "in the end"}, |
| 530 | {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, |
| 531 | } |
| 532 | |
| 533 | for _, tc := range cases { |
| 534 | True(t, assert.Regexp(tc.rx, tc.str)) |
| 535 | True(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) |
| 536 | False(t, assert.NotRegexp(tc.rx, tc.str)) |
| 537 | False(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) |
| 538 | } |
| 539 | |
| 540 | cases = []struct { |
| 541 | rx, str string |
| 542 | }{ |
| 543 | {"^asdfastart", "Not the start of the line"}, |
| 544 | {"end$", "in the end."}, |
| 545 | {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, |
| 546 | } |
| 547 | |
| 548 | for _, tc := range cases { |
| 549 | False(t, assert.Regexp(tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) |
| 550 | False(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) |
| 551 | True(t, assert.NotRegexp(tc.rx, tc.str)) |
| 552 | True(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | func TestZeroWrapper(t *testing.T) { |
| 557 | assert := New(t) |