MCPcopy
hub / github.com/expr-lang/expr / TestRegexpWrapper

Function TestRegexpWrapper

internal/testify/assert/forward_assertions_test.go:521–554  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

519}
520
521func 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
556func TestZeroWrapper(t *testing.T) {
557 assert := New(t)

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…