Equals asserts that the supplied string is equal to the expected string.
(expect string)
| 43 | |
| 44 | // Equals asserts that the supplied string is equal to the expected string. |
| 45 | func (o OnString) Equals(expect string) bool { |
| 46 | return o.Compare(o.value, "==", expect).Test(func() bool { |
| 47 | if o.value == expect { |
| 48 | return true |
| 49 | } |
| 50 | re := ([]rune)(expect) |
| 51 | for i, c := range o.value { |
| 52 | if i >= len(re) { |
| 53 | o.Printf("Longer\tby\t") |
| 54 | o.Println(o.value[i:]) |
| 55 | return false |
| 56 | } |
| 57 | if c != re[i] { |
| 58 | o.Printf("Differs\tfrom\t") |
| 59 | o.Println(o.value[i:]) |
| 60 | return false |
| 61 | } |
| 62 | } |
| 63 | o.Printf("Shorter\tby\t") |
| 64 | o.Println(expect[len(o.value):]) |
| 65 | return false |
| 66 | }()) |
| 67 | } |
| 68 | |
| 69 | // NotEquals asserts that the supplied string is not equal to the test string. |
| 70 | func (o OnString) NotEquals(test string) bool { |