| 221 | } |
| 222 | |
| 223 | func TestLess(t *testing.T) { |
| 224 | t.Parallel() |
| 225 | |
| 226 | mockT := new(testing.T) |
| 227 | |
| 228 | if !Less(mockT, 1, 2) { |
| 229 | t.Error("Less should return true") |
| 230 | } |
| 231 | |
| 232 | if Less(mockT, 1, 1) { |
| 233 | t.Error("Less should return false") |
| 234 | } |
| 235 | |
| 236 | if Less(mockT, 2, 1) { |
| 237 | t.Error("Less should return false") |
| 238 | } |
| 239 | |
| 240 | // Check error report |
| 241 | for _, currCase := range []struct { |
| 242 | less interface{} |
| 243 | greater interface{} |
| 244 | msg string |
| 245 | }{ |
| 246 | {less: "a", greater: "b", msg: `"b" is not less than "a"`}, |
| 247 | {less: int(1), greater: int(2), msg: `"2" is not less than "1"`}, |
| 248 | {less: int8(1), greater: int8(2), msg: `"2" is not less than "1"`}, |
| 249 | {less: int16(1), greater: int16(2), msg: `"2" is not less than "1"`}, |
| 250 | {less: int32(1), greater: int32(2), msg: `"2" is not less than "1"`}, |
| 251 | {less: int64(1), greater: int64(2), msg: `"2" is not less than "1"`}, |
| 252 | {less: uint8(1), greater: uint8(2), msg: `"2" is not less than "1"`}, |
| 253 | {less: uint16(1), greater: uint16(2), msg: `"2" is not less than "1"`}, |
| 254 | {less: uint32(1), greater: uint32(2), msg: `"2" is not less than "1"`}, |
| 255 | {less: uint64(1), greater: uint64(2), msg: `"2" is not less than "1"`}, |
| 256 | {less: float32(1.23), greater: float32(2.34), msg: `"2.34" is not less than "1.23"`}, |
| 257 | {less: float64(1.23), greater: float64(2.34), msg: `"2.34" is not less than "1.23"`}, |
| 258 | {less: uintptr(1), greater: uintptr(2), msg: `"2" is not less than "1"`}, |
| 259 | {less: time.Time{}, greater: time.Time{}.Add(time.Hour), msg: `"0001-01-01 01:00:00 +0000 UTC" is not less than "0001-01-01 00:00:00 +0000 UTC"`}, |
| 260 | {less: []byte{1, 1}, greater: []byte{1, 2}, msg: `"[1 2]" is not less than "[1 1]"`}, |
| 261 | } { |
| 262 | out := &outputT{buf: bytes.NewBuffer(nil)} |
| 263 | False(t, Less(out, currCase.greater, currCase.less)) |
| 264 | Contains(t, out.buf.String(), currCase.msg) |
| 265 | Contains(t, out.helpers, "github.com/stretchr/testify/assert.Less") |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | func TestLessOrEqual(t *testing.T) { |
| 270 | t.Parallel() |