mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
fixed8: remove trailing zeroes from string representation
Add some testcases from `dev` branch (with less than zero case added) and remove useless trailing zeroes from the resulting string.
This commit is contained in:
parent
d5d570f793
commit
c67217159f
3 changed files with 3 additions and 3 deletions
|
@ -165,7 +165,7 @@ var testRpcCases = []tc{
|
|||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "getaccountstate", "params": ["AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"] }`,
|
||||
method: "getaccountstate_1",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"version":0,"script_hash":"0xe9eed8dc39332032dc22e5d6e86332c50327ba23","frozen":false,"votes":[],"balances":[{"asset":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","value":"72099.99960000"},{"asset":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","value":"99989900"}]},"id":1}`,
|
||||
expectedResult: `{"jsonrpc":"2.0","result":{"version":0,"script_hash":"0xe9eed8dc39332032dc22e5d6e86332c50327ba23","frozen":false,"votes":[],"balances":[{"asset":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","value":"72099.9996"},{"asset":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","value":"99989900"}]},"id":1}`,
|
||||
},
|
||||
|
||||
// Bad case, invalid address
|
||||
|
|
|
@ -34,7 +34,7 @@ func (f Fixed8) String() string {
|
|||
for i := len(str); i < 8; i++ {
|
||||
buf.WriteRune('0')
|
||||
}
|
||||
buf.WriteString(str)
|
||||
buf.WriteString(strings.TrimRight(str, "0"))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestNewFixed8(t *testing.T) {
|
|||
|
||||
func TestFixed8DecodeString(t *testing.T) {
|
||||
// Fixed8DecodeString works correctly with integers
|
||||
ivalues := []string{"9000", "100000000", "5", "10945"}
|
||||
ivalues := []string{"9000", "100000000", "5", "10945", "20.45", "0.00000001", "-42"}
|
||||
for _, val := range ivalues {
|
||||
n, err := Fixed8DecodeString(val)
|
||||
assert.Nil(t, err)
|
||||
|
|
Loading…
Reference in a new issue