forked from cel-expr/cel-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattribute_trail_test.cc
More file actions
43 lines (36 loc) · 1.21 KB
/
Copy pathattribute_trail_test.cc
File metadata and controls
43 lines (36 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "eval/eval/attribute_trail.h"
#include "google/api/expr/v1alpha1/syntax.pb.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "eval/public/cel_attribute.h"
#include "eval/public/cel_value.h"
namespace google {
namespace api {
namespace expr {
namespace runtime {
using google::api::expr::v1alpha1::Expr;
// Attribute Trail behavior
TEST(AttributeTrailTest, AttributeTrailEmptyStep) {
google::protobuf::Arena arena;
std::string step = "step";
CelValue step_value = CelValue::CreateString(&step);
AttributeTrail trail;
ASSERT_TRUE(trail.Step(&step, &arena).empty());
ASSERT_TRUE(
trail.Step(CelAttributeQualifier::Create(step_value), &arena).empty());
}
TEST(AttributeTrailTest, AttributeTrailStep) {
google::protobuf::Arena arena;
std::string step = "step";
CelValue step_value = CelValue::CreateString(&step);
Expr root;
root.mutable_ident_expr()->set_name("ident");
AttributeTrail trail = AttributeTrail(root, &arena).Step(&step, &arena);
ASSERT_TRUE(trail.attribute() != nullptr);
ASSERT_EQ(*trail.attribute(),
CelAttribute(root, {CelAttributeQualifier::Create(step_value)}));
}
} // namespace runtime
} // namespace expr
} // namespace api
} // namespace google