Skip to content

Commit

Permalink
Add test for filter without surrounding parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
bfarmer67 committed Jun 14, 2024
1 parent 8e6230a commit 344d7d5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[[email protected]]", "{$|k};{..|s};{book|k};{[email protected]|s}" )]
[DataRow( "$..book[?(@.price<10)]", "{$|k};{..|s};{book|k};{?(@.price<10)|s}" )]
[DataRow( "$..book[[email protected]<10]", "{$|k};{..|s};{book|k};{[email protected]<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}""" )]
Expand All @@ -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;
Expand All @@ -41,8 +45,6 @@ static string TokenToString( JsonPathSegment segment )

return $"{{{selectorsString}|{selectorType}}}";
}

return string.Join( ';', segment.AsEnumerable().Select( TokenToString ) );
}

// act
Expand Down

0 comments on commit 344d7d5

Please sign in to comment.