| 53 | }; |
| 54 | |
| 55 | TEST(CelValueTest, TestType) { |
| 56 | ::google::protobuf::Arena arena; |
| 57 | |
| 58 | CelValue value_null = CelValue::CreateNull(); |
| 59 | EXPECT_THAT(value_null.type(), Eq(CelValue::Type::kNullType)); |
| 60 | |
| 61 | CelValue value_bool = CelValue::CreateBool(false); |
| 62 | EXPECT_THAT(value_bool.type(), Eq(CelValue::Type::kBool)); |
| 63 | |
| 64 | CelValue value_int64 = CelValue::CreateInt64(0); |
| 65 | EXPECT_THAT(value_int64.type(), Eq(CelValue::Type::kInt64)); |
| 66 | |
| 67 | CelValue value_uint64 = CelValue::CreateUint64(1); |
| 68 | EXPECT_THAT(value_uint64.type(), Eq(CelValue::Type::kUint64)); |
| 69 | |
| 70 | CelValue value_double = CelValue::CreateDouble(1.0); |
| 71 | EXPECT_THAT(value_double.type(), Eq(CelValue::Type::kDouble)); |
| 72 | |
| 73 | std::string str = "test"; |
| 74 | CelValue value_str = CelValue::CreateString(&str); |
| 75 | EXPECT_THAT(value_str.type(), Eq(CelValue::Type::kString)); |
| 76 | |
| 77 | std::string bytes_str = "bytes"; |
| 78 | CelValue value_bytes = CelValue::CreateBytes(&bytes_str); |
| 79 | EXPECT_THAT(value_bytes.type(), Eq(CelValue::Type::kBytes)); |
| 80 | |
| 81 | UnknownSet unknown_set; |
| 82 | CelValue value_unknown = CelValue::CreateUnknownSet(&unknown_set); |
| 83 | EXPECT_THAT(value_unknown.type(), Eq(CelValue::Type::kUnknownSet)); |
| 84 | |
| 85 | CelValue missing_attribute_error = |
| 86 | CreateMissingAttributeError(&arena, "destination.ip"); |
| 87 | EXPECT_TRUE(IsMissingAttributeError(missing_attribute_error)); |
| 88 | EXPECT_EQ(missing_attribute_error.ErrorOrDie()->code(), |
| 89 | absl::StatusCode::kInvalidArgument); |
| 90 | EXPECT_EQ(missing_attribute_error.ErrorOrDie()->message(), |
| 91 | "MissingAttributeError: destination.ip"); |
| 92 | } |
| 93 | |
| 94 | int CountTypeMatch(const CelValue& value) { |
| 95 | int count = 0; |
nothing calls this directly
no test coverage detected