Commit b96a59eb authored by Taylor Gerring's avatar Taylor Gerring

Added tests for extra large values

Test “E” scientific notation formatting
parent e7d9bcd3
...@@ -66,6 +66,7 @@ func CurrencyToString(num *big.Int) string { ...@@ -66,6 +66,7 @@ func CurrencyToString(num *big.Int) string {
denom = "Ada" denom = "Ada"
} }
// TODO add comment clarifying expected behavior
if len(fin.String()) > 5 { if len(fin.String()) > 5 {
return fmt.Sprintf("%sE%d %s", fin.String()[0:5], len(fin.String())-5, denom) return fmt.Sprintf("%sE%d %s", fin.String()[0:5], len(fin.String())-5, denom)
} }
......
...@@ -79,3 +79,21 @@ func TestCommon(t *testing.T) { ...@@ -79,3 +79,21 @@ func TestCommon(t *testing.T) {
t.Error("Got", wei) 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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment