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

Function TestEncoderSQLNullStringEmpty

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

Source from the content-addressed store, hash-verified

1121}
1122
1123func TestEncoderSQLNullStringEmpty(t *testing.T) {
1124 var testCases = []struct {
1125 name string
1126 baseJSON string
1127 expectedJSON string
1128 }{
1129 {
1130 name: "basic 1st elem",
1131 baseJSON: "[",
1132 expectedJSON: `[null,"bar"`,
1133 },
1134 {
1135 name: "basic 2nd elem",
1136 baseJSON: `["test"`,
1137 expectedJSON: `["test",null,"bar"`,
1138 },
1139 }
1140 for _, testCase := range testCases {
1141 t.Run(testCase.name, func(t *testing.T) {
1142 var b strings.Builder
1143 var enc = NewEncoder(&b)
1144 enc.writeString(testCase.baseJSON)
1145 enc.AddSQLNullStringNullEmpty(&sql.NullString{"", true})
1146 enc.SQLNullStringNullEmpty(&sql.NullString{"bar", true})
1147 enc.Write()
1148 assert.Equal(t, testCase.expectedJSON, b.String())
1149 })
1150 }
1151}
1152
1153func TestEncoderSQLNullStringKeyNullEmpty(t *testing.T) {
1154 var testCases = []struct {

Callers

nothing calls this directly

Calls 6

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…