(t *testing.T)
| 430 | } |
| 431 | |
| 432 | func 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 | |
| 462 | func TestEncoderObjectNullEmpty(t *testing.T) { |
| 463 | var testCases = []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…