diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2014-11-04 23:45:54 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2014-11-04 23:45:54 +0800 |
commit | b96a59eb28654ba5bc915bfaa21f511fdaa443df (patch) | |
tree | c840f61e26bdf60d3a86a9dc3dfc2872fed2076f | |
parent | e7d9bcd36b5809b649dc7f8e6092d5edaa0d155f (diff) | |
download | go-tangerine-b96a59eb28654ba5bc915bfaa21f511fdaa443df.tar.gz go-tangerine-b96a59eb28654ba5bc915bfaa21f511fdaa443df.tar.zst go-tangerine-b96a59eb28654ba5bc915bfaa21f511fdaa443df.zip |
Added tests for extra large values
Test āEā scientific notation formatting
-rw-r--r-- | ethutil/common.go | 1 | ||||
-rw-r--r-- | ethutil/common_test.go | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/ethutil/common.go b/ethutil/common.go index e60f237cf..0a29cac6c 100644 --- a/ethutil/common.go +++ b/ethutil/common.go @@ -66,6 +66,7 @@ func CurrencyToString(num *big.Int) string { denom = "Ada" } + // TODO add comment clarifying expected behavior if len(fin.String()) > 5 { return fmt.Sprintf("%sE%d %s", fin.String()[0:5], len(fin.String())-5, denom) } diff --git a/ethutil/common_test.go b/ethutil/common_test.go index 791ff0a25..056676765 100644 --- a/ethutil/common_test.go +++ b/ethutil/common_test.go @@ -79,3 +79,21 @@ func TestCommon(t *testing.T) { t.Error("Got", wei) } } + +func TestLarge(t *testing.T) { + douglaslarge := CurrencyToString(BigPow(100000000, 43)) + adalarge := CurrencyToString(BigPow(100000000, 4)) + weilarge := CurrencyToString(big.NewInt(100000000)) + + if douglaslarge != "10000E298 Douglas" { + t.Error("Got", douglaslarge) + } + + if adalarge != "10000E7 Einstein" { + t.Error("Got", adalarge) + } + + if weilarge != "100 Babbage" { + t.Error("Got", weilarge) + } +} |