|
|
@ -23,7 +23,7 @@ import ( |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func TestParseBig256(t *testing.T) { |
|
|
|
func TestHexOrDecimal256(t *testing.T) { |
|
|
|
tests := []struct { |
|
|
|
tests := []struct { |
|
|
|
input string |
|
|
|
input string |
|
|
|
num *big.Int |
|
|
|
num *big.Int |
|
|
@ -47,13 +47,14 @@ func TestParseBig256(t *testing.T) { |
|
|
|
{"115792089237316195423570985008687907853269984665640564039457584007913129639936", nil, false}, |
|
|
|
{"115792089237316195423570985008687907853269984665640564039457584007913129639936", nil, false}, |
|
|
|
} |
|
|
|
} |
|
|
|
for _, test := range tests { |
|
|
|
for _, test := range tests { |
|
|
|
num, ok := ParseBig256(test.input) |
|
|
|
var num HexOrDecimal256 |
|
|
|
if ok != test.ok { |
|
|
|
err := num.UnmarshalText([]byte(test.input)) |
|
|
|
t.Errorf("ParseBig(%q) -> ok = %t, want %t", test.input, ok, test.ok) |
|
|
|
if (err == nil) != test.ok { |
|
|
|
|
|
|
|
t.Errorf("ParseBig(%q) -> (err == nil) == %t, want %t", test.input, err == nil, test.ok) |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if num != nil && test.num != nil && num.Cmp(test.num) != 0 { |
|
|
|
if test.num != nil && (*big.Int)(&num).Cmp(test.num) != 0 { |
|
|
|
t.Errorf("ParseBig(%q) -> %d, want %d", test.input, num, test.num) |
|
|
|
t.Errorf("ParseBig(%q) -> %d, want %d", test.input, (*big.Int)(&num), test.num) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|