From 7ef4fb6ee42c96964c298a80f9301ce30a025099 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Mon, 9 Sep 2024 12:59:17 -0700 Subject: [PATCH] Clean up. --- lib/typing/values/string_test.go | 55 +++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/lib/typing/values/string_test.go b/lib/typing/values/string_test.go index 2b6484f24..434a6b26c 100644 --- a/lib/typing/values/string_test.go +++ b/lib/typing/values/string_test.go @@ -107,24 +107,41 @@ func TestToString(t *testing.T) { } { // Extended Decimal - // Floats - val, err := ToString(float32(123.45), typing.EDecimal) - assert.NoError(t, err) - assert.Equal(t, "123.45", val) - - val, err = ToString(123.45, typing.EDecimal) - assert.NoError(t, err) - assert.Equal(t, "123.45", val) - - // String - val, err = ToString("123.45", typing.EDecimal) - assert.NoError(t, err) - assert.Equal(t, "123.45", val) - - // Decimals - value := decimal.NewDecimalWithPrecision(numbers.MustParseDecimal("585692791691858.25"), 38) - val, err = ToString(value, typing.EDecimal) - assert.NoError(t, err) - assert.Equal(t, "585692791691858.25", val) + { + // Float32 + val, err := ToString(float32(123.45), typing.EDecimal) + assert.NoError(t, err) + assert.Equal(t, "123.45", val) + } + { + // Float64 + val, err := ToString(123.45, typing.EDecimal) + assert.NoError(t, err) + assert.Equal(t, "123.45", val) + } + { + // String + val, err := ToString("123.45", typing.EDecimal) + assert.NoError(t, err) + assert.Equal(t, "123.45", val) + } + { + // Decimal + val, err := ToString(decimal.NewDecimalWithPrecision(numbers.MustParseDecimal("585692791691858.25"), 38), typing.EDecimal) + assert.NoError(t, err) + assert.Equal(t, "585692791691858.25", val) + } + { + // Int32 + val, err := ToString(int32(123), typing.EDecimal) + assert.NoError(t, err) + assert.Equal(t, "123", val) + } + { + // Int64 + val, err := ToString(int64(123), typing.EDecimal) + assert.NoError(t, err) + assert.Equal(t, "123", val) + } } }