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