namespace
| 83 | } |
| 84 | } // namespace |
| 85 | TEST_F(ExpressionFuzzerUnitTest, restrictedLevelOfNesting) { |
| 86 | bolt::functions::prestosql::registerAllScalarFunctions(); |
| 87 | std::mt19937 seed{0}; |
| 88 | |
| 89 | auto testLevelOfNesting = [&](int32_t maxLevelOfNesting) { |
| 90 | ExpressionFuzzer fuzzer{ |
| 91 | bolt::getFunctionSignatures(), |
| 92 | 0, |
| 93 | vectorfuzzer, |
| 94 | makeOptionsWithMaxLevelNesting(maxLevelOfNesting), |
| 95 | }; |
| 96 | |
| 97 | for (int i = 0; i < 5000; ++i) { |
| 98 | auto expression = fuzzer.fuzzExpression().expressions[0]; |
| 99 | EXPECT_LE(countLevelOfNesting(expression), std::max(1, maxLevelOfNesting)) |
| 100 | << fmt::format( |
| 101 | "Expression {} exceeds max level of nesting {} (original {})", |
| 102 | expression->toString(), |
| 103 | std::max(1, maxLevelOfNesting), |
| 104 | maxLevelOfNesting); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | testLevelOfNesting(10); |
| 109 | |
| 110 | testLevelOfNesting(5); |
| 111 | |
| 112 | testLevelOfNesting(2); |
| 113 | |
| 114 | testLevelOfNesting(1); |
| 115 | |
| 116 | testLevelOfNesting(0); |
| 117 | |
| 118 | testLevelOfNesting(-1); |
| 119 | } |
| 120 | |
| 121 | TEST_F(ExpressionFuzzerUnitTest, reproduceExpressionWithSeed) { |
| 122 | bolt::functions::prestosql::registerAllScalarFunctions(); |
nothing calls this directly
no test coverage detected