MCPcopy
hub / github.com/cube2222/octosql / TestBuildValue

Function TestBuildValue

parser/sqlparser/dependency/sqltypes/value_test.go:40–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestBuildValue(t *testing.T) {
41 testcases := []struct {
42 in interface{}
43 out Value
44 }{{
45 in: nil,
46 out: NULL,
47 }, {
48 in: []byte("a"),
49 out: testVal(VarBinary, "a"),
50 }, {
51 in: int64(1),
52 out: testVal(Int64, "1"),
53 }, {
54 in: uint64(1),
55 out: testVal(Uint64, "1"),
56 }, {
57 in: float64(1.2),
58 out: testVal(Float64, "1.2"),
59 }, {
60 in: int(1),
61 out: testVal(Int64, "1"),
62 }, {
63 in: int8(1),
64 out: testVal(Int8, "1"),
65 }, {
66 in: int16(1),
67 out: testVal(Int16, "1"),
68 }, {
69 in: int32(1),
70 out: testVal(Int32, "1"),
71 }, {
72 in: uint(1),
73 out: testVal(Uint64, "1"),
74 }, {
75 in: uint8(1),
76 out: testVal(Uint8, "1"),
77 }, {
78 in: uint16(1),
79 out: testVal(Uint16, "1"),
80 }, {
81 in: uint32(1),
82 out: testVal(Uint32, "1"),
83 }, {
84 in: float32(1),
85 out: testVal(Float32, "1"),
86 }, {
87 in: "a",
88 out: testVal(VarBinary, "a"),
89 }, {
90 in: time.Date(2012, time.February, 24, 23, 19, 43, 10, time.UTC),
91 out: testVal(Datetime, "2012-02-24 23:19:43"),
92 }, {
93 in: testVal(VarBinary, "a"),
94 out: testVal(VarBinary, "a"),
95 }}
96 for _, tcase := range testcases {
97 v, err := BuildValue(tcase.in)

Callers

nothing calls this directly

Calls 4

testValFunction · 0.85
BuildValueFunction · 0.85
makePrettyFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected