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

Function TestAddSQLNullFloat64Key

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

Source from the content-addressed store, hash-verified

629}
630
631func TestAddSQLNullFloat64Key(t *testing.T) {
632 t.Run(
633 "AddSQLNullFloat64Key",
634 func(t *testing.T) {
635 testCases := []struct {
636 name string
637 sqlNullFloat64 sql.NullFloat64
638 baseJSON string
639 expectedResult string
640 err bool
641 }{
642 {
643 name: "it should encode a null string",
644 sqlNullFloat64: sql.NullFloat64{
645 Float64: 1,
646 },
647 baseJSON: "{",
648 expectedResult: `{"foo":1`,
649 },
650 {
651 name: "it should encode a null string",
652 sqlNullFloat64: sql.NullFloat64{
653 Float64: 2,
654 },
655 baseJSON: "{",
656 expectedResult: `{"foo":2`,
657 },
658 {
659 name: "it should encode a null string",
660 sqlNullFloat64: sql.NullFloat64{
661 Float64: 2,
662 },
663 baseJSON: "{",
664 expectedResult: `{"foo":2`,
665 },
666 }
667
668 for _, testCase := range testCases {
669 t.Run(testCase.name, func(t *testing.T) {
670 var b strings.Builder
671 enc := NewEncoder(&b)
672 enc.writeString(testCase.baseJSON)
673 enc.AddSQLNullFloat64Key("foo", &testCase.sqlNullFloat64)
674 enc.Write()
675 assert.Equal(t, testCase.expectedResult, b.String())
676
677 var b2 strings.Builder
678 enc = NewEncoder(&b2)
679 enc.writeString(testCase.baseJSON)
680 enc.SQLNullFloat64Key("foo", &testCase.sqlNullFloat64)
681 enc.Write()
682 assert.Equal(t, testCase.expectedResult, b2.String())
683 })
684 }
685 },
686 )
687 t.Run(
688 "AddSQLNullFloat64KeyOmitEmpty, is should encode a sql.NullFloat64",

Callers

nothing calls this directly

Calls 8

writeStringMethod · 0.95
AddSQLNullFloat64KeyMethod · 0.95
WriteMethod · 0.95
SQLNullFloat64KeyMethod · 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…