MCPcopy Create free account
hub / github.com/araddon/qlbridge / TestNumberParse

Function TestNumberParse

expr/parse_test.go:67–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestNumberParse(t *testing.T) {
68 t.Parallel()
69 for _, test := range numberTests {
70 n, err := expr.NewNumberStr(test.text)
71 ok := test.isInt || test.isFloat
72 if ok && err != nil {
73 t.Errorf("unexpected error for %q: %s", test.text, err)
74 continue
75 }
76 if !ok && err == nil {
77 t.Errorf("expected error for %q", test.text)
78 continue
79 }
80 if !ok {
81 if *VerboseTests {
82 u.Debugf("%s\n\t%s", test.text, err)
83 }
84 continue
85 }
86 if test.isInt && !n.IsInt {
87 t.Errorf("did not expect unsigned integer for %q", test.text)
88 }
89 if test.isFloat {
90 if !n.IsFloat {
91 t.Errorf("expected float for %q", test.text)
92 }
93 if n.Float64 != test.float64 {
94 t.Errorf("float64 for %q should be %g Is %g", test.text, test.float64, n.Float64)
95 }
96 } else if n.IsFloat {
97 t.Errorf("did not expect float for %q", test.text)
98 }
99 }
100}
101
102type exprTest struct {
103 qlText string

Callers

nothing calls this directly

Calls 2

NewNumberStrFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected