-Fixed JValue.CompareTo with number and string values

This commit is contained in:
James Newton-King
2017-07-22 13:41:14 +12:00
parent bbbddf0031
commit ad1a13728a
4 changed files with 220 additions and 3 deletions
@@ -51,6 +51,52 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
[TestFixture]
public class JPathExecuteTests : TestFixtureBase
{
[Test]
public void GreaterThanWithIntegerParameterAndStringValue()
{
string json = @"{
""persons"": [
{
""name"" : ""John"",
""age"": ""26""
},
{
""name"" : ""Jane"",
""age"": ""2""
}
]
}";
JObject models = JObject.Parse(json);
var results = models.SelectTokens("$.persons[?(@.age > 3)]").ToList();
Assert.AreEqual(1, results.Count);
}
[Test]
public void GreaterThanWithStringParameterAndIntegerValue()
{
string json = @"{
""persons"": [
{
""name"" : ""John"",
""age"": 26
},
{
""name"" : ""Jane"",
""age"": 2
}
]
}";
JObject models = JObject.Parse(json);
var results = models.SelectTokens("$.persons[?(@.age > '3')]").ToList();
Assert.AreEqual(1, results.Count);
}
[Test]
public void RecursiveWildcard()
{