Skip to content

Commit 922b301

Browse files
author
Gleb Brozhe
committed
added test for the specific scenario from the PR
1 parent afdd3e8 commit 922b301

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

internal/decimal/decimal_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,35 @@ func uint128(hi, lo uint64) []byte {
246246
func uint128s(lo uint64) []byte {
247247
return uint128(0, lo)
248248
}
249+
func TestParse(t *testing.T) {
250+
251+
tests := []struct {
252+
name string
253+
s string
254+
precision uint32
255+
scale uint32
256+
}{
257+
{
258+
name: "Specific Parse test",
259+
s: "100",
260+
precision: 0,
261+
scale: 0,
262+
},
263+
}
264+
265+
for _, tt := range tests {
266+
t.Run(tt.name, func(t *testing.T) {
267+
expectedRes, expectedErr := oldParse(tt.s, tt.precision, tt.scale)
268+
res, err := Parse(tt.s, tt.precision, tt.scale)
269+
if expectedErr == nil {
270+
require.Equal(t, expectedRes, res)
271+
} else {
272+
require.Error(t, err)
273+
}
274+
})
275+
}
276+
277+
}
249278

250279
func FuzzParse(f *testing.F) {
251280
f.Fuzz(func(t *testing.T, s string, precision, scale uint32) {

0 commit comments

Comments
 (0)