(t *testing.T)
| 169 | } |
| 170 | |
| 171 | func TestDecodeInterfaceAsInterface(t *testing.T) { |
| 172 | testCases := []struct { |
| 173 | name string |
| 174 | json string |
| 175 | expectedResult interface{} |
| 176 | err bool |
| 177 | errType interface{} |
| 178 | skipCheckResult bool |
| 179 | }{ |
| 180 | { |
| 181 | name: "basic-array", |
| 182 | json: `{ |
| 183 | "testStr": "hola", |
| 184 | "testInterface": ["h","o","l","a"] |
| 185 | }`, |
| 186 | expectedResult: map[string]interface{}( |
| 187 | map[string]interface{}{ |
| 188 | "testStr": "hola", |
| 189 | "testInterface": []interface{}{"h", "o", "l", "a"}, |
| 190 | }), |
| 191 | err: false, |
| 192 | }, |
| 193 | { |
| 194 | name: "basic-string", |
| 195 | json: `{ |
| 196 | "testInterface": "漢字" |
| 197 | }`, |
| 198 | expectedResult: map[string]interface{}( |
| 199 | map[string]interface{}{ |
| 200 | "testInterface": "漢字", |
| 201 | }), |
| 202 | err: false, |
| 203 | }, |
| 204 | { |
| 205 | name: "basic-error", |
| 206 | json: `{ |
| 207 | "testInterface": ["a""d","i","o","s"] |
| 208 | }`, |
| 209 | err: true, |
| 210 | errType: &json.SyntaxError{}, |
| 211 | skipCheckResult: true, |
| 212 | }, |
| 213 | { |
| 214 | name: "basic-interface", |
| 215 | json: `{ |
| 216 | "testInterface": { |
| 217 | "string": "prost" |
| 218 | } |
| 219 | }`, |
| 220 | expectedResult: map[string]interface{}( |
| 221 | map[string]interface{}{ |
| 222 | "testInterface": map[string]interface{}{"string": "prost"}, |
| 223 | }), |
| 224 | err: false, |
| 225 | }, |
| 226 | { |
| 227 | name: "complex-interface", |
| 228 | json: `{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…