(t *testing.T)
| 1151 | } |
| 1152 | |
| 1153 | func TestEncoderSQLNullStringKeyNullEmpty(t *testing.T) { |
| 1154 | var testCases = []struct { |
| 1155 | name string |
| 1156 | baseJSON string |
| 1157 | expectedJSON string |
| 1158 | }{ |
| 1159 | { |
| 1160 | name: "basic 1st elem", |
| 1161 | baseJSON: "{", |
| 1162 | expectedJSON: `{"foo":null,"bar":"bar"`, |
| 1163 | }, |
| 1164 | { |
| 1165 | name: "basic 2nd elem", |
| 1166 | baseJSON: `{"test":"test"`, |
| 1167 | expectedJSON: `{"test":"test","foo":null,"bar":"bar"`, |
| 1168 | }, |
| 1169 | } |
| 1170 | for _, testCase := range testCases { |
| 1171 | t.Run(testCase.name, func(t *testing.T) { |
| 1172 | var b strings.Builder |
| 1173 | var enc = NewEncoder(&b) |
| 1174 | enc.writeString(testCase.baseJSON) |
| 1175 | enc.SQLNullStringKeyNullEmpty("foo", &sql.NullString{"", true}) |
| 1176 | enc.SQLNullStringKeyNullEmpty("bar", &sql.NullString{"bar", true}) |
| 1177 | enc.Write() |
| 1178 | assert.Equal(t, testCase.expectedJSON, b.String()) |
| 1179 | }) |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | func TestEncoderSQLNullBoolEmpty(t *testing.T) { |
| 1184 | var testCases = []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…