MCPcopy Create free account
hub / github.com/francoispqt/gojay / TestEncoderSQLNullStringKeyNullEmpty

Function TestEncoderSQLNullStringKeyNullEmpty

encode_sqlnull_test.go:1153–1181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1151}
1152
1153func TestEncoderSQLNullStringKeyNullEmpty(t *testing.T) {
1154 var testCases = []struct {
1155 name string
1156 baseJSON string
1157 expectedJSON string
1158 }{
1159 {
1160 name: "basic 1st elem",
1161 baseJSON: "{",
1162 expectedJSON: `{"foo":null,"bar":"bar"`,
1163 },
1164 {
1165 name: "basic 2nd elem",
1166 baseJSON: `{"test":"test"`,
1167 expectedJSON: `{"test":"test","foo":null,"bar":"bar"`,
1168 },
1169 }
1170 for _, testCase := range testCases {
1171 t.Run(testCase.name, func(t *testing.T) {
1172 var b strings.Builder
1173 var enc = NewEncoder(&b)
1174 enc.writeString(testCase.baseJSON)
1175 enc.SQLNullStringKeyNullEmpty("foo", &sql.NullString{"", true})
1176 enc.SQLNullStringKeyNullEmpty("bar", &sql.NullString{"bar", true})
1177 enc.Write()
1178 assert.Equal(t, testCase.expectedJSON, b.String())
1179 })
1180 }
1181}
1182
1183func TestEncoderSQLNullBoolEmpty(t *testing.T) {
1184 var testCases = []struct {

Callers

nothing calls this directly

Calls 5

NewEncoderFunction · 0.85
writeStringMethod · 0.80
WriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…