Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: third_party/protobuf/src/google/protobuf/proto3_arena_lite_unittest.cc

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: owners Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/proto3_arena_lite_unittest.cc
diff --git a/third_party/protobuf/src/google/protobuf/proto3_arena_unittest.cc b/third_party/protobuf/src/google/protobuf/proto3_arena_lite_unittest.cc
similarity index 70%
copy from third_party/protobuf/src/google/protobuf/proto3_arena_unittest.cc
copy to third_party/protobuf/src/google/protobuf/proto3_arena_lite_unittest.cc
index 2838e0fc644078c680032375cab424248f688e41..0f18c027e86f150acd8c2ca158524dad803587e0 100644
--- a/third_party/protobuf/src/google/protobuf/proto3_arena_unittest.cc
+++ b/third_party/protobuf/src/google/protobuf/proto3_arena_lite_unittest.cc
@@ -37,13 +37,13 @@
#include <google/protobuf/test_util.h>
#include <google/protobuf/unittest.pb.h>
-#include <google/protobuf/unittest_proto3_arena.pb.h>
+#include <google/protobuf/unittest_proto3_arena_lite.pb.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
namespace google {
-using proto3_arena_unittest::TestAllTypes;
+using proto3_arena_lite_unittest::TestAllTypes;
namespace protobuf {
namespace {
@@ -56,9 +56,9 @@ void SetAllFields(TestAllTypes* m) {
m->mutable_optional_nested_message()->set_bb(42);
m->mutable_optional_foreign_message()->set_c(43);
m->set_optional_nested_enum(
- proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ);
+ proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ);
m->set_optional_foreign_enum(
- proto3_arena_unittest::FOREIGN_BAZ);
+ proto3_arena_lite_unittest::FOREIGN_BAZ);
m->mutable_optional_lazy_message()->set_bb(45);
m->add_repeated_int32(100);
m->add_repeated_string("asdf");
@@ -66,9 +66,9 @@ void SetAllFields(TestAllTypes* m) {
m->add_repeated_nested_message()->set_bb(46);
m->add_repeated_foreign_message()->set_c(47);
m->add_repeated_nested_enum(
- proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ);
+ proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ);
m->add_repeated_foreign_enum(
- proto3_arena_unittest::FOREIGN_BAZ);
+ proto3_arena_lite_unittest::FOREIGN_BAZ);
m->add_repeated_lazy_message()->set_bb(49);
m->set_oneof_uint32(1);
@@ -84,9 +84,9 @@ void ExpectAllFieldsSet(const TestAllTypes& m) {
EXPECT_EQ(42, m.optional_nested_message().bb());
EXPECT_EQ(true, m.has_optional_foreign_message());
EXPECT_EQ(43, m.optional_foreign_message().c());
- EXPECT_EQ(proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ,
+ EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ,
m.optional_nested_enum());
- EXPECT_EQ(proto3_arena_unittest::FOREIGN_BAZ,
+ EXPECT_EQ(proto3_arena_lite_unittest::FOREIGN_BAZ,
m.optional_foreign_enum());
EXPECT_EQ(true, m.has_optional_lazy_message());
EXPECT_EQ(45, m.optional_lazy_message().bb());
@@ -102,15 +102,15 @@ void ExpectAllFieldsSet(const TestAllTypes& m) {
EXPECT_EQ(1, m.repeated_foreign_message_size());
EXPECT_EQ(47, m.repeated_foreign_message(0).c());
EXPECT_EQ(1, m.repeated_nested_enum_size());
- EXPECT_EQ(proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ,
+ EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ,
m.repeated_nested_enum(0));
EXPECT_EQ(1, m.repeated_foreign_enum_size());
- EXPECT_EQ(proto3_arena_unittest::FOREIGN_BAZ,
+ EXPECT_EQ(proto3_arena_lite_unittest::FOREIGN_BAZ,
m.repeated_foreign_enum(0));
EXPECT_EQ(1, m.repeated_lazy_message_size());
EXPECT_EQ(49, m.repeated_lazy_message(0).bb());
- EXPECT_EQ(proto3_arena_unittest::TestAllTypes::kOneofString,
+ EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes::kOneofString,
m.oneof_field_case());
EXPECT_EQ("test", m.oneof_string());
}
@@ -119,7 +119,7 @@ void ExpectAllFieldsSet(const TestAllTypes& m) {
// proto3 and expect the arena support to be fully tested in proto2 unittests
// because proto3 shares most code with proto2.
-TEST(Proto3ArenaTest, Parsing) {
+TEST(Proto3ArenaLiteTest, Parsing) {
TestAllTypes original;
SetAllFields(&original);
@@ -129,28 +129,7 @@ TEST(Proto3ArenaTest, Parsing) {
ExpectAllFieldsSet(*arena_message);
}
-TEST(Proto3ArenaTest, UnknownFields) {
- TestAllTypes original;
- SetAllFields(&original);
-
- Arena arena;
- TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
- arena_message->ParseFromString(original.SerializeAsString());
- ExpectAllFieldsSet(*arena_message);
-
- // In proto3 we can still get a pointer to the UnknownFieldSet through
- // reflection API.
- UnknownFieldSet* unknown_fields =
- arena_message->GetReflection()->MutableUnknownFields(arena_message);
- // We can modify this UnknownFieldSet.
- unknown_fields->AddVarint(1, 2);
- // But the change will never will serialized back.
- ASSERT_EQ(original.ByteSize(), arena_message->ByteSize());
- ASSERT_TRUE(
- arena_message->GetReflection()->GetUnknownFields(*arena_message).empty());
-}
-
-TEST(Proto3ArenaTest, Swap) {
+TEST(Proto3ArenaLiteTest, Swap) {
Arena arena1;
Arena arena2;
@@ -162,7 +141,7 @@ TEST(Proto3ArenaTest, Swap) {
EXPECT_EQ(&arena2, arena2_message->GetArena());
}
-TEST(Proto3ArenaTest, SetAllocatedMessage) {
+TEST(Proto3ArenaLiteTest, SetAllocatedMessage) {
Arena arena;
TestAllTypes *arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
TestAllTypes::NestedMessage* nested = new TestAllTypes::NestedMessage;
@@ -171,7 +150,7 @@ TEST(Proto3ArenaTest, SetAllocatedMessage) {
EXPECT_EQ(118, arena_message->optional_nested_message().bb());
}
-TEST(Proto3ArenaTest, ReleaseMessage) {
+TEST(Proto3ArenaLiteTest, ReleaseMessage) {
Arena arena;
TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
arena_message->mutable_optional_nested_message()->set_bb(118);
@@ -180,30 +159,6 @@ TEST(Proto3ArenaTest, ReleaseMessage) {
EXPECT_EQ(118, nested->bb());
}
-TEST(Proto3ArenaTest, MessageFieldClear) {
- // GitHub issue #310: https://github.com/google/protobuf/issues/310
- Arena arena;
- TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);
- arena_message->mutable_optional_nested_message()->set_bb(118);
- // This should not crash, but prior to the bugfix, it tried to use `operator
- // delete` the nested message (which is on the arena):
- arena_message->Clear();
-}
-
-TEST(Proto3ArenaTest, MessageFieldClearViaReflection) {
- Arena arena;
- TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);
- const Reflection* r = message->GetReflection();
- const Descriptor* d = message->GetDescriptor();
- const FieldDescriptor* msg_field = d->FindFieldByName(
- "optional_nested_message");
-
- message->mutable_optional_nested_message()->set_bb(1);
- r->ClearField(message, msg_field);
- EXPECT_FALSE(message->has_optional_nested_message());
- EXPECT_EQ(0, message->optional_nested_message().bb());
-}
-
} // namespace
} // namespace protobuf
} // namespace google
« no previous file with comments | « third_party/protobuf/src/google/protobuf/metadata.h ('k') | third_party/protobuf/src/google/protobuf/proto3_lite_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698