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

Method HasPrefix

string.go:631–651  ·  view source on GitHub ↗

HasPrefix succeeds if string has given Go string as prefix Example: str := NewString(t, "Hello World") str.HasPrefix("Hello")

(value string)

Source from the content-addressed store, hash-verified

629// str := NewString(t, "Hello World")
630// str.HasPrefix("Hello")
631func (s *String) HasPrefix(value string) *String {
632 opChain := s.chain.enter("HasPrefix()")
633 defer opChain.leave()
634
635 if opChain.failed() {
636 return s
637 }
638
639 if !strings.HasPrefix(s.value, value) {
640 opChain.fail(AssertionFailure{
641 Type: AssertContainsSubset,
642 Actual: &AssertionValue{s.value},
643 Expected: &AssertionValue{value},
644 Errors: []error{
645 errors.New("expected: string has prefix"),
646 },
647 })
648 }
649
650 return s
651}
652
653// NotHasPrefix succeeds if string doesn't have given Go string as prefix
654//

Callers 11

TestFastBinder_TLSFunction · 0.80
TestString_FailedChainFunction · 0.80
TestString_HasPrefixFunction · 0.80
NotHasPrefixMethod · 0.80
HasPrefixFoldMethod · 0.80
NotHasPrefixFoldMethod · 0.80
colorModeFunction · 0.80
formatter.goFile · 0.80
TestFruitsFunction · 0.80
testAutoTLSHandlerFunction · 0.80
TestE2EAutoTLS_LiveFunction · 0.80

Calls 4

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

Tested by 6

TestFastBinder_TLSFunction · 0.64
TestString_FailedChainFunction · 0.64
TestString_HasPrefixFunction · 0.64
TestFruitsFunction · 0.64
testAutoTLSHandlerFunction · 0.64
TestE2EAutoTLS_LiveFunction · 0.64