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

Function TEST

env/internal/ext_registry_test.cc:34–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32using ::testing::HasSubstr;
33
34TEST(ExtensionRegistryTest, GetCompilerLibrary) {
35 ExtensionRegistry registry;
36 registry.RegisterCompilerLibrary("foo1", "f", 1, []() {
37 return CompilerLibrary("foo1_1", nullptr, nullptr);
38 });
39 registry.RegisterCompilerLibrary("foo1", "f", 2, []() {
40 return CompilerLibrary("foo1_2", nullptr, nullptr);
41 });
42 registry.RegisterCompilerLibrary("foo2", "", 1, []() {
43 return CompilerLibrary("foo2_1", nullptr, nullptr);
44 });
45
46 EXPECT_THAT(registry.GetCompilerLibrary("foo1", 1),
47 IsOkAndHolds(Field(&CompilerLibrary::id, "foo1_1")));
48 EXPECT_THAT(registry.GetCompilerLibrary("f", 1),
49 IsOkAndHolds(Field(&CompilerLibrary::id, "foo1_1")));
50 EXPECT_THAT(registry.GetCompilerLibrary("foo1", 2),
51 IsOkAndHolds(Field(&CompilerLibrary::id, "foo1_2")));
52 EXPECT_THAT(registry.GetCompilerLibrary("foo1", ExtensionRegistry::kLatest),
53 IsOkAndHolds(Field(&CompilerLibrary::id, "foo1_2")));
54 EXPECT_THAT(registry.GetCompilerLibrary("f", ExtensionRegistry::kLatest),
55 IsOkAndHolds(Field(&CompilerLibrary::id, "foo1_2")));
56 EXPECT_THAT(registry.GetCompilerLibrary("foo2", 1),
57 IsOkAndHolds(Field(&CompilerLibrary::id, "foo2_1")));
58 EXPECT_THAT(registry.GetCompilerLibrary("foo2", ExtensionRegistry::kLatest),
59 IsOkAndHolds(Field(&CompilerLibrary::id, "foo2_1")));
60
61 EXPECT_THAT(registry.GetCompilerLibrary("foo1", 3),
62 StatusIs(absl::StatusCode::kNotFound,
63 HasSubstr("CompilerLibrary not registered: foo1#3")));
64 EXPECT_THAT(registry.GetCompilerLibrary("foo3", 1),
65 StatusIs(absl::StatusCode::kNotFound,
66 HasSubstr("CompilerLibrary not registered: foo3")));
67 EXPECT_THAT(registry.GetCompilerLibrary("foo3", ExtensionRegistry::kLatest),
68 StatusIs(absl::StatusCode::kNotFound,
69 HasSubstr("CompilerLibrary not registered: foo3")));
70}
71
72} // namespace
73} // namespace cel::env_internal

Callers

nothing calls this directly

Calls 4

CompilerLibraryClass · 0.85
FieldClass · 0.85
GetCompilerLibraryMethod · 0.80

Tested by

no test coverage detected