| 303 | } |
| 304 | |
| 305 | func TestPositive(t *testing.T) { |
| 306 | mockT := new(testing.T) |
| 307 | |
| 308 | if !Positive(mockT, 1) { |
| 309 | t.Error("Positive should return true") |
| 310 | } |
| 311 | |
| 312 | if !Positive(mockT, 1.23) { |
| 313 | t.Error("Positive should return true") |
| 314 | } |
| 315 | |
| 316 | if Positive(mockT, -1) { |
| 317 | t.Error("Positive should return false") |
| 318 | } |
| 319 | |
| 320 | if Positive(mockT, -1.23) { |
| 321 | t.Error("Positive should return false") |
| 322 | } |
| 323 | |
| 324 | // Check error report |
| 325 | for _, currCase := range []struct { |
| 326 | e interface{} |
| 327 | msg string |
| 328 | }{ |
| 329 | {e: int(-1), msg: `"-1" is not positive`}, |
| 330 | {e: int8(-1), msg: `"-1" is not positive`}, |
| 331 | {e: int16(-1), msg: `"-1" is not positive`}, |
| 332 | {e: int32(-1), msg: `"-1" is not positive`}, |
| 333 | {e: int64(-1), msg: `"-1" is not positive`}, |
| 334 | {e: float32(-1.23), msg: `"-1.23" is not positive`}, |
| 335 | {e: float64(-1.23), msg: `"-1.23" is not positive`}, |
| 336 | } { |
| 337 | out := &outputT{buf: bytes.NewBuffer(nil)} |
| 338 | False(t, Positive(out, currCase.e)) |
| 339 | Contains(t, out.buf.String(), currCase.msg) |
| 340 | Contains(t, out.helpers, "github.com/expr-lang/expr/internal/testify/assert.Positive") |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | func TestNegative(t *testing.T) { |
| 345 | mockT := new(testing.T) |