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

Function TEST_P

extensions/encoders_test.cc:45–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43class EncodersTest : public ::testing::TestWithParam<TestCase> {};
44
45TEST_P(EncodersTest, ParseCheckEval) {
46 const TestCase& test_case = GetParam();
47
48 // Configure the compiler.
49 ASSERT_OK_AND_ASSIGN(
50 auto compiler_builder,
51 NewCompilerBuilder(internal::GetTestingDescriptorPool()));
52 ASSERT_THAT(compiler_builder->AddLibrary(StandardCheckerLibrary()), IsOk());
53 ASSERT_THAT(
54 compiler_builder->AddLibrary(extensions::EncodersCheckerLibrary()),
55 IsOk());
56 ASSERT_OK_AND_ASSIGN(std::unique_ptr<Compiler> compiler,
57 std::move(*compiler_builder).Build());
58
59 // Configure the runtime.
60 cel::RuntimeOptions runtime_options;
61 ASSERT_OK_AND_ASSIGN(
62 auto runtime_builder,
63 CreateStandardRuntimeBuilder(internal::GetTestingDescriptorPool(),
64 runtime_options));
65 ASSERT_THAT(RegisterEncodersFunctions(runtime_builder.function_registry(),
66 runtime_options),
67 IsOk());
68 ASSERT_OK_AND_ASSIGN(std::unique_ptr<const Runtime> runtime,
69 std::move(runtime_builder).Build());
70
71 // Compile, plan, evaluate.
72 ASSERT_OK_AND_ASSIGN(ValidationResult result,
73 compiler->Compile(test_case.expr));
74 ASSERT_TRUE(result.IsValid());
75 ASSERT_OK_AND_ASSIGN(auto program,
76 runtime->CreateProgram(*result.ReleaseAst()));
77
78 google::protobuf::Arena arena;
79 Activation activation;
80 ASSERT_OK_AND_ASSIGN(auto value, program->Evaluate(&arena, activation));
81 ASSERT_TRUE(value.IsBool());
82 ASSERT_TRUE(value.GetBool());
83}
84
85INSTANTIATE_TEST_SUITE_P(
86 EncodersTest, EncodersTest,

Callers

nothing calls this directly

Calls 9

StandardCheckerLibraryFunction · 0.85
EncodersCheckerLibraryFunction · 0.85
IsValidMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.50
AddLibraryMethod · 0.45
BuildMethod · 0.45
IsBoolMethod · 0.45
GetBoolMethod · 0.45

Tested by

no test coverage detected