| 354 | } |
| 355 | |
| 356 | func TestNegative(t *testing.T) { |
| 357 | t.Parallel() |
| 358 | |
| 359 | mockT := new(testing.T) |
| 360 | |
| 361 | if !Negative(mockT, -1) { |
| 362 | t.Error("Negative should return true") |
| 363 | } |
| 364 | |
| 365 | if !Negative(mockT, -1.23) { |
| 366 | t.Error("Negative should return true") |
| 367 | } |
| 368 | |
| 369 | if Negative(mockT, 1) { |
| 370 | t.Error("Negative should return false") |
| 371 | } |
| 372 | |
| 373 | if Negative(mockT, 1.23) { |
| 374 | t.Error("Negative should return false") |
| 375 | } |
| 376 | |
| 377 | // Check error report |
| 378 | for _, currCase := range []struct { |
| 379 | e interface{} |
| 380 | msg string |
| 381 | }{ |
| 382 | {e: int(1), msg: `"1" is not negative`}, |
| 383 | {e: int8(1), msg: `"1" is not negative`}, |
| 384 | {e: int16(1), msg: `"1" is not negative`}, |
| 385 | {e: int32(1), msg: `"1" is not negative`}, |
| 386 | {e: int64(1), msg: `"1" is not negative`}, |
| 387 | {e: float32(1.23), msg: `"1.23" is not negative`}, |
| 388 | {e: float64(1.23), msg: `"1.23" is not negative`}, |
| 389 | } { |
| 390 | out := &outputT{buf: bytes.NewBuffer(nil)} |
| 391 | False(t, Negative(out, currCase.e)) |
| 392 | Contains(t, out.buf.String(), currCase.msg) |
| 393 | Contains(t, out.helpers, "github.com/stretchr/testify/assert.Negative") |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | func Test_compareTwoValuesDifferentValuesTypes(t *testing.T) { |
| 398 | t.Parallel() |