(t *testing.T)
| 458 | } |
| 459 | |
| 460 | func TestAddSQLNullInt64(t *testing.T) { |
| 461 | t.Run( |
| 462 | "AddSQLNullInt64", |
| 463 | func(t *testing.T) { |
| 464 | testCases := []struct { |
| 465 | name string |
| 466 | sqlNullInt64 sql.NullInt64 |
| 467 | baseJSON string |
| 468 | expectedResult string |
| 469 | err bool |
| 470 | }{ |
| 471 | { |
| 472 | name: "it should encode a null string", |
| 473 | sqlNullInt64: sql.NullInt64{ |
| 474 | Int64: 1, |
| 475 | }, |
| 476 | baseJSON: "[", |
| 477 | expectedResult: `[1`, |
| 478 | }, |
| 479 | { |
| 480 | name: "it should encode a null string", |
| 481 | sqlNullInt64: sql.NullInt64{ |
| 482 | Int64: 2, |
| 483 | }, |
| 484 | baseJSON: "[", |
| 485 | expectedResult: `[2`, |
| 486 | }, |
| 487 | { |
| 488 | name: "it should encode a null string", |
| 489 | sqlNullInt64: sql.NullInt64{ |
| 490 | Int64: 2, |
| 491 | }, |
| 492 | baseJSON: "[", |
| 493 | expectedResult: `[2`, |
| 494 | }, |
| 495 | } |
| 496 | |
| 497 | for _, testCase := range testCases { |
| 498 | t.Run(testCase.name, func(t *testing.T) { |
| 499 | var b strings.Builder |
| 500 | enc := NewEncoder(&b) |
| 501 | enc.writeString(testCase.baseJSON) |
| 502 | enc.AddSQLNullInt64(&testCase.sqlNullInt64) |
| 503 | enc.Write() |
| 504 | assert.Equal(t, testCase.expectedResult, b.String()) |
| 505 | |
| 506 | var b2 strings.Builder |
| 507 | enc = NewEncoder(&b2) |
| 508 | enc.writeString(testCase.baseJSON) |
| 509 | enc.SQLNullInt64(&testCase.sqlNullInt64) |
| 510 | enc.Write() |
| 511 | assert.Equal(t, testCase.expectedResult, b2.String()) |
| 512 | }) |
| 513 | } |
| 514 | }, |
| 515 | ) |
| 516 | t.Run( |
| 517 | "AddSQLNullInt64KeyOmitEmpty, is should encode a sql.NullInt64", |
nothing calls this directly
no test coverage detected
searching dependent graphs…