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{
158158 isFound : true ,
159159 data : `3` ,
160160 },
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+ },
161175
162176 // Not found key tests
163177 Test {
@@ -254,12 +268,26 @@ var getTests = []Test{
254268 path : []string {"a" },
255269 isErr : true ,
256270 },
257- Test {
271+ Test { // This test returns not found instead of a parse error, as checking for the malformed JSON would reduce performance
258272 desc : "malformed key (followed by comma followed by colon)" ,
259273 json : `{"a",:1}` ,
260274 path : []string {"a" },
261275 isErr : true ,
262276 },
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+ },
263291}
264292
265293var getIntTests = []Test {
You can’t perform that action at this time.
0 commit comments