Extract package for Numeric datatype and add unittests #18

Merged
jacob1123 merged 8 commits from numeric-package into master 2022-02-23 23:13:18 +01:00
Showing only changes of commit f445f19233 - Show all commits

View File

@ -42,13 +42,13 @@ type TestCaseParse struct {
func TestParse(t *testing.T) { func TestParse(t *testing.T) {
tests := []TestCaseParse{ tests := []TestCaseParse{
{numeric.Zero(), `0`}, {numeric.FromInt64WithExp(0, 0), `0`},
{numeric.FromInt64(1), `1`}, {numeric.FromInt64WithExp(1, 0), `1`},
{numeric.FromInt64WithExp(1, 1), `10`}, {numeric.FromInt64WithExp(1, 1), `10`},
{numeric.FromInt64WithExp(1, 2), `100`}, {numeric.FromInt64WithExp(1, 2), `100`},
{numeric.MustParse("1.23"), "1.23"}, {numeric.FromInt64WithExp(123, -2), "1.23"},
{numeric.MustParse("1,24"), "1.24"}, {numeric.FromInt64WithExp(124, -2), "1,24"},
{numeric.MustParse("123456789.12345"), "123456789.12345"}, {numeric.FromInt64WithExp(12345678912345, -5), "123456789.12345"},
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.Value, func(t *testing.T) { t.Run(test.Value, func(t *testing.T) {
@ -67,9 +67,6 @@ func TestParse(t *testing.T) {
t.Errorf("Expected exp %d, got %d", test.Result.Exp, result.Exp) t.Errorf("Expected exp %d, got %d", test.Result.Exp, result.Exp)
return return
} }
// if string(result) != test.Result {
// return
//}
}) })
} }
} }