Skip to content

Commit

Permalink
Automated rollback of commit e2525e6.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 659723808
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Aug 5, 2024
1 parent 1a300ce commit 1492fa9
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 425 deletions.
17 changes: 15 additions & 2 deletions src/google/protobuf/compiler/cpp/unittest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
#include <memory>
#include <vector>

#include "absl/base/attributes.h"
#include "absl/strings/cord.h"
#include "google/protobuf/compiler/cpp/unittest.h"
#include "absl/strings/cord.h"
#include "absl/strings/string_view.h"
#ifndef _MSC_VER
// We exclude this large proto because it's too large for
Expand Down Expand Up @@ -483,11 +482,25 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ADLSwap) {
UNITTEST::TestAllTypes message1, message2;
TestUtil::SetAllFields(&message1);

// Note the address of one of the repeated fields, to verify it was swapped
// rather than copied.
const int32_t* addr = &message1.repeated_int32().Get(0);
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
const int32_t value = *addr;
#endif

using std::swap;
swap(message1, message2);

TestUtil::ExpectAllFieldsSet(message2);
TestUtil::ExpectClear(message1);

#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
EXPECT_NE(addr, &message2.repeated_int32().Get(0));
EXPECT_EQ(value, message2.repeated_int32().Get(0));
#else
EXPECT_EQ(addr, &message2.repeated_int32().Get(0));
#endif
}

TEST(GENERATED_MESSAGE_TEST_NAME, CopyConstructor) {
Expand Down
11 changes: 4 additions & 7 deletions src/google/protobuf/extension_set_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "google/protobuf/extension_set.h"

#include <algorithm>
#include <cstdint>
#include <string>

Expand Down Expand Up @@ -842,12 +841,10 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) {
const size_t old_capacity = \
message->GetRepeatedExtension(unittest::repeated_##type##_extension) \
.Capacity(); \
if (sizeof(cpptype) > 1) { \
EXPECT_GE( \
old_capacity, \
(RepeatedFieldLowerClampLimit<cpptype, std::max(sizeof(cpptype), \
sizeof(void*))>())); \
} \
EXPECT_GE( \
old_capacity, \
(RepeatedFieldLowerClampLimit<cpptype, std::max(sizeof(cpptype), \
sizeof(void*))>())); \
for (int i = 0; i < 16; ++i) { \
message->AddExtension(unittest::repeated_##type##_extension, value); \
} \
Expand Down
Loading

0 comments on commit 1492fa9

Please sign in to comment.