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.

22 lines
411 B

  1. package common
  2. import (
  3. "math/big"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestIdx(t *testing.T) {
  8. i := Idx(100)
  9. assert.Equal(t, big.NewInt(100), i.BigInt())
  10. i = Idx(uint32(4294967295))
  11. assert.Equal(t, "4294967295", i.BigInt().String())
  12. b := big.NewInt(4294967296)
  13. i, err := IdxFromBigInt(b)
  14. assert.NotNil(t, err)
  15. assert.Equal(t, ErrNumOverflow, err)
  16. assert.Equal(t, Idx(0), i)
  17. }