From a10ada1ae1ca463b79572dd37edf9f16f71035e0 Mon Sep 17 00:00:00 2001 From: Denver Date: Thu, 12 Jan 2023 15:41:47 +0900 Subject: [PATCH] test: Added test cases for precisionMultiplier (#14576) Co-authored-by: Hyunwoo Lee Co-authored-by: Aleksandr Bezobchuk --- math/dec_internal_test.go | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/math/dec_internal_test.go b/math/dec_internal_test.go index 248bd4bc45..0680cf0094 100644 --- a/math/dec_internal_test.go +++ b/math/dec_internal_test.go @@ -17,9 +17,35 @@ func TestDecimalInternalTestSuite(t *testing.T) { } func (s *decimalInternalTestSuite) TestPrecisionMultiplier() { - res := precisionMultiplier(5) - exp := big.NewInt(10000000000000) - s.Require().Equal(0, res.Cmp(exp), "equality was incorrect, res %v, exp %v", res, exp) + tests := []struct { + prec int64 + exp *big.Int + }{ + { + 5, + big.NewInt(10000000000000), + }, + { + 8, + big.NewInt(10000000000), + }, + { + 11, + big.NewInt(10000000), + }, + { + 15, + big.NewInt(1000), + }, + { + 18, + big.NewInt(1), + }, + } + for _, tt := range tests { + res := precisionMultiplier(tt.prec) + s.Require().Equal(0, res.Cmp(tt.exp), "equality was incorrect, res %v, exp %v", res, tt.exp) + } } func (s *decimalInternalTestSuite) TestZeroDeserializationJSON() {