diff options
Diffstat (limited to 'src/google/protobuf/reflection_ops_unittest.cc')
-rw-r--r-- | src/google/protobuf/reflection_ops_unittest.cc | 78 |
1 files changed, 4 insertions, 74 deletions
diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc index 32740ea..1cd56f1 100644 --- a/src/google/protobuf/reflection_ops_unittest.cc +++ b/src/google/protobuf/reflection_ops_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 @@ -78,18 +78,6 @@ TEST(ReflectionOpsTest, CopyExtensions) { TestUtil::ExpectAllExtensionsSet(message2); } -TEST(ReflectionOpsTest, CopyOneof) { - unittest::TestOneof2 message, message2; - TestUtil::SetOneof1(&message); - ReflectionOps::Copy(message, &message2); - TestUtil::ExpectOneofSet1(message2); - - TestUtil::SetOneof2(&message); - TestUtil::ExpectOneofSet2(message); - ReflectionOps::Copy(message, &message2); - TestUtil::ExpectOneofSet2(message2); -} - TEST(ReflectionOpsTest, Merge) { // Note: Copy is implemented in terms of Merge() so technically the Copy // test already tested most of this. @@ -164,25 +152,7 @@ TEST(ReflectionOpsTest, MergeUnknown) { EXPECT_EQ(2, message1.unknown_fields().field(1).varint()); } -TEST(ReflectionOpsTest, MergeOneof) { - unittest::TestOneof2 message1, message2; - TestUtil::SetOneof1(&message1); - - // Merge to empty message - ReflectionOps::Merge(message1, &message2); - TestUtil::ExpectOneofSet1(message2); - - // Merge with the same oneof fields - ReflectionOps::Merge(message1, &message2); - TestUtil::ExpectOneofSet1(message2); - - // Merge with different oneof fields - TestUtil::SetOneof2(&message1); - ReflectionOps::Merge(message1, &message2); - TestUtil::ExpectOneofSet2(message2); -} - -#ifdef PROTOBUF_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST TEST(ReflectionOpsTest, MergeFromSelf) { // Note: Copy is implemented in terms of Merge() so technically the Copy @@ -195,7 +165,7 @@ TEST(ReflectionOpsTest, MergeFromSelf) { "&from"); } -#endif // PROTOBUF_HAS_DEATH_TEST +#endif // GTEST_HAS_DEATH_TEST TEST(ReflectionOpsTest, Clear) { unittest::TestAllTypes message; @@ -250,23 +220,6 @@ TEST(ReflectionOpsTest, ClearUnknown) { EXPECT_EQ(0, message.unknown_fields().field_count()); } -TEST(ReflectionOpsTest, ClearOneof) { - unittest::TestOneof2 message; - - TestUtil::ExpectOneofClear(message); - TestUtil::SetOneof1(&message); - TestUtil::ExpectOneofSet1(message); - ReflectionOps::Clear(&message); - TestUtil::ExpectOneofClear(message); - - TestUtil::SetOneof1(&message); - TestUtil::ExpectOneofSet1(message); - TestUtil::SetOneof2(&message); - TestUtil::ExpectOneofSet2(message); - ReflectionOps::Clear(&message); - TestUtil::ExpectOneofClear(message); -} - TEST(ReflectionOpsTest, DiscardUnknownFields) { unittest::TestAllTypes message; TestUtil::SetAllFields(&message); @@ -401,26 +354,10 @@ TEST(ReflectionOpsTest, ExtensionIsInitialized) { EXPECT_TRUE(ReflectionOps::IsInitialized(message)); } -TEST(ReflectionOpsTest, OneofIsInitialized) { - unittest::TestRequiredOneof message; - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); - - message.mutable_foo_message(); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - - message.set_foo_int(1); - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); - - message.mutable_foo_message(); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - message.mutable_foo_message()->set_required_double(0.1); - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); -} - static string FindInitializationErrors(const Message& message) { vector<string> errors; ReflectionOps::FindInitializationErrors(message, "", &errors); - return Join(errors, ","); + return JoinStrings(errors, ","); } TEST(ReflectionOpsTest, FindInitializationErrors) { @@ -462,13 +399,6 @@ TEST(ReflectionOpsTest, FindExtensionInitializationErrors) { FindInitializationErrors(message)); } -TEST(ReflectionOpsTest, FindOneofInitializationErrors) { - unittest::TestRequiredOneof message; - message.mutable_foo_message(); - EXPECT_EQ("foo_message.required_double", - FindInitializationErrors(message)); -} - } // namespace } // namespace internal } // namespace protobuf |