aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest_unittest.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-08-07 06:47:47 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-08-07 06:47:47 +0000
commited8500b341c473ecf46acd13951ae5b4e3acc780 (patch)
treeca41796e67c988e8985cc084e1c6136aa609df39 /test/gtest_unittest.cc
parent18c31d64e120919e8e04df3035234b9afe8eb6d9 (diff)
downloadgoogletest-ed8500b341c473ecf46acd13951ae5b4e3acc780.tar.gz
googletest-ed8500b341c473ecf46acd13951ae5b4e3acc780.tar.bz2
googletest-ed8500b341c473ecf46acd13951ae5b4e3acc780.zip
Implements EXPECT_DEATH_IF_SUPPORTED (by Vlad Losev); Fixes compatibility with Symbian (by Araceli Checa); Removes GetCapturedStderr()'s dependency on std::string (by Vlad Losev).
Diffstat (limited to 'test/gtest_unittest.cc')
-rw-r--r--test/gtest_unittest.cc44
1 files changed, 15 insertions, 29 deletions
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index 4eb098e7..2c087209 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -78,16 +78,6 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <map>
#endif
-// GTEST_EXPECT_DEATH_IF_SUPPORTED_(statement, regex) expands to a
-// real death test if death tests are supported; otherwise it expands
-// to empty.
-#if GTEST_HAS_DEATH_TEST
-#define GTEST_EXPECT_DEATH_IF_SUPPORTED_(statement, regex) \
- EXPECT_DEATH(statement, regex)
-#else
-#define GTEST_EXPECT_DEATH_IF_SUPPORTED_(statement, regex)
-#endif
-
namespace testing {
namespace internal {
const char* FormatTimeInMillisAsSeconds(TimeInMillis ms);
@@ -630,7 +620,7 @@ TEST(VectorDeathTest, Erase) {
Vector<int> a;
// Tests erasing from an empty vector.
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
a.Erase(0),
"Invalid Vector index 0: must be in range \\[0, -1\\]\\.");
@@ -646,10 +636,10 @@ TEST(VectorDeathTest, Erase) {
a1.PushBack(1);
a1.PushBack(2);
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
a1.Erase(3),
"Invalid Vector index 3: must be in range \\[0, 2\\]\\.");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
a1.Erase(-1),
"Invalid Vector index -1: must be in range \\[0, 2\\]\\.");
@@ -697,10 +687,10 @@ TEST(ListDeathTest, GetElement) {
EXPECT_EQ(0, a.GetElement(0));
EXPECT_EQ(1, a.GetElement(1));
EXPECT_EQ(2, a.GetElement(2));
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
a.GetElement(3),
"Invalid Vector index 3: must be in range \\[0, 2\\]\\.");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
a.GetElement(-1),
"Invalid Vector index -1: must be in range \\[0, 2\\]\\.");
}
@@ -1368,10 +1358,10 @@ typedef TestResultTest TestResultDeathTest;
TEST_F(TestResultDeathTest, GetTestPartResult) {
CompareTestPartResult(*pr1, r2->GetTestPartResult(0));
CompareTestPartResult(*pr2, r2->GetTestPartResult(1));
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
r2->GetTestPartResult(2),
"Invalid Vector index 2: must be in range \\[0, 1\\]\\.");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
r2->GetTestPartResult(-1),
"Invalid Vector index -1: must be in range \\[0, 1\\]\\.");
}
@@ -1455,10 +1445,10 @@ TEST(TestResultPropertyDeathTest, GetTestProperty) {
EXPECT_STREQ("key_3", fetched_property_3.key());
EXPECT_STREQ("3", fetched_property_3.value());
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
test_result.GetTestProperty(3),
"Invalid Vector index 3: must be in range \\[0, 2\\]\\.");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
test_result.GetTestProperty(-1),
"Invalid Vector index -1: must be in range \\[0, 2\\]\\.");
}
@@ -1737,7 +1727,7 @@ TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) {
// if the variable is not an Int32.
TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "xxx");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "VAR", 123),
".*");
}
@@ -1746,7 +1736,7 @@ TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
// if the variable cannot be represnted by an Int32.
TEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) {
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "1234567891234567891234");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(
+ EXPECT_DEATH_IF_SUPPORTED(
Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "VAR", 123),
".*");
}
@@ -1824,23 +1814,19 @@ typedef ShouldShardTest ShouldShardDeathTest;
TEST_F(ShouldShardDeathTest, AbortsWhenShardingEnvVarsAreInvalid) {
SetEnv(index_var_, "4");
SetEnv(total_var_, "4");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(ShouldShard(total_var_, index_var_, false),
- ".*");
+ EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*");
SetEnv(index_var_, "4");
SetEnv(total_var_, "-2");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(ShouldShard(total_var_, index_var_, false),
- ".*");
+ EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*");
SetEnv(index_var_, "5");
SetEnv(total_var_, "");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(ShouldShard(total_var_, index_var_, false),
- ".*");
+ EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*");
SetEnv(index_var_, "");
SetEnv(total_var_, "5");
- GTEST_EXPECT_DEATH_IF_SUPPORTED_(ShouldShard(total_var_, index_var_, false),
- ".*");
+ EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), ".*");
}
// Tests that ShouldRunTestOnShard is a partition when 5