| 342 | } |
| 343 | |
| 344 | func TestNegative(t *testing.T) { |
| 345 | mockT := new(testing.T) |
| 346 | |
| 347 | if !Negative(mockT, -1) { |
| 348 | t.Error("Negative should return true") |
| 349 | } |
| 350 | |
| 351 | if !Negative(mockT, -1.23) { |
| 352 | t.Error("Negative should return true") |
| 353 | } |
| 354 | |
| 355 | if Negative(mockT, 1) { |
| 356 | t.Error("Negative should return false") |
| 357 | } |
| 358 | |
| 359 | if Negative(mockT, 1.23) { |
| 360 | t.Error("Negative should return false") |
| 361 | } |
| 362 | |
| 363 | // Check error report |
| 364 | for _, currCase := range []struct { |
| 365 | e interface{} |
| 366 | msg string |
| 367 | }{ |
| 368 | {e: int(1), msg: `"1" is not negative`}, |
| 369 | {e: int8(1), msg: `"1" is not negative`}, |
| 370 | {e: int16(1), msg: `"1" is not negative`}, |
| 371 | {e: int32(1), msg: `"1" is not negative`}, |
| 372 | {e: int64(1), msg: `"1" is not negative`}, |
| 373 | {e: float32(1.23), msg: `"1.23" is not negative`}, |
| 374 | {e: float64(1.23), msg: `"1.23" is not negative`}, |
| 375 | } { |
| 376 | out := &outputT{buf: bytes.NewBuffer(nil)} |
| 377 | False(t, Negative(out, currCase.e)) |
| 378 | Contains(t, out.buf.String(), currCase.msg) |
| 379 | Contains(t, out.helpers, "github.com/expr-lang/expr/internal/testify/assert.Negative") |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | func Test_compareTwoValuesDifferentValuesTypes(t *testing.T) { |
| 384 | mockT := new(testing.T) |