mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make EncodableValue::LongValue const (flutter/engine#25335)
This method doesn't mutate the value of the underlying variant. Fixes https://github.com/flutter/flutter/issues/79472
This commit is contained in:
parent
20b6f2a4ea
commit
896ed97baf
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user