File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,20 @@ var getTests = []Test{
158
158
isFound : true ,
159
159
data : `3` ,
160
160
},
161
+ Test { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance
162
+ desc : `malformed with trailing whitespace` ,
163
+ json : `{"a":1 ` ,
164
+ path : []string {"a" },
165
+ isFound : true ,
166
+ data : `1` ,
167
+ },
168
+ Test { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance
169
+ desc : `malformed with wrong closing bracket` ,
170
+ json : `{"a":1]` ,
171
+ path : []string {"a" },
172
+ isFound : true ,
173
+ data : `1` ,
174
+ },
161
175
162
176
// Not found key tests
163
177
Test {
@@ -254,12 +268,26 @@ var getTests = []Test{
254
268
path : []string {"a" },
255
269
isErr : true ,
256
270
},
257
- Test {
271
+ Test { // This test returns not found instead of a parse error, as checking for the malformed JSON would reduce performance
258
272
desc : "malformed key (followed by comma followed by colon)" ,
259
273
json : `{"a",:1}` ,
260
274
path : []string {"a" },
261
275
isErr : true ,
262
276
},
277
+ Test { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance (this is not ideal)
278
+ desc : "malformed 'colon chain', lookup first string" ,
279
+ json : `{"a":"b":"c"}` ,
280
+ path : []string {"a" },
281
+ isFound : true ,
282
+ data : "b" ,
283
+ },
284
+ Test { // This test returns a match instead of a parse error, as checking for the malformed JSON would reduce performance (this is not ideal)
285
+ desc : "malformed 'colon chain', lookup second string" ,
286
+ json : `{"a":"b":"c"}` ,
287
+ path : []string {"b" },
288
+ isFound : true ,
289
+ data : "c" ,
290
+ },
263
291
}
264
292
265
293
var getIntTests = []Test {
You can’t perform that action at this time.
0 commit comments