Directly test calling ByteSizeLong() on default instances.

These instances may be in `.rodata`, so ByteSizeLong() cannot write to the
_cached_size_.  The call itself should succeed.

PiperOrigin-RevId: 689822451
pull/18998/head
Chris Kennelly 5 months ago committed by Copybara-Service
parent 14564cc648
commit 03ed5d970b
  1. 6
      src/google/protobuf/message_unittest.inc

@ -420,6 +420,12 @@ TEST(MESSAGE_TEST_NAME, UnparsedEmpty) {
EXPECT_EQ(message.lazy_child().ByteSizeLong(), 0);
}
TEST(MESSAGE_TEST_NAME, DefaultInstanceByteSizeLong) {
EXPECT_EQ(UNITTEST::NestedTestAllTypes::default_instance().ByteSizeLong(), 0);
EXPECT_EQ(UNITTEST::NestedTestAllTypes::default_instance().GetCachedSize(),
0);
}
TEST(MESSAGE_TEST_NAME, ParseFailNonCanonicalZeroTag) {
const char encoded[] = {"\n\x3\x80\0\0"};
UNITTEST::NestedTestAllTypes parsed;

Loading…
Cancel
Save