test(math): fix FormatDec test (#15215)

This commit is contained in:
Julien Robert 2023-02-28 15:57:42 +01:00 committed by GitHub
parent 17ba80df7c
commit 1273c05ada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 1 deletions

View File

@ -671,7 +671,7 @@ func BenchmarkLegacyQuoRoundupMut(b *testing.B) {
func TestFormatDec(t *testing.T) {
type decimalTest []string
var testcases []decimalTest
raw, err := os.ReadFile("../x/tx/textual/internal/testdata/decimals.json")
raw, err := os.ReadFile("./testdata/decimals.json")
require.NoError(t, err)
err = json.Unmarshal(raw, &testcases)
require.NoError(t, err)

47
math/testdata/decimals.json vendored Normal file
View File

@ -0,0 +1,47 @@
[
["0", "0"],
["1", "1"],
["12", "12"],
["123", "123"],
["1234", "1'234"],
["0.1", "0.1"],
["0.01", "0.01"],
["0.001", "0.001"],
["0.0001", "0.0001"],
["0.00001", "0.00001"],
["0.000001", "0.000001"],
["0.0000001", "0.0000001"],
["0.00000001", "0.00000001"],
["0.000000001", "0.000000001"],
["0.0000000001", "0.0000000001"],
["0.00000000001", "0.00000000001"],
["0.000000000001", "0.000000000001"],
["0.0000000000001", "0.0000000000001"],
["0.00000000000001", "0.00000000000001"],
["0.000000000000001", "0.000000000000001"],
["0.0000000000000001", "0.0000000000000001"],
["0.00000000000000001", "0.00000000000000001"],
["0.000000000000000001", "0.000000000000000001"],
["0.100000000000000000", "0.1"],
["0.010000000000000000", "0.01"],
["0.001000000000000000", "0.001"],
["0.000100000000000000", "0.0001"],
["0.000010000000000000", "0.00001"],
["0.000001000000000000", "0.000001"],
["0.000000100000000000", "0.0000001"],
["0.000000010000000000", "0.00000001"],
["0.000000001000000000", "0.000000001"],
["0.000000000100000000", "0.0000000001"],
["0.000000000010000000", "0.00000000001"],
["0.000000000001000000", "0.000000000001"],
["0.000000000000100000", "0.0000000000001"],
["0.000000000000010000", "0.00000000000001"],
["0.000000000000001000", "0.000000000000001"],
["0.000000000000000100", "0.0000000000000001"],
["0.000000000000000010", "0.00000000000000001"],
["0.000000000000000001", "0.000000000000000001"],
["-10.0", "-10"],
["-10000", "-10'000"],
["-9999", "-9'999"],
["-999999999999", "-999'999'999'999"]
]