|
| 1 | +package io.whitefox.core.types.predicates; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 4 | + |
| 5 | +import io.whitefox.core.types.DateType; |
| 6 | +import io.whitefox.core.types.IntegerType; |
| 7 | +import java.util.List; |
| 8 | +import java.util.Map; |
| 9 | +import org.junit.jupiter.api.Test; |
| 10 | + |
| 11 | +public class EvalHelperTest { |
| 12 | + |
| 13 | + @Test |
| 14 | + void testLessThan() throws PredicateException { |
| 15 | + var evalContext1 = new EvalContext(Map.of("date", "2020-10-10"), Map.of()); |
| 16 | + var children1 = |
| 17 | + List.of(new ColumnOp("date", DateType.DATE), new LiteralOp("2020-10-11", DateType.DATE)); |
| 18 | + assertTrue(EvalHelper.lessThan(children1, evalContext1)); |
| 19 | + var evalContext2 = new EvalContext(Map.of("integer", "19"), Map.of()); |
| 20 | + var children2 = List.of( |
| 21 | + new ColumnOp("integer", IntegerType.INTEGER), new LiteralOp("20", IntegerType.INTEGER)); |
| 22 | + assertTrue(EvalHelper.lessThan(children2, evalContext2)); |
| 23 | + } |
| 24 | + |
| 25 | + @Test |
| 26 | + void testEqual() throws PredicateException { |
| 27 | + var evalContext1 = new EvalContext(Map.of("date", "2020-10-11"), Map.of()); |
| 28 | + var children1 = |
| 29 | + List.of(new ColumnOp("date", DateType.DATE), new LiteralOp("2020-10-11", DateType.DATE)); |
| 30 | + assertTrue(EvalHelper.equal(children1, evalContext1)); |
| 31 | + var evalContext2 = new EvalContext(Map.of("integer", "20"), Map.of()); |
| 32 | + var children2 = List.of( |
| 33 | + new ColumnOp("integer", IntegerType.INTEGER), new LiteralOp("20", IntegerType.INTEGER)); |
| 34 | + assertTrue(EvalHelper.equal(children2, evalContext2)); |
| 35 | + } |
| 36 | +} |
0 commit comments