From 0ddbb762bf17d25e6416f0b2fc0ca7e3e4110682 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Thu, 16 May 2024 15:50:43 +1200 Subject: [PATCH] add quote escape tests for filter expressions (#78) --- tests/filter.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/filter.json b/tests/filter.json index 09fa32c..4b7f5fe 100644 --- a/tests/filter.json +++ b/tests/filter.json @@ -932,6 +932,30 @@ "selector" : "$[?(@.a || @.b) && @.b]", "document" : [{"a": 1}], "result": [] + }, + { + "name": "string literal, single quote in double quotes", + "selector" : "$[?@ == \"quoted' literal\"]", + "document" : ["quoted' literal", "a", "quoted\\' literal"], + "result": ["quoted' literal"] + }, + { + "name": "string literal, double quote in single quotes", + "selector" : "$[?@ == 'quoted\" literal']", + "document" : ["quoted\" literal", "a", "quoted\\\" literal", "'quoted\" literal'"], + "result": ["quoted\" literal"] + }, + { + "name": "string literal, escaped single quote in single quotes", + "selector" : "$[?@ == 'quoted\\' literal']", + "document" : ["quoted' literal", "a", "quoted\\' literal", "'quoted\" literal'"], + "result": ["quoted' literal"] + }, + { + "name": "string literal, escaped double quote in double quotes", + "selector" : "$[?@ == \"quoted\\\" literal\"]", + "document" : ["quoted\" literal", "a", "quoted\\\" literal", "'quoted\" literal'"], + "result": ["quoted\" literal"] } ] }