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

Function TestAddSQLNullFloat64

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

Source from the content-addressed store, hash-verified

736}
737
738func TestAddSQLNullFloat64(t *testing.T) {
739 t.Run(
740 "AddSQLNullFloat64",
741 func(t *testing.T) {
742 testCases := []struct {
743 name string
744 sqlNullFloat64 sql.NullFloat64
745 baseJSON string
746 expectedResult string
747 err bool
748 }{
749 {
750 name: "it should encode a null string",
751 sqlNullFloat64: sql.NullFloat64{
752 Float64: 1,
753 },
754 baseJSON: "[",
755 expectedResult: `[1`,
756 },
757 {
758 name: "it should encode a null string",
759 sqlNullFloat64: sql.NullFloat64{
760 Float64: 2,
761 },
762 baseJSON: "[",
763 expectedResult: `[2`,
764 },
765 {
766 name: "it should encode a null string",
767 sqlNullFloat64: sql.NullFloat64{
768 Float64: 2,
769 },
770 baseJSON: "[",
771 expectedResult: `[2`,
772 },
773 }
774
775 for _, testCase := range testCases {
776 t.Run(testCase.name, func(t *testing.T) {
777 var b strings.Builder
778 enc := NewEncoder(&b)
779 enc.writeString(testCase.baseJSON)
780 enc.AddSQLNullFloat64(&testCase.sqlNullFloat64)
781 enc.Write()
782 assert.Equal(t, testCase.expectedResult, b.String())
783
784 var b2 strings.Builder
785 enc = NewEncoder(&b2)
786 enc.writeString(testCase.baseJSON)
787 enc.SQLNullFloat64(&testCase.sqlNullFloat64)
788 enc.Write()
789 assert.Equal(t, testCase.expectedResult, b2.String())
790 })
791 }
792 },
793 )
794 t.Run(
795 "AddSQLNullFloat64KeyOmitEmpty, is should encode a sql.NullFloat64",

Callers

nothing calls this directly

Calls 8

writeStringMethod · 0.95
AddSQLNullFloat64Method · 0.95
WriteMethod · 0.95
SQLNullFloat64Method · 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…