feature: implement new regex equals operator for JsonPath Query expression. Example: Blah[?( @.name =~'/hi/i' )]

This commit is contained in:
Minh Nguyen
2017-07-20 18:03:55 +10:00
parent bbbddf0031
commit 865b2076c2
4 changed files with 119 additions and 1 deletions
@@ -314,6 +314,17 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
Assert.AreEqual("h\\i", (string)(JToken)expressions.Right);
}
[Test]
public void SinglePropertyAndFilterWithRegex()
{
JPath path = new JPath("Blah[ ?( @.name=~'/hi/i' ) ]");
Assert.AreEqual(2, path.Filters.Count);
Assert.AreEqual("Blah", ((FieldFilter)path.Filters[0]).Name);
BooleanQueryExpression expressions = (BooleanQueryExpression)((QueryFilter)path.Filters[1]).Expression;
Assert.AreEqual(QueryOperator.RegExEquals, expressions.Operator);
Assert.AreEqual("/hi/i", (string)(JToken)expressions.Right);
}
[Test]
public void SinglePropertyAndFilterWithUnknownEscape()
{