Index: third_party/protobuf/src/google/protobuf/dynamic_message_unittest.cc |
diff --git a/third_party/protobuf/src/google/protobuf/dynamic_message_unittest.cc b/third_party/protobuf/src/google/protobuf/dynamic_message_unittest.cc |
index 522a092aa82d7fe81ce4b0fb58aa549d9a7ee678..e46159702bb486028dfdbbef936730f68b7aa460 100644 |
--- a/third_party/protobuf/src/google/protobuf/dynamic_message_unittest.cc |
+++ b/third_party/protobuf/src/google/protobuf/dynamic_message_unittest.cc |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+// http://code.google.com/p/protobuf/ |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -46,7 +46,6 @@ |
#include <google/protobuf/descriptor.pb.h> |
#include <google/protobuf/test_util.h> |
#include <google/protobuf/unittest.pb.h> |
-#include <google/protobuf/unittest_no_field_presence.pb.h> |
#include <google/protobuf/testing/googletest.h> |
#include <gtest/gtest.h> |
@@ -64,10 +63,6 @@ class DynamicMessageTest : public testing::Test { |
const Message* extensions_prototype_; |
const Descriptor* packed_descriptor_; |
const Message* packed_prototype_; |
- const Descriptor* oneof_descriptor_; |
- const Message* oneof_prototype_; |
- const Descriptor* proto3_descriptor_; |
- const Message* proto3_prototype_; |
DynamicMessageTest(): factory_(&pool_) {} |
@@ -79,20 +74,16 @@ class DynamicMessageTest : public testing::Test { |
FileDescriptorProto unittest_file; |
FileDescriptorProto unittest_import_file; |
FileDescriptorProto unittest_import_public_file; |
- FileDescriptorProto unittest_no_field_presence_file; |
unittest::TestAllTypes::descriptor()->file()->CopyTo(&unittest_file); |
unittest_import::ImportMessage::descriptor()->file()->CopyTo( |
&unittest_import_file); |
unittest_import::PublicImportMessage::descriptor()->file()->CopyTo( |
&unittest_import_public_file); |
- proto2_nofieldpresence_unittest::TestAllTypes::descriptor()-> |
- file()->CopyTo(&unittest_no_field_presence_file); |
ASSERT_TRUE(pool_.BuildFile(unittest_import_public_file) != NULL); |
ASSERT_TRUE(pool_.BuildFile(unittest_import_file) != NULL); |
ASSERT_TRUE(pool_.BuildFile(unittest_file) != NULL); |
- ASSERT_TRUE(pool_.BuildFile(unittest_no_field_presence_file) != NULL); |
descriptor_ = pool_.FindMessageTypeByName("protobuf_unittest.TestAllTypes"); |
ASSERT_TRUE(descriptor_ != NULL); |
@@ -107,17 +98,6 @@ class DynamicMessageTest : public testing::Test { |
pool_.FindMessageTypeByName("protobuf_unittest.TestPackedTypes"); |
ASSERT_TRUE(packed_descriptor_ != NULL); |
packed_prototype_ = factory_.GetPrototype(packed_descriptor_); |
- |
- oneof_descriptor_ = |
- pool_.FindMessageTypeByName("protobuf_unittest.TestOneof2"); |
- ASSERT_TRUE(oneof_descriptor_ != NULL); |
- oneof_prototype_ = factory_.GetPrototype(oneof_descriptor_); |
- |
- proto3_descriptor_ = |
- pool_.FindMessageTypeByName( |
- "proto2_nofieldpresence_unittest.TestAllTypes"); |
- ASSERT_TRUE(proto3_descriptor_ != NULL); |
- proto3_prototype_ = factory_.GetPrototype(proto3_descriptor_); |
} |
}; |
@@ -167,63 +147,6 @@ TEST_F(DynamicMessageTest, PackedFields) { |
reflection_tester.ExpectPackedFieldsSetViaReflection(*message); |
} |
-TEST_F(DynamicMessageTest, Oneof) { |
- // Check that oneof fields work properly. |
- scoped_ptr<Message> message(oneof_prototype_->New()); |
- |
- // Check default values. |
- const Descriptor* descriptor = message->GetDescriptor(); |
- const Reflection* reflection = message->GetReflection(); |
- EXPECT_EQ(0, reflection->GetInt32( |
- *message, descriptor->FindFieldByName("foo_int"))); |
- EXPECT_EQ("", reflection->GetString( |
- *message, descriptor->FindFieldByName("foo_string"))); |
- EXPECT_EQ("", reflection->GetString( |
- *message, descriptor->FindFieldByName("foo_cord"))); |
- EXPECT_EQ("", reflection->GetString( |
- *message, descriptor->FindFieldByName("foo_string_piece"))); |
- EXPECT_EQ("", reflection->GetString( |
- *message, descriptor->FindFieldByName("foo_bytes"))); |
- EXPECT_EQ(unittest::TestOneof2::FOO, reflection->GetEnum( |
- *message, descriptor->FindFieldByName("foo_enum"))->number()); |
- const Descriptor* nested_descriptor; |
- const Message* nested_prototype; |
- nested_descriptor = |
- pool_.FindMessageTypeByName("protobuf_unittest.TestOneof2.NestedMessage"); |
- nested_prototype = factory_.GetPrototype(nested_descriptor); |
- EXPECT_EQ(nested_prototype, |
- &reflection->GetMessage( |
- *message, descriptor->FindFieldByName("foo_message"))); |
- const Descriptor* foogroup_descriptor; |
- const Message* foogroup_prototype; |
- foogroup_descriptor = |
- pool_.FindMessageTypeByName("protobuf_unittest.TestOneof2.FooGroup"); |
- foogroup_prototype = factory_.GetPrototype(foogroup_descriptor); |
- EXPECT_EQ(foogroup_prototype, |
- &reflection->GetMessage( |
- *message, descriptor->FindFieldByName("foogroup"))); |
- EXPECT_NE(foogroup_prototype, |
- &reflection->GetMessage( |
- *message, descriptor->FindFieldByName("foo_lazy_message"))); |
- EXPECT_EQ(5, reflection->GetInt32( |
- *message, descriptor->FindFieldByName("bar_int"))); |
- EXPECT_EQ("STRING", reflection->GetString( |
- *message, descriptor->FindFieldByName("bar_string"))); |
- EXPECT_EQ("CORD", reflection->GetString( |
- *message, descriptor->FindFieldByName("bar_cord"))); |
- EXPECT_EQ("SPIECE", reflection->GetString( |
- *message, descriptor->FindFieldByName("bar_string_piece"))); |
- EXPECT_EQ("BYTES", reflection->GetString( |
- *message, descriptor->FindFieldByName("bar_bytes"))); |
- EXPECT_EQ(unittest::TestOneof2::BAR, reflection->GetEnum( |
- *message, descriptor->FindFieldByName("bar_enum"))->number()); |
- |
- // Check set functions. |
- TestUtil::ReflectionTester reflection_tester(oneof_descriptor_); |
- reflection_tester.SetOneofViaReflection(message.get()); |
- reflection_tester.ExpectOneofSetViaReflection(*message); |
-} |
- |
TEST_F(DynamicMessageTest, SpaceUsed) { |
// Test that SpaceUsed() works properly |
@@ -239,47 +162,5 @@ TEST_F(DynamicMessageTest, SpaceUsed) { |
EXPECT_LT(initial_space_used, message->SpaceUsed()); |
} |
-TEST_F(DynamicMessageTest, Arena) { |
- Arena arena; |
- Message* message = prototype_->New(&arena); |
- (void)message; // avoid unused-variable error. |
- // Return without freeing: should not leak. |
-} |
- |
-TEST_F(DynamicMessageTest, Proto3) { |
- Message* message = proto3_prototype_->New(); |
- const Reflection* refl = message->GetReflection(); |
- const Descriptor* desc = message->GetDescriptor(); |
- |
- // Just test a single primtive and single message field here to make sure we |
- // are getting the no-field-presence semantics elsewhere. DynamicMessage uses |
- // GeneratedMessageReflection under the hood, so the rest should be fine as |
- // long as GMR recognizes that we're using a proto3 message. |
- const FieldDescriptor* optional_int32 = |
- desc->FindFieldByName("optional_int32"); |
- const FieldDescriptor* optional_msg = |
- desc->FindFieldByName("optional_nested_message"); |
- EXPECT_TRUE(optional_int32 != NULL); |
- EXPECT_TRUE(optional_msg != NULL); |
- |
- EXPECT_EQ(false, refl->HasField(*message, optional_int32)); |
- refl->SetInt32(message, optional_int32, 42); |
- EXPECT_EQ(true, refl->HasField(*message, optional_int32)); |
- refl->SetInt32(message, optional_int32, 0); |
- EXPECT_EQ(false, refl->HasField(*message, optional_int32)); |
- |
- EXPECT_EQ(false, refl->HasField(*message, optional_msg)); |
- refl->MutableMessage(message, optional_msg); |
- EXPECT_EQ(true, refl->HasField(*message, optional_msg)); |
- delete refl->ReleaseMessage(message, optional_msg); |
- EXPECT_EQ(false, refl->HasField(*message, optional_msg)); |
- |
- // Also ensure that the default instance handles field presence properly. |
- EXPECT_EQ(false, refl->HasField(*proto3_prototype_, optional_msg)); |
- |
- delete message; |
-} |
- |
- |
} // namespace protobuf |
} // namespace google |