MCPcopy Create free account
hub / github.com/gavv/httpexpect / NotMatch

Method NotMatch

string.go:920–950  ·  view source on GitHub ↗

NotMatch succeeds if the string doesn't match to given regexp. regexp.Compile is used to construct regexp, and Regexp.MatchString is used to perform match. Example: s := NewString(t, "a") s.NotMatch(`[^a]`)

(re string)

Source from the content-addressed store, hash-verified

918// s := NewString(t, "a")
919// s.NotMatch(`[^a]`)
920func (s *String) NotMatch(re string) *String {
921 opChain := s.chain.enter("NotMatch()")
922 defer opChain.leave()
923
924 rx, err := regexp.Compile(re)
925 if err != nil {
926 opChain.fail(AssertionFailure{
927 Type: AssertValid,
928 Actual: &AssertionValue{re},
929 Errors: []error{
930 errors.New("expected: valid regexp"),
931 err,
932 },
933 })
934 return s
935 }
936
937 if rx.MatchString(s.value) {
938 opChain.fail(AssertionFailure{
939 Type: AssertNotMatchRegexp,
940 Actual: &AssertionValue{s.value},
941 Expected: &AssertionValue{re},
942 Errors: []error{
943 errors.New("expected: string does not match regexp"),
944 },
945 })
946 return s
947 }
948
949 return s
950}
951
952// MatchAll find all matches in string for given regexp and returns a list
953// of found matches.

Callers 2

TestString_MatchFunction · 0.95
TestString_FailedChainFunction · 0.80

Calls 3

enterMethod · 0.80
leaveMethod · 0.80
failMethod · 0.80

Tested by 2

TestString_MatchFunction · 0.76
TestString_FailedChainFunction · 0.64