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

Function TestEncoderStringNullKeyEmpty

encode_string_test.go:225–253  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

223}
224
225func TestEncoderStringNullKeyEmpty(t *testing.T) {
226 var testCases = []struct {
227 name string
228 baseJSON string
229 expectedJSON string
230 }{
231 {
232 name: "basic 1st elem",
233 baseJSON: "{",
234 expectedJSON: `{"foo":null,"bar":"true"`,
235 },
236 {
237 name: "basic 2nd elem",
238 baseJSON: `{"test":"test"`,
239 expectedJSON: `{"test":"test","foo":null,"bar":"true"`,
240 },
241 }
242 for _, testCase := range testCases {
243 t.Run("true", func(t *testing.T) {
244 var b strings.Builder
245 var enc = NewEncoder(&b)
246 enc.writeString(testCase.baseJSON)
247 enc.StringKeyNullEmpty("foo", "")
248 enc.AddStringKeyNullEmpty("bar", "true")
249 enc.Write()
250 assert.Equal(t, testCase.expectedJSON, b.String())
251 })
252 }
253}

Callers

nothing calls this directly

Calls 6

NewEncoderFunction · 0.85
writeStringMethod · 0.80
StringKeyNullEmptyMethod · 0.80
AddStringKeyNullEmptyMethod · 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…