Commit 1d32532e authored by liujisi@google.com's avatar liujisi@google.com

Update gtest to 1.6; Disable death tests when exceptions are enabled.

parent e7194890
...@@ -556,7 +556,7 @@ TEST(GeneratedMessageTest, NonEmptyMergeFrom) { ...@@ -556,7 +556,7 @@ TEST(GeneratedMessageTest, NonEmptyMergeFrom) {
TestUtil::ExpectAllFieldsSet(message1); TestUtil::ExpectAllFieldsSet(message1);
} }
#ifdef GTEST_HAS_DEATH_TEST #ifdef PROTOBUF_HAS_DEATH_TEST
TEST(GeneratedMessageTest, MergeFromSelf) { TEST(GeneratedMessageTest, MergeFromSelf) {
unittest::TestAllTypes message; unittest::TestAllTypes message;
...@@ -565,7 +565,7 @@ TEST(GeneratedMessageTest, MergeFromSelf) { ...@@ -565,7 +565,7 @@ TEST(GeneratedMessageTest, MergeFromSelf) {
"&from"); "&from");
} }
#endif // GTEST_HAS_DEATH_TEST #endif // PROTOBUF_HAS_DEATH_TEST
// Test the generated SerializeWithCachedSizesToArray(), // Test the generated SerializeWithCachedSizesToArray(),
TEST(GeneratedMessageTest, SerializationToArray) { TEST(GeneratedMessageTest, SerializationToArray) {
......
...@@ -427,7 +427,7 @@ TEST(GeneratedMessageReflectionTest, ReleaseExtensionMessageTest) { ...@@ -427,7 +427,7 @@ TEST(GeneratedMessageReflectionTest, ReleaseExtensionMessageTest) {
TestUtil::ExpectAllExtensionsSet(message); TestUtil::ExpectAllExtensionsSet(message);
} }
#ifdef GTEST_HAS_DEATH_TEST #ifdef PROTOBUF_HAS_DEATH_TEST
TEST(GeneratedMessageReflectionTest, UsageErrors) { TEST(GeneratedMessageReflectionTest, UsageErrors) {
unittest::TestAllTypes message; unittest::TestAllTypes message;
...@@ -476,7 +476,7 @@ TEST(GeneratedMessageReflectionTest, UsageErrors) { ...@@ -476,7 +476,7 @@ TEST(GeneratedMessageReflectionTest, UsageErrors) {
#undef f #undef f
} }
#endif // GTEST_HAS_DEATH_TEST #endif // PROTOBUF_HAS_DEATH_TEST
} // namespace } // namespace
......
...@@ -205,7 +205,7 @@ TEST(MessageTest, InitializationErrorString) { ...@@ -205,7 +205,7 @@ TEST(MessageTest, InitializationErrorString) {
EXPECT_EQ("a, b, c", message.InitializationErrorString()); EXPECT_EQ("a, b, c", message.InitializationErrorString());
} }
#ifdef GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet. #ifdef PROTOBUF_HAS_DEATH_TEST
TEST(MessageTest, SerializeFailsIfNotInitialized) { TEST(MessageTest, SerializeFailsIfNotInitialized) {
unittest::TestRequired message; unittest::TestRequired message;
...@@ -222,7 +222,7 @@ TEST(MessageTest, CheckInitialized) { ...@@ -222,7 +222,7 @@ TEST(MessageTest, CheckInitialized) {
"fields: a, b, c"); "fields: a, b, c");
} }
#endif // GTEST_HAS_DEATH_TEST #endif // PROTOBUF_HAS_DEATH_TEST
TEST(MessageTest, BypassInitializationCheckOnSerialize) { TEST(MessageTest, BypassInitializationCheckOnSerialize) {
unittest::TestRequired message; unittest::TestRequired message;
......
...@@ -152,7 +152,7 @@ TEST(ReflectionOpsTest, MergeUnknown) { ...@@ -152,7 +152,7 @@ TEST(ReflectionOpsTest, MergeUnknown) {
EXPECT_EQ(2, message1.unknown_fields().field(1).varint()); EXPECT_EQ(2, message1.unknown_fields().field(1).varint());
} }
#ifdef GTEST_HAS_DEATH_TEST #ifdef PROTOBUF_HAS_DEATH_TEST
TEST(ReflectionOpsTest, MergeFromSelf) { TEST(ReflectionOpsTest, MergeFromSelf) {
// Note: Copy is implemented in terms of Merge() so technically the Copy // Note: Copy is implemented in terms of Merge() so technically the Copy
...@@ -165,7 +165,7 @@ TEST(ReflectionOpsTest, MergeFromSelf) { ...@@ -165,7 +165,7 @@ TEST(ReflectionOpsTest, MergeFromSelf) {
"&from"); "&from");
} }
#endif // GTEST_HAS_DEATH_TEST #endif // PROTOBUF_HAS_DEATH_TEST
TEST(ReflectionOpsTest, Clear) { TEST(ReflectionOpsTest, Clear) {
unittest::TestAllTypes message; unittest::TestAllTypes message;
......
...@@ -144,6 +144,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { ...@@ -144,6 +144,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) {
EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, 7)); EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, 7));
} }
#ifdef PROTOBUF_HAS_DEATH_TEST
// Make sure types are checked correctly at runtime. // Make sure types are checked correctly at runtime.
const FieldDescriptor* fd_optional_int32 = const FieldDescriptor* fd_optional_int32 =
desc->FindFieldByName("optional_int32"); desc->FindFieldByName("optional_int32");
...@@ -153,6 +154,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { ...@@ -153,6 +154,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) {
message, fd_repeated_int32), "not the right type"); message, fd_repeated_int32), "not the right type");
EXPECT_DEATH(refl->GetRepeatedPtrField<TestAllTypes>( EXPECT_DEATH(refl->GetRepeatedPtrField<TestAllTypes>(
message, fd_repeated_foreign_message), "wrong submessage type"); message, fd_repeated_foreign_message), "wrong submessage type");
#endif // PROTOBUF_HAS_DEATH_TEST
} }
......
...@@ -38,6 +38,11 @@ ...@@ -38,6 +38,11 @@
#include <vector> #include <vector>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
// Disable death tests if we use exceptions in CHECK().
#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST)
#define PROTOBUF_HAS_DEATH_TEST
#endif
namespace google { namespace google {
namespace protobuf { namespace protobuf {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment