Make custom option able to work for -f-no-rtti; Fix remaining death tests for gtest 1.6

pull/3335/head
liujisi@google.com 12 years ago
parent e34f1f63b6
commit f5d5b4de92
  1. 14
      src/google/protobuf/compiler/cpp/cpp_unittest.cc
  2. 6
      src/google/protobuf/descriptor.cc
  3. 8
      src/google/protobuf/extension_set_unittest.cc
  4. 4
      src/google/protobuf/io/printer_unittest.cc
  5. 12
      src/google/protobuf/io/tokenizer_unittest.cc
  6. 2
      src/google/protobuf/repeated_field_unittest.cc

@ -382,6 +382,8 @@ TEST(GeneratedMessageTest, StringCharStarLength) {
}
#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \
!defined(GOOGLE_PROTOBUF_NO_RTTI)
TEST(GeneratedMessageTest, CopyFrom) {
unittest::TestAllTypes message1, message2;
@ -393,7 +395,7 @@ TEST(GeneratedMessageTest, CopyFrom) {
message2.CopyFrom(message2);
TestUtil::ExpectAllFieldsSet(message2);
}
#endif
TEST(GeneratedMessageTest, SwapWithEmpty) {
unittest::TestAllTypes message1, message2;
@ -493,6 +495,8 @@ TEST(GeneratedMessageTest, CopyAssignmentOperator) {
TestUtil::ExpectAllFieldsSet(message2);
}
#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \
!defined(GOOGLE_PROTOBUF_NO_RTTI)
TEST(GeneratedMessageTest, UpcastCopyFrom) {
// Test the CopyFrom method that takes in the generic const Message&
// parameter.
@ -505,6 +509,7 @@ TEST(GeneratedMessageTest, UpcastCopyFrom) {
TestUtil::ExpectAllFieldsSet(message2);
}
#endif
#ifndef PROTOBUF_TEST_NO_DESCRIPTORS
@ -530,6 +535,8 @@ TEST(GeneratedMessageTest, DynamicMessageCopyFrom) {
#endif // !PROTOBUF_TEST_NO_DESCRIPTORS
#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \
!defined(GOOGLE_PROTOBUF_NO_RTTI)
TEST(GeneratedMessageTest, NonEmptyMergeFrom) {
// Test merging with a non-empty message. Code is a modified form
// of that found in google/protobuf/reflection_ops_unittest.cc.
@ -566,6 +573,7 @@ TEST(GeneratedMessageTest, MergeFromSelf) {
}
#endif // PROTOBUF_HAS_DEATH_TEST
#endif // !PROTOBUF_TEST_NO_DESCRIPTORS || !GOOGLE_PROTOBUF_NO_RTTI
// Test the generated SerializeWithCachedSizesToArray(),
TEST(GeneratedMessageTest, SerializationToArray) {
@ -1199,7 +1207,7 @@ TEST_F(GeneratedServiceTest, CallMethod) {
TEST_F(GeneratedServiceTest, CallMethodTypeFailure) {
// Verify death if we call Foo() with Bar's message types.
#ifdef GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet
#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet
EXPECT_DEBUG_DEATH(
mock_service_.CallMethod(foo_, &mock_controller_,
&foo_request_, &bar_response_, done_.get()),
@ -1210,7 +1218,7 @@ TEST_F(GeneratedServiceTest, CallMethodTypeFailure) {
mock_service_.CallMethod(foo_, &mock_controller_,
&bar_request_, &foo_response_, done_.get()),
"dynamic_cast");
#endif // GTEST_HAS_DEATH_TEST
#endif // PROTOBUF_HAS_DEATH_TEST
}
TEST_F(GeneratedServiceTest, GetPrototypes) {

@ -2987,7 +2987,11 @@ template<class DescriptorT> void DescriptorBuilder::AllocateOptionsImpl(
// tables_->AllocateMessage<typename DescriptorT::OptionsType>();
typename DescriptorT::OptionsType* const dummy = NULL;
typename DescriptorT::OptionsType* options = tables_->AllocateMessage(dummy);
options->CopyFrom(orig_options);
// Avoid using MergeFrom()/CopyFrom() in this class to make it -fno-rtti
// friendly. Without RTTI, MergeFrom() and CopyFrom() will fallback to the
// reflection based method, which requires the Descriptor. However, we are in
// the middle of building the descriptors, thus the deadlock.
options->ParseFromString(orig_options.SerializeAsString());
descriptor->options_ = options;
// Don't add to options_to_interpret_ unless there were uninterpreted

@ -550,7 +550,7 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) {
}
}
#ifdef GTEST_HAS_DEATH_TEST
#ifdef PROTOBUF_HAS_DEATH_TEST
TEST(ExtensionSetTest, InvalidEnumDeath) {
unittest::TestAllExtensions message;
@ -560,7 +560,7 @@ TEST(ExtensionSetTest, InvalidEnumDeath) {
"IsValid");
}
#endif // GTEST_HAS_DEATH_TEST
#endif // PROTOBUF_HAS_DEATH_TEST
TEST(ExtensionSetTest, DynamicExtensions) {
// Test adding a dynamic extension to a compiled-in message object.
@ -695,7 +695,11 @@ TEST(ExtensionSetTest, DynamicExtensions) {
const Message& sub_message =
message.GetReflection()->GetMessage(message, message_extension);
const unittest::ForeignMessage* typed_sub_message =
#ifdef GOOGLE_PROTOBUF_NO_RTTI
static_cast<const unittest::ForeignMessage*>(&sub_message);
#else
dynamic_cast<const unittest::ForeignMessage*>(&sub_message);
#endif
ASSERT_TRUE(typed_sub_message != NULL);
EXPECT_EQ(456, typed_sub_message->c());
}

@ -220,7 +220,7 @@ TEST(Printer, Indenting) {
}
// Death tests do not work on Windows as of yet.
#ifdef GTEST_HAS_DEATH_TEST
#ifdef PROTOBUF_HAS_DEATH_TEST
TEST(Printer, Death) {
char buffer[8192];
@ -231,7 +231,7 @@ TEST(Printer, Death) {
EXPECT_DEBUG_DEATH(printer.Print("$unclosed"), "Unclosed variable name");
EXPECT_DEBUG_DEATH(printer.Outdent(), "without matching Indent");
}
#endif // GTEST_HAS_DEATH_TEST
#endif // PROTOBUF__HAS_DEATH_TEST
TEST(Printer, WriteFailurePartial) {
char buffer[17];

@ -741,7 +741,7 @@ TEST_F(TokenizerTest, ParseInteger) {
EXPECT_EQ(0, ParseInteger("0x"));
uint64 i;
#ifdef GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet
#ifdef PROTOBUF_HASDEATH_TEST // death tests do not work on Windows yet
// Test invalid integers that will never be tokenized as integers.
EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("zxy", kuint64max, &i),
"passed text that could not have been tokenized as an integer");
@ -753,7 +753,7 @@ TEST_F(TokenizerTest, ParseInteger) {
"passed text that could not have been tokenized as an integer");
EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("-1", kuint64max, &i),
"passed text that could not have been tokenized as an integer");
#endif // GTEST_HAS_DEATH_TEST
#endif // PROTOBUF_HASDEATH_TEST
// Test overflows.
EXPECT_TRUE (Tokenizer::ParseInteger("0", 0, &i));
@ -796,7 +796,7 @@ TEST_F(TokenizerTest, ParseFloat) {
EXPECT_EQ( 0.0, Tokenizer::ParseFloat("1e-9999999999999999999999999999"));
EXPECT_EQ(HUGE_VAL, Tokenizer::ParseFloat("1e+9999999999999999999999999999"));
#ifdef GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet
#ifdef PROTOBUF_HASDEATH_TEST // death tests do not work on Windows yet
// Test invalid integers that will never be tokenized as integers.
EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat("zxy"),
"passed text that could not have been tokenized as a float");
@ -804,7 +804,7 @@ TEST_F(TokenizerTest, ParseFloat) {
"passed text that could not have been tokenized as a float");
EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat("-1.0"),
"passed text that could not have been tokenized as a float");
#endif // GTEST_HAS_DEATH_TEST
#endif // PROTOBUF_HASDEATH_TEST
}
TEST_F(TokenizerTest, ParseString) {
@ -843,10 +843,10 @@ TEST_F(TokenizerTest, ParseString) {
EXPECT_EQ("u0", output);
// Test invalid strings that will never be tokenized as strings.
#ifdef GTEST_HAS_DEATH_TEST // death tests do not work on Windows yet
#ifdef PROTOBUF_HASDEATH_TEST // death tests do not work on Windows yet
EXPECT_DEBUG_DEATH(Tokenizer::ParseString("", &output),
"passed text that could not have been tokenized as a string");
#endif // GTEST_HAS_DEATH_TEST
#endif // PROTOBUF_HASDEATH_TEST
}
TEST_F(TokenizerTest, ParseStringAppend) {

@ -331,7 +331,7 @@ TEST(RepeatedField, Truncate) {
// Truncations that don't change the size are allowed, but growing is not
// allowed.
field.Truncate(field.size());
#ifdef GTEST_HAS_DEATH_TEST
#ifdef PROTOBUF_HAS_DEATH_TEST
EXPECT_DEBUG_DEATH(field.Truncate(field.size() + 1), "new_size");
#endif
}

Loading…
Cancel
Save