|
|
@ -7,13 +7,17 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "google/protobuf/arena.h" |
|
|
|
#include "google/protobuf/arena.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <time.h> |
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm> |
|
|
|
#include <algorithm> |
|
|
|
#include <array> |
|
|
|
#include <array> |
|
|
|
#include <atomic> |
|
|
|
#include <atomic> |
|
|
|
#include <cstddef> |
|
|
|
#include <cstddef> |
|
|
|
#include <cstdint> |
|
|
|
#include <cstdint> |
|
|
|
|
|
|
|
#include <cstdlib> |
|
|
|
#include <cstring> |
|
|
|
#include <cstring> |
|
|
|
#include <memory> |
|
|
|
#include <memory> |
|
|
|
|
|
|
|
#include <new> // IWYU pragma: keep for operator new |
|
|
|
#include <string> |
|
|
|
#include <string> |
|
|
|
#include <thread> |
|
|
|
#include <thread> |
|
|
|
#include <type_traits> |
|
|
|
#include <type_traits> |
|
|
@ -874,7 +878,7 @@ TEST(ArenaTest, ReleaseFromArenaMessageUsingReflectionMakesCopy) { |
|
|
|
const Reflection* r = arena_message->GetReflection(); |
|
|
|
const Reflection* r = arena_message->GetReflection(); |
|
|
|
const FieldDescriptor* f = arena_message->GetDescriptor()->FindFieldByName( |
|
|
|
const FieldDescriptor* f = arena_message->GetDescriptor()->FindFieldByName( |
|
|
|
"optional_nested_message"); |
|
|
|
"optional_nested_message"); |
|
|
|
nested_msg = static_cast<TestAllTypes::NestedMessage*>( |
|
|
|
nested_msg = DownCastToGenerated<TestAllTypes::NestedMessage>( |
|
|
|
r->ReleaseMessage(arena_message, f)); |
|
|
|
r->ReleaseMessage(arena_message, f)); |
|
|
|
} |
|
|
|
} |
|
|
|
EXPECT_EQ(42, nested_msg->bb()); |
|
|
|
EXPECT_EQ(42, nested_msg->bb()); |
|
|
@ -1482,7 +1486,7 @@ TEST(ArenaTest, MutableMessageReflection) { |
|
|
|
const Descriptor* d = message->GetDescriptor(); |
|
|
|
const Descriptor* d = message->GetDescriptor(); |
|
|
|
const FieldDescriptor* field = d->FindFieldByName("optional_nested_message"); |
|
|
|
const FieldDescriptor* field = d->FindFieldByName("optional_nested_message"); |
|
|
|
TestAllTypes::NestedMessage* submessage = |
|
|
|
TestAllTypes::NestedMessage* submessage = |
|
|
|
static_cast<TestAllTypes::NestedMessage*>( |
|
|
|
DownCastToGenerated<TestAllTypes::NestedMessage>( |
|
|
|
r->MutableMessage(message, field)); |
|
|
|
r->MutableMessage(message, field)); |
|
|
|
TestAllTypes::NestedMessage* submessage_expected = |
|
|
|
TestAllTypes::NestedMessage* submessage_expected = |
|
|
|
message->mutable_optional_nested_message(); |
|
|
|
message->mutable_optional_nested_message(); |
|
|
@ -1492,7 +1496,7 @@ TEST(ArenaTest, MutableMessageReflection) { |
|
|
|
|
|
|
|
|
|
|
|
const FieldDescriptor* oneof_field = |
|
|
|
const FieldDescriptor* oneof_field = |
|
|
|
d->FindFieldByName("oneof_nested_message"); |
|
|
|
d->FindFieldByName("oneof_nested_message"); |
|
|
|
submessage = static_cast<TestAllTypes::NestedMessage*>( |
|
|
|
submessage = DownCastToGenerated<TestAllTypes::NestedMessage>( |
|
|
|
r->MutableMessage(message, oneof_field)); |
|
|
|
r->MutableMessage(message, oneof_field)); |
|
|
|
submessage_expected = message->mutable_oneof_nested_message(); |
|
|
|
submessage_expected = message->mutable_oneof_nested_message(); |
|
|
|
|
|
|
|
|
|
|
@ -1655,7 +1659,7 @@ TEST(ArenaTest, Alignment) { |
|
|
|
Arena arena; |
|
|
|
Arena arena; |
|
|
|
for (int i = 0; i < 200; i++) { |
|
|
|
for (int i = 0; i < 200; i++) { |
|
|
|
void* p = Arena::CreateArray<char>(&arena, i); |
|
|
|
void* p = Arena::CreateArray<char>(&arena, i); |
|
|
|
ABSL_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << ": " << p; |
|
|
|
ABSL_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0u) << i << ": " << p; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|