Add more test coverage for arena registration.

PiperOrigin-RevId: 696606741
pull/19254/head
Protobuf Team Bot 3 weeks ago committed by Copybara-Service
parent b7d54e5ef1
commit d4cc9126fe
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 2
      src/google/protobuf/BUILD.bazel
  3. 1
      src/google/protobuf/compiler/cpp/file_unittest.cc
  4. 15
      src/google/protobuf/message_unittest.inc
  5. 4
      src/google/protobuf/unittest.proto

@ -1,17 +0,0 @@
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#endregion
namespace Google.Protobuf.Reflection;
internal sealed partial class FeatureSetDescriptor
{
// Canonical serialized form of the edition defaults, generated by embed_edition_defaults.
private const string DefaultsBase64 =
"ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH";
}

@ -1734,6 +1734,7 @@ cc_test(
":cc_lite_test_protos",
":cc_test_protos",
":internal_visibility",
":lite_test_util",
":port",
":protobuf",
":protobuf_lite",
@ -1766,6 +1767,7 @@ cc_test(
":arena",
":cc_test_protos",
":internal_visibility",
":lite_test_util",
":port",
":protobuf",
":protobuf_lite",

@ -47,6 +47,7 @@ TEST(FileTest, TopologicallyOrderedDescriptors) {
"TestVerifyBigFieldNumberUint32.Nested",
"TestUnpackedTypes",
"TestUnpackedExtensions",
"TestString",
"TestReservedFields",
"TestRequiredOpenEnum",
"TestRequiredOneof.NestedMessage",

@ -41,6 +41,7 @@
#include "absl/strings/cord.h"
#include "absl/strings/substitute.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/arena_test_util.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/dynamic_message.h"
#include "google/protobuf/generated_message_reflection.h"
@ -58,6 +59,9 @@
// Must be included last.
#include "google/protobuf/port_def.inc"
using ::testing::IsEmpty;
using ::testing::Not;
namespace google {
namespace protobuf {
@ -891,6 +895,17 @@ TEST(MESSAGE_TEST_NAME, MessageDebugStringMatchesBehindPointerAndLitePointer) {
ASSERT_EQ(test_all_types.DebugString(), msg_lite_pointer->DebugString());
}
TEST(MESSAGE_TEST_NAME, CordFieldGetsProperlyRegisteredInTheArena) {
Arena arena;
auto* msg = Arena::Create<UNITTEST::TestCord>(&arena);
// Very large input that needs allocation.
msg->set_optional_bytes_cord(std::string(1000, 'x'));
// Something should be registered for destruction.
EXPECT_THAT(internal::ArenaTestPeer::PeekCleanupListForTesting(&arena),
Not(IsEmpty()));
// We expect memory leaks here if the Cord was not properly destroyed.
}
#if GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet.
TEST(MESSAGE_TEST_NAME, SerializeFailsIfNotInitialized) {

@ -2455,6 +2455,10 @@ extend RedactedFields {
];
}
message TestString {
string optional_string = 1;
}
message TestCord {
bytes optional_bytes_cord = 1 [
ctype = CORD

Loading…
Cancel
Save