| 52 | using ComprehensionNestingValidatorTest = testing::TestWithParam<TestCase>; |
| 53 | |
| 54 | TEST_P(ComprehensionNestingValidatorTest, Validate) { |
| 55 | const auto& test_case = GetParam(); |
| 56 | Validator validator; |
| 57 | validator.AddValidation(ComprehensionNestingLimitValidator(test_case.limit)); |
| 58 | |
| 59 | ASSERT_OK_AND_ASSIGN(auto compiler, StdLibCompiler()); |
| 60 | auto result_or = compiler->Compile(test_case.expression); |
| 61 | if (!result_or.ok()) { |
| 62 | GTEST_SKIP() << "Expression failed to compile: " << test_case.expression |
| 63 | << " " << result_or.status().message(); |
| 64 | } |
| 65 | auto result = std::move(result_or).value(); |
| 66 | |
| 67 | validator.UpdateValidationResult(result); |
| 68 | |
| 69 | EXPECT_EQ(result.IsValid(), test_case.valid) |
| 70 | << "Expression: " << test_case.expression |
| 71 | << " Limit: " << test_case.limit; |
| 72 | if (!test_case.valid) { |
| 73 | EXPECT_THAT(result.FormatError(), HasSubstr(test_case.error_substr)); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | INSTANTIATE_TEST_SUITE_P( |
| 78 | ComprehensionNestingValidatorTest, ComprehensionNestingValidatorTest, |
nothing calls this directly
no test coverage detected