MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / TEST

Function TEST

validator/ast_depth_validator_test.cc:41–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41TEST(AstDepthValidatorTest, Basic) {
42 auto compiler = CreateCompiler();
43 ASSERT_OK_AND_ASSIGN(auto result, compiler->Compile("1 + 2 + 3"));
44
45 Validator validator;
46 validator.AddValidation(AstDepthValidator(10));
47 auto output = validator.Validate(*result.GetAst());
48 EXPECT_TRUE(output.valid);
49
50 Validator validator2;
51 validator2.AddValidation(AstDepthValidator(2));
52 output = validator2.Validate(*result.GetAst());
53 EXPECT_FALSE(output.valid);
54 EXPECT_THAT(output.issues,
55 testing::Contains(testing::Property(
56 &TypeCheckIssue::message,
57 testing::Eq("AST depth 3 exceeds maximum of 2"))));
58}
59
60TEST(AstDepthValidatorTest, Nested) {
61 auto compiler = CreateCompiler();

Callers

nothing calls this directly

Calls 5

AstDepthValidatorFunction · 0.85
AddValidationMethod · 0.80
ValidateMethod · 0.80
GetAstMethod · 0.80
CreateCompilerFunction · 0.70

Tested by

no test coverage detected