When comparing std big.Int's or big.Float's there is an edge case for the value zero where is reports the error 0 != 0. The reason for this is the big.{Int,Float} attribute neg bool which can be both true and false for the value zero.
Example
package main
import (
"math/big"
"testing"
"github.com/matryer/is"
)
func TestBig(t *testing.T) {
is := is.NewRelaxed(t)
big0 := new(big.Int).Add(big.NewInt(-1), big.NewInt(1))
is.Equal(new(big.Int), big0) // big.Int
is.Equal(new(big.Float), big.NewFloat(0)) // big.Float
}
This will result in:
is_test.go:13: 0 != 0 // big.Int
is_test.go:14: 0 != 0 // big.Float
--- FAIL: TestBig (0.00s)
FAIL
It's not really a bug since the structs are different after all. However, since this are std types it would be nice if they would be compared by their Cmp function.
When comparing std
big.Int's orbig.Float's there is an edge case for the value zero whereisreports the error0 != 0. The reason for this is thebig.{Int,Float}attributeneg boolwhich can be bothtrueandfalsefor the value zero.Example
This will result in:
It's not really a bug since the structs are different after all. However, since this are std types it would be nice if they would be compared by their
Cmpfunction.