| 787 | } |
| 788 | |
| 789 | google::protobuf::Message* FloatFromValue(const google::protobuf::Message* prototype, |
| 790 | const CelValue& value, google::protobuf::Arena* arena) { |
| 791 | double val; |
| 792 | if (!value.GetValue(&val)) { |
| 793 | return nullptr; |
| 794 | } |
| 795 | float fval = val; |
| 796 | // Abort the conversion if the value is outside the float range. |
| 797 | if (val > std::numeric_limits<float>::max()) { |
| 798 | fval = std::numeric_limits<float>::infinity(); |
| 799 | } else if (val < std::numeric_limits<float>::lowest()) { |
| 800 | fval = -std::numeric_limits<float>::infinity(); |
| 801 | } |
| 802 | auto* message = prototype->New(arena); |
| 803 | CEL_ASSIGN_OR_RETURN( |
| 804 | auto reflection, |
| 805 | cel::well_known_types::GetFloatValueReflection(message->GetDescriptor()), |
| 806 | _.With(IgnoreErrorAndReturnNullptr())); |
| 807 | reflection.SetValue(message, static_cast<float>(fval)); |
| 808 | return message; |
| 809 | } |
| 810 | |
| 811 | google::protobuf::Message* Int32FromValue(const google::protobuf::Message* prototype, |
| 812 | const CelValue& value, google::protobuf::Arena* arena) { |
no test coverage detected