From 1ea3590fd608dbe0feaed7ef60c9ff0fc487d549 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Fri, 25 Feb 2022 15:32:32 +0000 Subject: [PATCH] Add tests with negative numbers --- postgres/numeric/numeric_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/postgres/numeric/numeric_test.go b/postgres/numeric/numeric_test.go index 9e89a38..061ff9b 100644 --- a/postgres/numeric/numeric_test.go +++ b/postgres/numeric/numeric_test.go @@ -25,6 +25,14 @@ func TestMarshalJSON(t *testing.T) { {numeric.MustParse("0.01"), "0.01"}, {numeric.MustParse("0.001"), "0.001"}, {numeric.MustParse("0.0001"), "0.0001"}, + {numeric.MustParse("-1"), "-1"}, + {numeric.MustParse("-10"), "-10"}, + {numeric.MustParse("-100"), "-100"}, + {numeric.MustParse("-1000"), "-1000"}, + {numeric.MustParse("-0.1"), "-0.1"}, + {numeric.MustParse("-0.01"), "-0.01"}, + {numeric.MustParse("-0.001"), "-0.001"}, + {numeric.MustParse("-0.0001"), "-0.0001"}, {numeric.MustParse("123456789.12345"), "123456789.12345"}, {numeric.MustParse("123456789.12345"), "123456789.12345"}, {numeric.MustParse("-1.23"), "-1.23"}, @@ -67,6 +75,14 @@ func TestParse(t *testing.T) { {numeric.FromInt64WithExp(1, -2), `0.01`}, {numeric.FromInt64WithExp(1, -3), `0.001`}, {numeric.FromInt64WithExp(1, -4), `0.0001`}, + {numeric.FromInt64WithExp(-1, 0), `-1`}, + {numeric.FromInt64WithExp(-1, 1), `-10`}, + {numeric.FromInt64WithExp(-1, 2), `-100`}, + {numeric.FromInt64WithExp(-1, 3), `-1000`}, + {numeric.FromInt64WithExp(-1, -1), `-0.1`}, + {numeric.FromInt64WithExp(-1, -2), `-0.01`}, + {numeric.FromInt64WithExp(-1, -3), `-0.001`}, + {numeric.FromInt64WithExp(-1, -4), `-0.0001`}, {numeric.FromInt64WithExp(123, -2), "1.23"}, {numeric.FromInt64WithExp(124, -2), "1,24"}, {numeric.FromInt64WithExp(12345678912345, -5), "123456789.12345"},