| 46 | using ::testing::SizeIs; |
| 47 | |
| 48 | TEST(IdentStepTest, TestIdentStep) { |
| 49 | ASSERT_OK_AND_ASSIGN(auto step, CreateIdentStep("name0", /*id=*/-1)); |
| 50 | |
| 51 | ExecutionPath path; |
| 52 | path.push_back(std::move(step)); |
| 53 | |
| 54 | auto env = NewTestingRuntimeEnv(); |
| 55 | CelExpressionFlatImpl impl( |
| 56 | env, FlatExpression(std::move(path), /*comprehension_slot_count=*/0, |
| 57 | env->type_registry.GetComposedTypeProvider(), |
| 58 | cel::RuntimeOptions{})); |
| 59 | |
| 60 | Activation activation; |
| 61 | Arena arena; |
| 62 | std::string value("test"); |
| 63 | |
| 64 | activation.InsertValue("name0", CelValue::CreateString(&value)); |
| 65 | auto status0 = impl.Evaluate(activation, &arena); |
| 66 | ASSERT_OK(status0); |
| 67 | |
| 68 | CelValue result = status0.value(); |
| 69 | |
| 70 | ASSERT_TRUE(result.IsString()); |
| 71 | EXPECT_THAT(result.StringOrDie().value(), Eq("test")); |
| 72 | } |
| 73 | |
| 74 | TEST(IdentStepTest, TestIdentStepNameNotFound) { |
| 75 | ASSERT_OK_AND_ASSIGN(auto step, CreateIdentStep("name0", /*id=*/-1)); |
| 76 | |
| 77 | ExecutionPath path; |
| 78 | path.push_back(std::move(step)); |
| 79 | |
| 80 | auto env = NewTestingRuntimeEnv(); |
| 81 | CelExpressionFlatImpl impl( |
| 82 | env, FlatExpression(std::move(path), /*comprehension_slot_count=*/0, |
| 83 | env->type_registry.GetComposedTypeProvider(), |
| 84 | cel::RuntimeOptions{})); |
| 85 | |
| 86 | Activation activation; |
| 87 | Arena arena; |
| 88 | std::string value("test"); |
| 89 | |
| 90 | auto status0 = impl.Evaluate(activation, &arena); |
| 91 | ASSERT_OK(status0); |
| 92 | |
| 93 | CelValue result = status0.value(); |
| 94 | ASSERT_TRUE(result.IsError()); |
| 95 | } |
| 96 | |
| 97 | TEST(IdentStepTest, DisableMissingAttributeErrorsOK) { |
| 98 | ASSERT_OK_AND_ASSIGN(auto step, CreateIdentStep("name0", /*id=*/-1)); |
| 99 | |
| 100 | ExecutionPath path; |
| 101 | path.push_back(std::move(step)); |
| 102 | cel::RuntimeOptions options; |
| 103 | options.unknown_processing = cel::UnknownProcessingOptions::kDisabled; |
| 104 | auto env = NewTestingRuntimeEnv(); |
| 105 | CelExpressionFlatImpl impl( |
nothing calls this directly
no test coverage detected