|
|
@ -14,7 +14,6 @@ |
|
|
|
#include "absl/strings/match.h" |
|
|
|
#include "absl/strings/match.h" |
|
|
|
#include "google/protobuf/arena.h" |
|
|
|
#include "google/protobuf/arena.h" |
|
|
|
#include "google/protobuf/descriptor.h" |
|
|
|
#include "google/protobuf/descriptor.h" |
|
|
|
#include "google/protobuf/port.h" |
|
|
|
|
|
|
|
#include "google/protobuf/text_format.h" |
|
|
|
#include "google/protobuf/text_format.h" |
|
|
|
#include "google/protobuf/unittest.pb.h" |
|
|
|
#include "google/protobuf/unittest.pb.h" |
|
|
|
#include "google/protobuf/unittest_proto3_arena.pb.h" |
|
|
|
#include "google/protobuf/unittest_proto3_arena.pb.h" |
|
|
@ -257,38 +256,6 @@ TEST(Proto3OptionalTest, OptionalFields) { |
|
|
|
EXPECT_EQ(serialized.size(), 0); |
|
|
|
EXPECT_EQ(serialized.size(), 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST(Proto3ArenaTest, CheckMessageFieldIsCleared) { |
|
|
|
|
|
|
|
Arena arena; |
|
|
|
|
|
|
|
auto msg = Arena::Create<TestAllTypes>(&arena); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Referring to a saved pointer to a child message is never guaranteed to
|
|
|
|
|
|
|
|
// work. IOW, protobufs do not guarantee pointer stability. This test only
|
|
|
|
|
|
|
|
// does this to replicate (unsupported) user behaviors.
|
|
|
|
|
|
|
|
auto child = msg->mutable_optional_foreign_message(); |
|
|
|
|
|
|
|
child->set_c(100); |
|
|
|
|
|
|
|
msg->Clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(child->c(), 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST(Proto3ArenaTest, CheckOneofMessageFieldIsCleared) { |
|
|
|
|
|
|
|
if (!internal::DebugHardenClearOneofMessageOnArena()) { |
|
|
|
|
|
|
|
GTEST_SKIP() << "arena allocated oneof message fields are not cleared."; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Arena arena; |
|
|
|
|
|
|
|
auto msg = Arena::Create<TestAllTypes>(&arena); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Referring to a saved pointer to a child message is never guaranteed to
|
|
|
|
|
|
|
|
// work. IOW, protobufs do not guarantee pointer stability. This test only
|
|
|
|
|
|
|
|
// does this to replicate (unsupported) user behaviors.
|
|
|
|
|
|
|
|
auto child = msg->mutable_oneof_nested_message(); |
|
|
|
|
|
|
|
child->set_bb(100); |
|
|
|
|
|
|
|
msg->Clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(child->bb(), 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST(Proto3OptionalTest, OptionalFieldDescriptor) { |
|
|
|
TEST(Proto3OptionalTest, OptionalFieldDescriptor) { |
|
|
|
const Descriptor* d = protobuf_unittest::TestProto3Optional::descriptor(); |
|
|
|
const Descriptor* d = protobuf_unittest::TestProto3Optional::descriptor(); |
|
|
|
|
|
|
|
|
|
|
|