File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package types
22
33import (
44 "math/big"
5+ "strconv"
56 "testing"
67
78 "github.com/stretchr/testify/require"
@@ -87,3 +88,32 @@ func TestToDecimal(t *testing.T) {
8788 })
8889 }
8990}
91+
92+ func TestDecimalParse (t * testing.T ) {
93+ for i , tt := range []struct {
94+ raw string
95+ literal string
96+ err bool
97+ }{
98+ {
99+ raw : "-1234567.890123456" ,
100+ literal : `Decimal("-1234567.890123456",22,9)` ,
101+ err : false ,
102+ },
103+ {
104+ raw : "not a decimal" ,
105+ literal : `` ,
106+ err : true ,
107+ },
108+ } {
109+ t .Run (strconv .Itoa (i )+ "." + tt .raw , func (t * testing.T ) {
110+ dec , err := DecimalValueFromString (tt .raw , 22 , 9 )
111+ if err != nil {
112+ require .True (t , tt .err )
113+ require .Nil (t , dec )
114+ } else {
115+ require .Equal (t , tt .literal , dec .Yql ())
116+ }
117+ })
118+ }
119+ }
You can’t perform that action at this time.
0 commit comments