MCPcopy Index your code
hub / github.com/gavv/httpexpect / Contains

Method Contains

string.go:517–537  ·  view source on GitHub ↗

Contains succeeds if string contains given Go string as a substring. Example: str := NewString(t, "Hello") str.Contains("ell")

(value string)

Source from the content-addressed store, hash-verified

515// str := NewString(t, "Hello")
516// str.Contains("ell")
517func (s *String) Contains(value string) *String {
518 opChain := s.chain.enter("Contains()")
519 defer opChain.leave()
520
521 if opChain.failed() {
522 return s
523 }
524
525 if !strings.Contains(s.value, value) {
526 opChain.fail(AssertionFailure{
527 Type: AssertContainsSubset,
528 Actual: &AssertionValue{s.value},
529 Expected: &AssertionValue{value},
530 Errors: []error{
531 errors.New("expected: string contains sub-string"),
532 },
533 })
534 }
535
536 return s
537}
538
539// NotContains succeeds if string doesn't contain Go string as a substring.
540//

Callers 3

NotContainsMethod · 0.45
ContainsFoldMethod · 0.45
NotContainsFoldMethod · 0.45

Calls 4

enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by

no test coverage detected