| 96 | } |
| 97 | |
| 98 | absl::StatusOr<Value> MinList( |
| 99 | const ListValue& values, |
| 100 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
| 101 | google::protobuf::MessageFactory* absl_nonnull message_factory, |
| 102 | google::protobuf::Arena* absl_nonnull arena) { |
| 103 | CEL_ASSIGN_OR_RETURN(auto iterator, values.NewIterator()); |
| 104 | if (!iterator->HasNext()) { |
| 105 | return ErrorValue( |
| 106 | absl::InvalidArgumentError("math.@min argument must not be empty")); |
| 107 | } |
| 108 | Value value; |
| 109 | CEL_RETURN_IF_ERROR( |
| 110 | iterator->Next(descriptor_pool, message_factory, arena, &value)); |
| 111 | absl::StatusOr<CelNumber> current = ValueToNumber(value, kMathMin); |
| 112 | if (!current.ok()) { |
| 113 | return ErrorValue{current.status()}; |
| 114 | } |
| 115 | CelNumber min = *current; |
| 116 | while (iterator->HasNext()) { |
| 117 | CEL_RETURN_IF_ERROR( |
| 118 | iterator->Next(descriptor_pool, message_factory, arena, &value)); |
| 119 | absl::StatusOr<CelNumber> other = ValueToNumber(value, kMathMin); |
| 120 | if (!other.ok()) { |
| 121 | return ErrorValue{other.status()}; |
| 122 | } |
| 123 | min = MinNumber(min, *other); |
| 124 | } |
| 125 | return NumberToValue(min); |
| 126 | } |
| 127 | |
| 128 | CelNumber MaxNumber(CelNumber v1, CelNumber v2) { |
| 129 | if (v2 > v1) { |
nothing calls this directly
no test coverage detected