aboutsummaryrefslogtreecommitdiffstats
path: root/common/math/integer_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-03-08 06:19:44 +0800
committerFelix Lange <fjl@twurst.com>2017-03-23 22:58:42 +0800
commit04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76 (patch)
tree61cdf35a8b91b8d67cc34738cdd60253acdb9326 /common/math/integer_test.go
parent61d2150a0750a554250c3bf090ef994be6c060f0 (diff)
downloaddexon-04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76.tar
dexon-04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76.tar.gz
dexon-04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76.tar.bz2
dexon-04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76.tar.lz
dexon-04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76.tar.xz
dexon-04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76.tar.zst
dexon-04fa6a374499dcefeb3f854c4cf6cfcdfb6c8c76.zip
common/math: add HexOrDecimal64, HexOrDecimal256
Diffstat (limited to 'common/math/integer_test.go')
-rw-r--r--common/math/integer_test.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/math/integer_test.go b/common/math/integer_test.go
index 05bba221f..b31c7c26c 100644
--- a/common/math/integer_test.go
+++ b/common/math/integer_test.go
@@ -65,7 +65,7 @@ func TestOverflow(t *testing.T) {
}
}
-func TestParseUint64(t *testing.T) {
+func TestHexOrDecimal64(t *testing.T) {
tests := []struct {
input string
num uint64
@@ -88,12 +88,13 @@ func TestParseUint64(t *testing.T) {
{"18446744073709551617", 0, false},
}
for _, test := range tests {
- num, ok := ParseUint64(test.input)
- if ok != test.ok {
- t.Errorf("ParseUint64(%q) -> ok = %t, want %t", test.input, ok, test.ok)
+ var num HexOrDecimal64
+ err := num.UnmarshalText([]byte(test.input))
+ if (err == nil) != test.ok {
+ t.Errorf("ParseUint64(%q) -> (err == nil) = %t, want %t", test.input, err == nil, test.ok)
continue
}
- if ok && num != test.num {
+ if err == nil && uint64(num) != test.num {
t.Errorf("ParseUint64(%q) -> %d, want %d", test.input, num, test.num)
}
}