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

Function TestString

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

Source from the content-addressed store, hash-verified

131)
132
133func TestString(t *testing.T) {
134 s := Value{String([]byte(HARDSQL))}
135 b := bytes.NewBuffer(nil)
136 s.EncodeSql(b)
137 if b.String() != HARDESCAPED {
138 t.Errorf("Expecting %s, received %s", HARDESCAPED, b.String())
139 }
140 b = bytes.NewBuffer(nil)
141 s.EncodeAscii(b)
142 if b.String() != HARDASCII {
143 t.Errorf("Expecting %s, received %#v", HARDASCII, b.String())
144 }
145 s = Value{String([]byte("ab\x01cd"))}
146 js, err := s.MarshalJSON()
147 if err != nil {
148 t.Errorf("Unexpected error: %s", err)
149 }
150 if got, want := string(js), "\"ab\\u0001cd\""; got != want {
151 t.Errorf("%#v.MarshalJSON() = %#v, want %#v", s, got, want)
152 }
153}
154
155func TestBuildValue(t *testing.T) {
156 v, err := BuildValue(nil)

Callers

nothing calls this directly

Calls 5

EncodeSqlMethod · 0.95
EncodeAsciiMethod · 0.95
MarshalJSONMethod · 0.95
StringMethod · 0.80
StringTypeAlias · 0.70

Tested by

no test coverage detected