MCPcopy Index your code
hub / github.com/dropbox/godropbox / TestBuildNumeric

Function TestBuildNumeric

database/sqltypes/sqltypes_test.go:78–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

76)
77
78func TestBuildNumeric(t *testing.T) {
79 var n Value
80 var err error
81 n, err = BuildNumeric(MINNEG)
82 if err != nil {
83 t.Errorf("Unexpected error: %s", err)
84 }
85 if n.String() != MINNEG {
86 t.Errorf("Expecting %v, received %s", MINNEG, n.Raw())
87 }
88 n, err = BuildNumeric(MAXPOS)
89 if err != nil {
90 t.Errorf("Unexpected error: %s", err)
91 }
92 if n.String() != MAXPOS {
93 t.Errorf("Expecting %v, received %s", MAXPOS, n.Raw())
94 }
95 n, err = BuildNumeric("0xA")
96 if err != nil {
97 t.Errorf("Unexpected error: %s", err)
98 }
99 if n.String() != "10" {
100 t.Errorf("Expecting %v, received %s", 10, n.Raw())
101 }
102 n, err = BuildNumeric("012")
103 if err != nil {
104 t.Errorf("Unexpected error: %s", err)
105 }
106 if string(n.Raw()) != "10" {
107 t.Errorf("Expecting %v, received %s", 10, n.Raw())
108 }
109 if n, err = BuildNumeric(INVALIDNEG); err == nil {
110 t.Errorf("Expecting error")
111 }
112 if n, err = BuildNumeric(INVALIDPOS); err == nil {
113 t.Errorf("Expecting error")
114 }
115 if n, err = BuildNumeric(NEGFLOAT); err == nil {
116 t.Errorf("Expecting error")
117 }
118 if n, err = BuildNumeric(POSFLOAT); err == nil {
119 t.Errorf("Expecting error")
120 }
121}
122
123const (
124 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