(t *testing.T)
| 460 | } |
| 461 | |
| 462 | func 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 | |
| 492 | type ObjectWithKeys struct { |
| 493 | Str string |
nothing calls this directly
no test coverage detected
searching dependent graphs…