HasPrefix succeeds if string has given Go string as prefix Example: str := NewString(t, "Hello World") str.HasPrefix("Hello")
(value string)
| 629 | // str := NewString(t, "Hello World") |
| 630 | // str.HasPrefix("Hello") |
| 631 | func (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 | // |