| 1 | package matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.21.4 strings/" |
| 6 | ) |
| 7 | |
| 8 | // EndWithMatcher accepts a string and succeeds |
| 9 | // if the actual string ends with the expected string. |
| 10 | type EndWithMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher# struct { |
| 11 | suffixscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher#suffix. string |
| 12 | } |
| 13 | |
| 14 | // EndWith returns an EndWithMatcher with the expected suffix. |
| 15 | func EndWithscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWith().(suffix string) EndWithMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher# { |
| 16 | return EndWithMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher#{ |
| 17 | suffixscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher#suffix.: suffix, |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func (m EndWithMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher#) Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher#Match().(actual any) (any, error) { |
| 22 | s, ok := actual.(string) |
| 23 | if !ok { |
| 24 | return nil, fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("'%v' (%T) is not a string", actual, actual) |
| 25 | } |
| 26 | |
| 27 | if !stringsscip-go gomod github.com/golang/go/src go1.21.4 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.21.4 strings/HasSuffix().(s, m.suffixscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher#suffix.) { |
| 28 | return nil, fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("%s does not end with %s", s, m.suffixscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/EndWithMatcher#suffix.) |
| 29 | } |
| 30 | |
| 31 | return actual, nil |
| 32 | } |