You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
640 B

  1. package test
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. // AssertUSD asserts pointers to float64, and checks that they are equal
  7. // with a tolerance of 0.01%. After that, the actual value is setted to the expected value
  8. // in order to be able to perform further assertions using the standar assert functions.
  9. func AssertUSD(t *testing.T, expected, actual *float64) {
  10. if actual == nil {
  11. assert.Equal(t, expected, actual)
  12. return
  13. }
  14. if *expected < *actual {
  15. assert.InEpsilon(t, *actual, *expected, 0.0001)
  16. } else if *expected > *actual {
  17. assert.InEpsilon(t, *expected, *actual, 0.0001)
  18. }
  19. *expected = *actual
  20. }