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

Function TestEncoderObjectKeyNullEmpty

encode_object_test.go:432–460  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

430}
431
432func TestEncoderObjectKeyNullEmpty(t *testing.T) {
433 var testCases = []struct {
434 name string
435 baseJSON string
436 expectedJSON string
437 }{
438 {
439 name: "basic 1st elem",
440 baseJSON: "{",
441 expectedJSON: `{"foo":null,"bar":{"test":"","test2":"","testInt":0,"testBool":false,"testArr":[],"testF64":0,"testF32":0,"sub":{}}`,
442 },
443 {
444 name: "basic 2nd elem",
445 baseJSON: `{"test":"test"`,
446 expectedJSON: `{"test":"test","foo":null,"bar":{"test":"","test2":"","testInt":0,"testBool":false,"testArr":[],"testF64":0,"testF32":0,"sub":{}}`,
447 },
448 }
449 for _, testCase := range testCases {
450 t.Run(testCase.name, func(t *testing.T) {
451 var b strings.Builder
452 var enc = NewEncoder(&b)
453 enc.writeString(testCase.baseJSON)
454 enc.AddObjectKeyNullEmpty("foo", (*TestEncoding)(nil))
455 enc.ObjectKeyNullEmpty("bar", &TestEncoding{})
456 enc.Write()
457 assert.Equal(t, testCase.expectedJSON, b.String())
458 })
459 }
460}
461
462func TestEncoderObjectNullEmpty(t *testing.T) {
463 var testCases = []struct {

Callers

nothing calls this directly

Calls 6

NewEncoderFunction · 0.85
writeStringMethod · 0.80
AddObjectKeyNullEmptyMethod · 0.80
ObjectKeyNullEmptyMethod · 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…