test: Added test cases for precisionMultiplier (#14576)

Co-authored-by: Hyunwoo Lee <denver@Hyunwoos-MacBook-Pro-2.local>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Denver 2023-01-12 15:41:47 +09:00 committed by GitHub
parent 67e71980fd
commit a10ada1ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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() {