MCPcopy Create free account
hub / github.com/dinedal/textql / TestBuildNumeric

Function TestBuildNumeric

sqlparser/sqltypes/type_test.go:82–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80)
81
82func TestBuildNumeric(t *testing.T) {
83 var n Value
84 var err error
85 n, err = BuildNumeric(MINNEG)
86 if err != nil {
87 t.Errorf("Unexpected error: %s", err)
88 }
89 if n.String() != MINNEG {
90 t.Errorf("Expecting %v, received %s", MINNEG, n.Raw())
91 }
92 n, err = BuildNumeric(MAXPOS)
93 if err != nil {
94 t.Errorf("Unexpected error: %s", err)
95 }
96 if n.String() != MAXPOS {
97 t.Errorf("Expecting %v, received %s", MAXPOS, n.Raw())
98 }
99 n, err = BuildNumeric("0xA")
100 if err != nil {
101 t.Errorf("Unexpected error: %s", err)
102 }
103 if n.String() != "10" {
104 t.Errorf("Expecting %v, received %s", 10, n.Raw())
105 }
106 n, err = BuildNumeric("012")
107 if err != nil {
108 t.Errorf("Unexpected error: %s", err)
109 }
110 if string(n.Raw()) != "10" {
111 t.Errorf("Expecting %v, received %s", 10, n.Raw())
112 }
113 if n, err = BuildNumeric(INVALIDNEG); err == nil {
114 t.Errorf("Expecting error")
115 }
116 if n, err = BuildNumeric(INVALIDPOS); err == nil {
117 t.Errorf("Expecting error")
118 }
119 if n, err = BuildNumeric(NEGFLOAT); err == nil {
120 t.Errorf("Expecting error")
121 }
122 if n, err = BuildNumeric(POSFLOAT); err == nil {
123 t.Errorf("Expecting error")
124 }
125}
126
127const (
128 HARDSQL = "\x00'\"\b\n\r\t\x1A\\"

Callers

nothing calls this directly

Calls 3

StringMethod · 0.95
RawMethod · 0.95
BuildNumericFunction · 0.85

Tested by

no test coverage detected