|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
package com.jayway.jsonpath; |
|
|
|
|
|
|
|
|
|
import com.jayway.jsonpath.eval.Expression; |
|
|
|
|
import com.jayway.jsonpath.eval.ExpressionEvaluator; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
@ -18,46 +18,46 @@ public class ExpressionEvalTest {
|
|
|
|
|
@Test |
|
|
|
|
public void long_eval() throws Exception { |
|
|
|
|
|
|
|
|
|
assertTrue(Expression.eval(1L, "=", "1")); |
|
|
|
|
assertTrue(Expression.eval(2L, "!=", "1")); |
|
|
|
|
assertTrue(Expression.eval(2L, ">", "1")); |
|
|
|
|
assertTrue(Expression.eval(2L, ">=", "1")); |
|
|
|
|
assertTrue(Expression.eval(2L, ">=", "2")); |
|
|
|
|
assertTrue(Expression.eval(1L, "<", "2")); |
|
|
|
|
assertTrue(Expression.eval(2L, "<=", "2")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(1L, "=", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2L, "!=", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2L, ">", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2L, ">=", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2L, ">=", "2")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(1L, "<", "2")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2L, "<=", "2")); |
|
|
|
|
|
|
|
|
|
assertFalse(Expression.eval(1, ">", "2")); |
|
|
|
|
assertFalse(Expression.eval(1, ">=", "2")); |
|
|
|
|
assertFalse(Expression.eval(2, "<", "1")); |
|
|
|
|
assertFalse(Expression.eval(2, "<=", "1")); |
|
|
|
|
assertFalse(Expression.eval(1, "=", "2")); |
|
|
|
|
assertFalse(Expression.eval(1, "!=", "1")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1, ">", "2")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1, ">=", "2")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(2, "<", "1")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(2, "<=", "1")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1, "=", "2")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1, "!=", "1")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void double_eval() throws Exception { |
|
|
|
|
|
|
|
|
|
assertTrue(Expression.eval(1D, "=", "1")); |
|
|
|
|
assertTrue(Expression.eval(2D, "!=", "1")); |
|
|
|
|
assertTrue(Expression.eval(2D, ">", "1")); |
|
|
|
|
assertTrue(Expression.eval(2D, ">=", "1")); |
|
|
|
|
assertTrue(Expression.eval(2D, ">=", "2")); |
|
|
|
|
assertTrue(Expression.eval(1D, "<", "2")); |
|
|
|
|
assertTrue(Expression.eval(2D, "<=", "2")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(1D, "=", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2D, "!=", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2D, ">", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2D, ">=", "1")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2D, ">=", "2")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(1D, "<", "2")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval(2D, "<=", "2")); |
|
|
|
|
|
|
|
|
|
assertFalse(Expression.eval(1D, ">", "2")); |
|
|
|
|
assertFalse(Expression.eval(1D, ">=", "2")); |
|
|
|
|
assertFalse(Expression.eval(2D, "<", "1")); |
|
|
|
|
assertFalse(Expression.eval(2D, "<=", "1")); |
|
|
|
|
assertFalse(Expression.eval(1D, "=", "2")); |
|
|
|
|
assertFalse(Expression.eval(1D, "!=", "1")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1D, ">", "2")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1D, ">=", "2")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(2D, "<", "1")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(2D, "<=", "1")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1D, "=", "2")); |
|
|
|
|
assertFalse(ExpressionEvaluator.eval(1D, "!=", "1")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void string_eval() throws Exception { |
|
|
|
|
|
|
|
|
|
assertTrue(Expression.eval("A", "=", "A")); |
|
|
|
|
assertTrue(Expression.eval("B", "!=", "A")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval("A", "=", "A")); |
|
|
|
|
assertTrue(ExpressionEvaluator.eval("B", "!=", "A")); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|