未验证 提交 3ea464b7 编写于 作者: C Chris Bracken 提交者: GitHub

Make EncodableValue::LongValue const (#25335)

This method doesn't mutate the value of the underlying variant.

Fixes https://github.com/flutter/flutter/issues/79472
上级 77a2b31b
......@@ -33,10 +33,10 @@ TEST(EncodableValueTest, Int) {
// Test the int/long convenience wrapper.
TEST(EncodableValueTest, LongValue) {
EncodableValue value(std::numeric_limits<int32_t>::max());
EXPECT_EQ(value.LongValue(), std::numeric_limits<int32_t>::max());
value = std::numeric_limits<int64_t>::max();
EXPECT_EQ(value.LongValue(), std::numeric_limits<int64_t>::max());
const EncodableValue int_value(std::numeric_limits<int32_t>::max());
EXPECT_EQ(int_value.LongValue(), std::numeric_limits<int32_t>::max());
const EncodableValue long_value(std::numeric_limits<int64_t>::max());
EXPECT_EQ(long_value.LongValue(), std::numeric_limits<int64_t>::max());
}
TEST(EncodableValueTest, Long) {
......
......@@ -203,7 +203,7 @@ class EncodableValue : public internal::EncodableValueVariant {
//
// Calling this method if the value doesn't contain either an int32_t or an
// int64_t will throw an exception.
int64_t LongValue() {
int64_t LongValue() const {
if (std::holds_alternative<int32_t>(*this)) {
return std::get<int32_t>(*this);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册