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

Function TestAddSQLNullInt64

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

Source from the content-addressed store, hash-verified

458}
459
460func 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",

Callers

nothing calls this directly

Calls 8

writeStringMethod · 0.95
AddSQLNullInt64Method · 0.95
WriteMethod · 0.95
SQLNullInt64Method · 0.95
SQLNullInt64OmitEmptyMethod · 0.95
NewEncoderFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…