Skip to content

Commit 9948574

Browse files
committed
more tests and coverage printer
1 parent 27899fb commit 9948574

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

server/core/src/main/java/io/whitefox/core/types/predicates/BaseOp.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ default void validateChildren(List<BaseOp> children) throws PredicateException {
112112
}
113113

114114
for (BaseOp c : children) {
115-
try {
116-
c.validate();
117-
} catch (PredicateException e) {
118-
throw new RuntimeException(e);
119-
}
115+
c.validate();
120116
}
121117
}
122118
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

Comments
 (0)