|
|
|
@ -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
|
|
|
|
|