(t *testing.T)
| 106 | } |
| 107 | |
| 108 | func TestDecodeSQLNullFloat64(t *testing.T) { |
| 109 | testCases := []struct { |
| 110 | name string |
| 111 | json string |
| 112 | expectedNullFloat64 sql.NullFloat64 |
| 113 | err bool |
| 114 | }{ |
| 115 | { |
| 116 | name: "basic", |
| 117 | json: `1`, |
| 118 | expectedNullFloat64: sql.NullFloat64{Float64: 1, Valid: true}, |
| 119 | }, |
| 120 | { |
| 121 | name: "basic", |
| 122 | json: `"test`, |
| 123 | expectedNullFloat64: sql.NullFloat64{Float64: 1, Valid: true}, |
| 124 | err: true, |
| 125 | }, |
| 126 | } |
| 127 | for _, testCase := range testCases { |
| 128 | t.Run(testCase.name, func(t *testing.T) { |
| 129 | nullFloat64 := sql.NullFloat64{} |
| 130 | dec := NewDecoder(strings.NewReader(testCase.json)) |
| 131 | err := dec.DecodeSQLNullFloat64(&nullFloat64) |
| 132 | if testCase.err { |
| 133 | assert.NotNil(t, err) |
| 134 | } else { |
| 135 | assert.Nil(t, err) |
| 136 | assert.Equal(t, testCase.expectedNullFloat64, nullFloat64) |
| 137 | } |
| 138 | }) |
| 139 | } |
| 140 | t.Run( |
| 141 | "should panic because decoder is pooled", |
| 142 | func(t *testing.T) { |
| 143 | dec := NewDecoder(nil) |
| 144 | dec.Release() |
| 145 | defer func() { |
| 146 | err := recover() |
| 147 | assert.NotNil(t, err, "err shouldnt be nil") |
| 148 | assert.IsType(t, InvalidUsagePooledDecoderError(""), err, "err should be of type InvalidUsagePooledDecoderError") |
| 149 | }() |
| 150 | _ = dec.DecodeSQLNullFloat64(&sql.NullFloat64{}) |
| 151 | assert.True(t, false, "should not be called as decoder should have panicked") |
| 152 | }, |
| 153 | ) |
| 154 | } |
| 155 | |
| 156 | func TestDecodeSQLNullBool(t *testing.T) { |
| 157 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…