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

Function TestEncoderObjectNullEmpty

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

Source from the content-addressed store, hash-verified

460}
461
462func TestEncoderObjectNullEmpty(t *testing.T) {
463 var testCases = []struct {
464 name string
465 baseJSON string
466 expectedJSON string
467 }{
468 {
469 name: "basic 1st elem",
470 baseJSON: "[",
471 expectedJSON: `[null,{"test":"","test2":"","testInt":0,"testBool":false,"testArr":[],"testF64":0,"testF32":0,"sub":{}}`,
472 },
473 {
474 name: "basic 2nd elem",
475 baseJSON: `["test"`,
476 expectedJSON: `["test",null,{"test":"","test2":"","testInt":0,"testBool":false,"testArr":[],"testF64":0,"testF32":0,"sub":{}}`,
477 },
478 }
479 for _, testCase := range testCases {
480 t.Run(testCase.name, func(t *testing.T) {
481 var b strings.Builder
482 var enc = NewEncoder(&b)
483 enc.writeString(testCase.baseJSON)
484 enc.AddObjectNullEmpty((*TestEncoding)(nil))
485 enc.ObjectNullEmpty(&TestEncoding{})
486 enc.Write()
487 assert.Equal(t, testCase.expectedJSON, b.String())
488 })
489 }
490}
491
492type ObjectWithKeys struct {
493 Str string

Callers

nothing calls this directly

Calls 6

NewEncoderFunction · 0.85
writeStringMethod · 0.80
AddObjectNullEmptyMethod · 0.80
ObjectNullEmptyMethod · 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…