From 344d7d5c42a11edd121fea99da4ba2d0bd61d663 Mon Sep 17 00:00:00 2001 From: Brenton Farmer Date: Fri, 14 Jun 2024 08:08:56 -0700 Subject: [PATCH] Add test for filter without surrounding parenthesis --- .../Tokenizer/JsonPathQueryTokenizerTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/Hyperbee.Json.Tests/Tokenizer/JsonPathQueryTokenizerTests.cs b/test/Hyperbee.Json.Tests/Tokenizer/JsonPathQueryTokenizerTests.cs index 13a17873..4569000d 100644 --- a/test/Hyperbee.Json.Tests/Tokenizer/JsonPathQueryTokenizerTests.cs +++ b/test/Hyperbee.Json.Tests/Tokenizer/JsonPathQueryTokenizerTests.cs @@ -24,7 +24,9 @@ public class JsonPathQueryTokenizerTests [DataRow( "$.store.book[0,1]", "{$|k};{store|k};{book|k};{1,0|s}" )] [DataRow( "$..book['category','author']", "{$|k};{..|s};{book|k};{author,category|s}" )] [DataRow( "$..book[?(@.isbn)]", "{$|k};{..|s};{book|k};{?(@.isbn)|s}" )] + [DataRow( "$..book[?@.isbn]", "{$|k};{..|s};{book|k};{?@.isbn|s}" )] [DataRow( "$..book[?(@.price<10)]", "{$|k};{..|s};{book|k};{?(@.price<10)|s}" )] + [DataRow( "$..book[?@.price<10]", "{$|k};{..|s};{book|k};{?@.price<10|s}" )] [DataRow( "$..*", "{$|k};{..|s};{*|s}" )] [DataRow( """$.store.book[?(@path !== "$['store']['book'][0]")]""", """{$|k};{store|k};{book|k};{?(@path !== "$['store']['book'][0]")|s}""" )] [DataRow( """$..book[?(@.price == 8.99 && @.category == "fiction")]""", """{$|k};{..|s};{book|k};{?(@.price == 8.99 && @.category == "fiction")|s}""" )] @@ -33,6 +35,8 @@ public void Should_tokenize_json_path( string jsonPath, string expected ) // arrange static string TokensToString( JsonPathSegment segment ) { + return string.Join( ';', segment.AsEnumerable().Select( TokenToString ) ); + static string TokenToString( JsonPathSegment segment ) { var (keySelector, selectors) = segment; @@ -41,8 +45,6 @@ static string TokenToString( JsonPathSegment segment ) return $"{{{selectorsString}|{selectorType}}}"; } - - return string.Join( ';', segment.AsEnumerable().Select( TokenToString ) ); } // act