-Additional JSONPath NotEquals fix

This commit is contained in:
James Newton-King
2016-03-23 21:22:17 +13:00
parent 5b06e9e97f
commit 029e36e7e4
2 changed files with 14 additions and 8 deletions
@@ -904,7 +904,7 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
}
[Test]
public void NotEqualsNullAndNonPrimativeValues()
public void NotEqualsAndNonPrimativeValues()
{
string json = @"[
{
@@ -934,9 +934,18 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
JArray a = JArray.Parse(json);
List<JToken> result = a.SelectTokens("$.[?(@.value!=null)]").ToList();
List<JToken> result = a.SelectTokens("$.[?(@.value!=1)]").ToList();
Assert.AreEqual(4, result.Count);
result = a.SelectTokens("$.[?(@.value!='2000-12-05T05:07:59-10:00')]").ToList();
Assert.AreEqual(4, result.Count);
result = a.SelectTokens("$.[?(@.value!=null)]").ToList();
Assert.AreEqual(4, result.Count);
result = a.SelectTokens("$.[?(@.value!=123)]").ToList();
Assert.AreEqual(3, result.Count);
result = a.SelectTokens("$.[?(@.value)]").ToList();
Assert.AreEqual(4, result.Count);
}
@@ -124,13 +124,10 @@ namespace Newtonsoft.Json.Linq.JsonPath
{
switch (Operator)
{
case QueryOperator.NotEquals:
if (Value.Type == JTokenType.Null)
{
return true;
}
break;
case QueryOperator.Exists:
// you can only specify primative types in a comparison
// notequals will always be true
case QueryOperator.NotEquals:
return true;
}
}