| 1 | #include "catch.hpp" |
|---|---|
| 2 | #include "duckdb/common/helper.hpp" |
| 3 | #include "expression_helper.hpp" |
| 4 | #include "duckdb/optimizer/rule/comparison_simplification.hpp" |
| 5 | |
| 6 | using namespace duckdb; |
| 7 | using namespace std; |
| 8 | |
| 9 | TEST_CASE("Comparison simplification test", "[optimizer]") { |
| 10 | ExpressionHelper helper; |
| 11 | |
| 12 | REQUIRE(helper.AddColumns("X INTEGER").empty()); |
| 13 | |
| 14 | helper.AddRule<ComparisonSimplificationRule>(); |
| 15 | |
| 16 | string input, expected_output; |
| 17 | |
| 18 | input = "X=NULL"; |
| 19 | expected_output = "NULL"; |
| 20 | REQUIRE(helper.VerifyRewrite(input, expected_output)); |
| 21 | |
| 22 | input = "X>NULL"; |
| 23 | expected_output = "NULL"; |
| 24 | REQUIRE(helper.VerifyRewrite(input, expected_output)); |
| 25 | |
| 26 | input = "NULL>X"; |
| 27 | expected_output = "NULL"; |
| 28 | REQUIRE(helper.VerifyRewrite(input, expected_output)); |
| 29 | } |
| 30 |