Commit 0599a7b8 authored by misterg's avatar misterg Committed by Gennadiy Civil
Browse files

Googletest export

Change tests to use new Test Suite API

PiperOrigin-RevId: 228908894
parent 2edadced
...@@ -120,9 +120,9 @@ TEST_P(MyParamTest, ShouldPass) { ...@@ -120,9 +120,9 @@ TEST_P(MyParamTest, ShouldPass) {
GTEST_CHECK_INT_EQ_(g_param_test_count % kNumberOfParamTests, GetParam()); GTEST_CHECK_INT_EQ_(g_param_test_count % kNumberOfParamTests, GetParam());
g_param_test_count++; g_param_test_count++;
} }
INSTANTIATE_TEST_CASE_P(MyParamSequence, INSTANTIATE_TEST_SUITE_P(MyParamSequence,
MyParamTest, MyParamTest,
testing::Range(0, kNumberOfParamTests)); testing::Range(0, kNumberOfParamTests));
// Resets the count for each test. // Resets the count for each test.
void ResetCounts() { void ResetCounts() {
......
...@@ -1570,7 +1570,7 @@ class GTestFlagSaverTest : public Test { ...@@ -1570,7 +1570,7 @@ class GTestFlagSaverTest : public Test {
// Saves the Google Test flags such that we can restore them later, and // Saves the Google Test flags such that we can restore them later, and
// then sets them to their default values. This will be called // then sets them to their default values. This will be called
// before the first test in this test case is run. // before the first test in this test case is run.
static void SetUpTestCase() { static void SetUpTestSuite() {
saver_ = new GTestFlagSaver; saver_ = new GTestFlagSaver;
GTEST_FLAG(also_run_disabled_tests) = false; GTEST_FLAG(also_run_disabled_tests) = false;
...@@ -1592,7 +1592,7 @@ class GTestFlagSaverTest : public Test { ...@@ -1592,7 +1592,7 @@ class GTestFlagSaverTest : public Test {
// Restores the Google Test flags that the tests have modified. This will // Restores the Google Test flags that the tests have modified. This will
// be called after the last test in this test case is run. // be called after the last test in this test case is run.
static void TearDownTestCase() { static void TearDownTestSuite() {
delete saver_; delete saver_;
saver_ = nullptr; saver_ = nullptr;
} }
...@@ -1956,7 +1956,7 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) { ...@@ -1956,7 +1956,7 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) {
// Test class, there are no separate tests for the following classes // Test class, there are no separate tests for the following classes
// (except for some trivial cases): // (except for some trivial cases):
// //
// TestCase, UnitTest, UnitTestResultPrinter. // TestSuite, UnitTest, UnitTestResultPrinter.
// //
// Similarly, there are no separate tests for the following macros: // Similarly, there are no separate tests for the following macros:
// //
...@@ -1990,7 +1990,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( ...@@ -1990,7 +1990,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
key); key);
} }
void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
const char* key) { const char* key) {
const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); const TestCase* test_case = UnitTest::GetInstance()->current_test_case();
ASSERT_TRUE(test_case != nullptr); ASSERT_TRUE(test_case != nullptr);
...@@ -1998,7 +1998,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( ...@@ -1998,7 +1998,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
test_case->ad_hoc_test_result(), key); test_case->ad_hoc_test_result(), key);
} }
void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
const char* key) { const char* key) {
ExpectNonFatalFailureRecordingPropertyWithReservedKey( ExpectNonFatalFailureRecordingPropertyWithReservedKey(
UnitTest::GetInstance()->ad_hoc_test_result(), key); UnitTest::GetInstance()->ad_hoc_test_result(), key);
...@@ -2010,29 +2010,30 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ...@@ -2010,29 +2010,30 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
class UnitTestRecordPropertyTest : class UnitTestRecordPropertyTest :
public testing::internal::UnitTestRecordPropertyTestHelper { public testing::internal::UnitTestRecordPropertyTestHelper {
public: public:
static void SetUpTestCase() { static void SetUpTestSuite() {
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
"disabled"); "disabled");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
"errors"); "errors");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
"failures"); "failures");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
"name"); "name");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
"tests"); "tests");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestSuite(
"time"); "time");
Test::RecordProperty("test_case_key_1", "1"); Test::RecordProperty("test_case_key_1", "1");
const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); const testing::TestSuite* test_suite =
ASSERT_TRUE(test_case != nullptr); UnitTest::GetInstance()->current_test_case();
ASSERT_TRUE(test_suite != nullptr);
ASSERT_EQ(1, test_case->ad_hoc_test_result().test_property_count()); ASSERT_EQ(1, test_suite->ad_hoc_test_result().test_property_count());
EXPECT_STREQ("test_case_key_1", EXPECT_STREQ("test_case_key_1",
test_case->ad_hoc_test_result().GetTestProperty(0).key()); test_suite->ad_hoc_test_result().GetTestProperty(0).key());
EXPECT_STREQ("1", EXPECT_STREQ("1",
test_case->ad_hoc_test_result().GetTestProperty(0).value()); test_suite->ad_hoc_test_result().GetTestProperty(0).value());
} }
}; };
...@@ -2085,7 +2086,7 @@ TEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) { ...@@ -2085,7 +2086,7 @@ TEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) {
} }
TEST_F(UnitTestRecordPropertyTest, TEST_F(UnitTestRecordPropertyTest,
AddFailureInsideTestsWhenUsingTestCaseReservedKeys) { AddFailureInsideTestsWhenUsingTestSuiteReservedKeys) {
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
"name"); "name");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
...@@ -2111,21 +2112,21 @@ TEST_F(UnitTestRecordPropertyTest, ...@@ -2111,21 +2112,21 @@ TEST_F(UnitTestRecordPropertyTest,
class UnitTestRecordPropertyTestEnvironment : public Environment { class UnitTestRecordPropertyTestEnvironment : public Environment {
public: public:
void TearDown() override { void TearDown() override {
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"tests"); "tests");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"failures"); "failures");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"disabled"); "disabled");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"errors"); "errors");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"name"); "name");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"timestamp"); "timestamp");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"time"); "time");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase( ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestSuite(
"random_seed"); "random_seed");
} }
}; };
...@@ -3119,28 +3120,28 @@ TEST(DisabledTest, NotDISABLED_TestShouldRun) { ...@@ -3119,28 +3120,28 @@ TEST(DisabledTest, NotDISABLED_TestShouldRun) {
// A test case whose name starts with DISABLED_. // A test case whose name starts with DISABLED_.
// Should not run. // Should not run.
TEST(DISABLED_TestCase, TestShouldNotRun) { TEST(DISABLED_TestSuite, TestShouldNotRun) {
FAIL() << "Unexpected failure: Test in disabled test case should not be run."; FAIL() << "Unexpected failure: Test in disabled test case should not be run.";
} }
// A test case and test whose names start with DISABLED_. // A test case and test whose names start with DISABLED_.
// Should not run. // Should not run.
TEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) { TEST(DISABLED_TestSuite, DISABLED_TestShouldNotRun) {
FAIL() << "Unexpected failure: Test in disabled test case should not be run."; FAIL() << "Unexpected failure: Test in disabled test case should not be run.";
} }
// Check that when all tests in a test case are disabled, SetUpTestCase() and // Check that when all tests in a test case are disabled, SetUpTestSuite() and
// TearDownTestCase() are not called. // TearDownTestSuite() are not called.
class DisabledTestsTest : public Test { class DisabledTestsTest : public Test {
protected: protected:
static void SetUpTestCase() { static void SetUpTestSuite() {
FAIL() << "Unexpected failure: All tests disabled in test case. " FAIL() << "Unexpected failure: All tests disabled in test case. "
"SetUpTestCase() should not be called."; "SetUpTestSuite() should not be called.";
} }
static void TearDownTestCase() { static void TearDownTestSuite() {
FAIL() << "Unexpected failure: All tests disabled in test case. " FAIL() << "Unexpected failure: All tests disabled in test case. "
"TearDownTestCase() should not be called."; "TearDownTestSuite() should not be called.";
} }
}; };
...@@ -3161,7 +3162,7 @@ class TypedTest : public Test { ...@@ -3161,7 +3162,7 @@ class TypedTest : public Test {
}; };
typedef testing::Types<int, double> NumericTypes; typedef testing::Types<int, double> NumericTypes;
TYPED_TEST_CASE(TypedTest, NumericTypes); TYPED_TEST_SUITE(TypedTest, NumericTypes);
TYPED_TEST(TypedTest, DISABLED_ShouldNotRun) { TYPED_TEST(TypedTest, DISABLED_ShouldNotRun) {
FAIL() << "Unexpected failure: Disabled typed test should not run."; FAIL() << "Unexpected failure: Disabled typed test should not run.";
...@@ -3171,7 +3172,7 @@ template <typename T> ...@@ -3171,7 +3172,7 @@ template <typename T>
class DISABLED_TypedTest : public Test { class DISABLED_TypedTest : public Test {
}; };
TYPED_TEST_CASE(DISABLED_TypedTest, NumericTypes); TYPED_TEST_SUITE(DISABLED_TypedTest, NumericTypes);
TYPED_TEST(DISABLED_TypedTest, ShouldNotRun) { TYPED_TEST(DISABLED_TypedTest, ShouldNotRun) {
FAIL() << "Unexpected failure: Disabled typed test should not run."; FAIL() << "Unexpected failure: Disabled typed test should not run.";
...@@ -3187,31 +3188,31 @@ template <typename T> ...@@ -3187,31 +3188,31 @@ template <typename T>
class TypedTestP : public Test { class TypedTestP : public Test {
}; };
TYPED_TEST_CASE_P(TypedTestP); TYPED_TEST_SUITE_P(TypedTestP);
TYPED_TEST_P(TypedTestP, DISABLED_ShouldNotRun) { TYPED_TEST_P(TypedTestP, DISABLED_ShouldNotRun) {
FAIL() << "Unexpected failure: " FAIL() << "Unexpected failure: "
<< "Disabled type-parameterized test should not run."; << "Disabled type-parameterized test should not run.";
} }
REGISTER_TYPED_TEST_CASE_P(TypedTestP, DISABLED_ShouldNotRun); REGISTER_TYPED_TEST_SUITE_P(TypedTestP, DISABLED_ShouldNotRun);
INSTANTIATE_TYPED_TEST_CASE_P(My, TypedTestP, NumericTypes); INSTANTIATE_TYPED_TEST_SUITE_P(My, TypedTestP, NumericTypes);
template <typename T> template <typename T>
class DISABLED_TypedTestP : public Test { class DISABLED_TypedTestP : public Test {
}; };
TYPED_TEST_CASE_P(DISABLED_TypedTestP); TYPED_TEST_SUITE_P(DISABLED_TypedTestP);
TYPED_TEST_P(DISABLED_TypedTestP, ShouldNotRun) { TYPED_TEST_P(DISABLED_TypedTestP, ShouldNotRun) {
FAIL() << "Unexpected failure: " FAIL() << "Unexpected failure: "
<< "Disabled type-parameterized test should not run."; << "Disabled type-parameterized test should not run.";
} }
REGISTER_TYPED_TEST_CASE_P(DISABLED_TypedTestP, ShouldNotRun); REGISTER_TYPED_TEST_SUITE_P(DISABLED_TypedTestP, ShouldNotRun);
INSTANTIATE_TYPED_TEST_CASE_P(My, DISABLED_TypedTestP, NumericTypes); INSTANTIATE_TYPED_TEST_SUITE_P(My, DISABLED_TypedTestP, NumericTypes);
#endif // GTEST_HAS_TYPED_TEST_P #endif // GTEST_HAS_TYPED_TEST_P
...@@ -3487,7 +3488,7 @@ std::vector<std::string> CharsToLines(const std::string& str) { ...@@ -3487,7 +3488,7 @@ std::vector<std::string> CharsToLines(const std::string& str) {
return out; return out;
} }
TEST(EditDistance, TestCases) { TEST(EditDistance, TestSuites) {
struct Case { struct Case {
int line; int line;
const char* left; const char* left;
...@@ -5310,11 +5311,11 @@ namespace testing { ...@@ -5310,11 +5311,11 @@ namespace testing {
class TestInfoTest : public Test { class TestInfoTest : public Test {
protected: protected:
static const TestInfo* GetTestInfo(const char* test_name) { static const TestInfo* GetTestInfo(const char* test_name) {
const TestCase* const test_case = const TestSuite* const test_suite =
GetUnitTestImpl()->GetTestCase("TestInfoTest", "", nullptr, nullptr); GetUnitTestImpl()->GetTestSuite("TestInfoTest", "", nullptr, nullptr);
for (int i = 0; i < test_case->total_test_count(); ++i) { for (int i = 0; i < test_suite->total_test_count(); ++i) {
const TestInfo* const test_info = test_case->GetTestInfo(i); const TestInfo* const test_info = test_suite->GetTestInfo(i);
if (strcmp(test_name, test_info->name()) == 0) if (strcmp(test_name, test_info->name()) == 0)
return test_info; return test_info;
} }
...@@ -5371,13 +5372,13 @@ TEST_P(CodeLocationForTESTP, Verify) { ...@@ -5371,13 +5372,13 @@ TEST_P(CodeLocationForTESTP, Verify) {
VERIFY_CODE_LOCATION; VERIFY_CODE_LOCATION;
} }
INSTANTIATE_TEST_CASE_P(, CodeLocationForTESTP, Values(0)); INSTANTIATE_TEST_SUITE_P(, CodeLocationForTESTP, Values(0));
template <typename T> template <typename T>
class CodeLocationForTYPEDTEST : public Test { class CodeLocationForTYPEDTEST : public Test {
}; };
TYPED_TEST_CASE(CodeLocationForTYPEDTEST, int); TYPED_TEST_SUITE(CodeLocationForTYPEDTEST, int);
TYPED_TEST(CodeLocationForTYPEDTEST, Verify) { TYPED_TEST(CodeLocationForTYPEDTEST, Verify) {
VERIFY_CODE_LOCATION; VERIFY_CODE_LOCATION;
...@@ -5387,20 +5388,21 @@ template <typename T> ...@@ -5387,20 +5388,21 @@ template <typename T>
class CodeLocationForTYPEDTESTP : public Test { class CodeLocationForTYPEDTESTP : public Test {
}; };
TYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP); TYPED_TEST_SUITE_P(CodeLocationForTYPEDTESTP);
TYPED_TEST_P(CodeLocationForTYPEDTESTP, Verify) { TYPED_TEST_P(CodeLocationForTYPEDTESTP, Verify) {
VERIFY_CODE_LOCATION; VERIFY_CODE_LOCATION;
} }
REGISTER_TYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP, Verify); REGISTER_TYPED_TEST_SUITE_P(CodeLocationForTYPEDTESTP, Verify);
INSTANTIATE_TYPED_TEST_CASE_P(My, CodeLocationForTYPEDTESTP, int); INSTANTIATE_TYPED_TEST_SUITE_P(My, CodeLocationForTYPEDTESTP, int);
#undef VERIFY_CODE_LOCATION #undef VERIFY_CODE_LOCATION
// Tests setting up and tearing down a test case. // Tests setting up and tearing down a test case.
// Legacy API is deprecated but still available
#ifndef REMOVE_LEGACY_TEST_CASEAPI
class SetUpTestCaseTest : public Test { class SetUpTestCaseTest : public Test {
protected: protected:
// This will be called once before the first test in this test case // This will be called once before the first test in this test case
...@@ -5459,8 +5461,9 @@ TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(nullptr, shared_resource_); } ...@@ -5459,8 +5461,9 @@ TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(nullptr, shared_resource_); }
TEST_F(SetUpTestCaseTest, Test2) { TEST_F(SetUpTestCaseTest, Test2) {
EXPECT_STREQ("123", shared_resource_); EXPECT_STREQ("123", shared_resource_);
} }
#endif // REMOVE_LEGACY_TEST_CASEAPI
// Tests SetupTestSuite/TearDown TestSuite API // Tests SetupTestSuite/TearDown TestSuite
class SetUpTestSuiteTest : public Test { class SetUpTestSuiteTest : public Test {
protected: protected:
// This will be called once before the first test in this test case // This will be called once before the first test in this test case
...@@ -6278,7 +6281,7 @@ class CurrentTestInfoTest : public Test { ...@@ -6278,7 +6281,7 @@ class CurrentTestInfoTest : public Test {
protected: protected:
// Tests that current_test_info() returns NULL before the first test in // Tests that current_test_info() returns NULL before the first test in
// the test case is run. // the test case is run.
static void SetUpTestCase() { static void SetUpTestSuite() {
// There should be no tests running at this point. // There should be no tests running at this point.
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_test_info(); UnitTest::GetInstance()->current_test_info();
...@@ -6288,7 +6291,7 @@ class CurrentTestInfoTest : public Test { ...@@ -6288,7 +6291,7 @@ class CurrentTestInfoTest : public Test {
// Tests that current_test_info() returns NULL after the last test in // Tests that current_test_info() returns NULL after the last test in
// the test case has run. // the test case has run.
static void TearDownTestCase() { static void TearDownTestSuite() {
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_test_info(); UnitTest::GetInstance()->current_test_info();
EXPECT_TRUE(test_info == nullptr) EXPECT_TRUE(test_info == nullptr)
...@@ -6298,14 +6301,14 @@ class CurrentTestInfoTest : public Test { ...@@ -6298,14 +6301,14 @@ class CurrentTestInfoTest : public Test {
// Tests that current_test_info() returns TestInfo for currently running // Tests that current_test_info() returns TestInfo for currently running
// test by checking the expected test name against the actual one. // test by checking the expected test name against the actual one.
TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) { TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestSuite) {
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_test_info(); UnitTest::GetInstance()->current_test_info();
ASSERT_TRUE(nullptr != test_info) ASSERT_TRUE(nullptr != test_info)
<< "There is a test running so we should have a valid TestInfo."; << "There is a test running so we should have a valid TestInfo.";
EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name())
<< "Expected the name of the currently running test case."; << "Expected the name of the currently running test case.";
EXPECT_STREQ("WorksForFirstTestInATestCase", test_info->name()) EXPECT_STREQ("WorksForFirstTestInATestSuite", test_info->name())
<< "Expected the name of the currently running test."; << "Expected the name of the currently running test.";
} }
...@@ -6313,14 +6316,14 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) { ...@@ -6313,14 +6316,14 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) {
// test by checking the expected test name against the actual one. We // test by checking the expected test name against the actual one. We
// use this test to see that the TestInfo object actually changed from // use this test to see that the TestInfo object actually changed from
// the previous invocation. // the previous invocation.
TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) { TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestSuite) {
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_test_info(); UnitTest::GetInstance()->current_test_info();
ASSERT_TRUE(nullptr != test_info) ASSERT_TRUE(nullptr != test_info)
<< "There is a test running so we should have a valid TestInfo."; << "There is a test running so we should have a valid TestInfo.";
EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name())
<< "Expected the name of the currently running test case."; << "Expected the name of the currently running test case.";
EXPECT_STREQ("WorksForSecondTestInATestCase", test_info->name()) EXPECT_STREQ("WorksForSecondTestInATestSuite", test_info->name())
<< "Expected the name of the currently running test."; << "Expected the name of the currently running test.";
} }
...@@ -7549,14 +7552,14 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) { ...@@ -7549,14 +7552,14 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
class AdHocTestResultTest : public testing::Test { class AdHocTestResultTest : public testing::Test {
protected: protected:
static void SetUpTestCase() { static void SetUpTestSuite() {
FAIL() << "A failure happened inside SetUpTestCase()."; FAIL() << "A failure happened inside SetUpTestSuite().";
} }
}; };
TEST_F(AdHocTestResultTest, AdHocTestResultForTestCaseShowsFailure) { TEST_F(AdHocTestResultTest, AdHocTestResultForTestSuiteShowsFailure) {
const testing::TestResult& test_result = testing::UnitTest::GetInstance() const testing::TestResult& test_result = testing::UnitTest::GetInstance()
->current_test_case() ->current_test_suite()
->ad_hoc_test_result(); ->ad_hoc_test_result();
EXPECT_TRUE(test_result.Failed()); EXPECT_TRUE(test_result.Failed());
} }
...@@ -7579,8 +7582,8 @@ auto* dynamic_test = testing::RegisterTest( ...@@ -7579,8 +7582,8 @@ auto* dynamic_test = testing::RegisterTest(
TEST(RegisterTest, WasRegistered) { TEST(RegisterTest, WasRegistered) {
auto* unittest = testing::UnitTest::GetInstance(); auto* unittest = testing::UnitTest::GetInstance();
for (int i = 0; i < unittest->total_test_case_count(); ++i) { for (int i = 0; i < unittest->total_test_suite_count(); ++i) {
auto* tests = unittest->GetTestCase(i); auto* tests = unittest->GetTestSuite(i);
if (tests->name() != std::string("DynamicUnitTestFixture")) continue; if (tests->name() != std::string("DynamicUnitTestFixture")) continue;
for (int j = 0; j < tests->total_test_count(); ++j) { for (int j = 0; j < tests->total_test_count(); ++j) {
if (tests->GetTestInfo(j)->name() != std::string("DynamicTest")) continue; if (tests->GetTestInfo(j)->name() != std::string("DynamicTest")) continue;
......
...@@ -111,7 +111,7 @@ Invalid characters in brackets []%(stack)s]]></failure> ...@@ -111,7 +111,7 @@ Invalid characters in brackets []%(stack)s]]></failure>
<testsuite name="SkippedTest" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="SkippedTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Skipped" status="skipped" time="*" classname="SkippedTest"/> <testcase name="Skipped" status="skipped" time="*" classname="SkippedTest"/>
</testsuite> </testsuite>
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye"> <testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTestSuite="yes" TearDownTestSuite="aye">
<testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest"> <testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key_1" value="1"/> <property name="key_1" value="1"/>
...@@ -164,11 +164,11 @@ Invalid characters in brackets []%(stack)s]]></failure> ...@@ -164,11 +164,11 @@ Invalid characters in brackets []%(stack)s]]></failure>
<testsuite name="TypedTest/1" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="TypedTest/1" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="TypedTest/1" /> <testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="TypedTest/1" />
</testsuite> </testsuite>
<testsuite name="Single/TypeParameterizedTestCase/0" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="Single/TypeParameterizedTestSuite/0" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTestCase/0" /> <testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTestSuite/0" />
</testsuite> </testsuite>
<testsuite name="Single/TypeParameterizedTestCase/1" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="Single/TypeParameterizedTestSuite/1" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTestCase/1" /> <testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTestSuite/1" />
</testsuite> </testsuite>
</testsuites>""" % {'stack': STACK_TRACE_TEMPLATE} </testsuites>""" % {'stack': STACK_TRACE_TEMPLATE}
...@@ -186,7 +186,7 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?> ...@@ -186,7 +186,7 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*"> <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/> <testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite> </testsuite>
<testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye"> <testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" errors="0" time="*" SetUpTestSuite="yes" TearDownTestSuite="aye">
<testcase name="TwoValuesForOneKeyUsesLastValue" status="run" time="*" classname="PropertyRecordingTest"> <testcase name="TwoValuesForOneKeyUsesLastValue" status="run" time="*" classname="PropertyRecordingTest">
<properties> <properties>
<property name="key_1" value="2"/> <property name="key_1" value="2"/>
......
...@@ -101,8 +101,10 @@ TEST(InvalidCharactersTest, InvalidCharactersInMessage) { ...@@ -101,8 +101,10 @@ TEST(InvalidCharactersTest, InvalidCharactersInMessage) {
class PropertyRecordingTest : public Test { class PropertyRecordingTest : public Test {
public: public:
static void SetUpTestCase() { RecordProperty("SetUpTestCase", "yes"); } static void SetUpTestSuite() { RecordProperty("SetUpTestSuite", "yes"); }
static void TearDownTestCase() { RecordProperty("TearDownTestCase", "aye"); } static void TearDownTestSuite() {
RecordProperty("TearDownTestSuite", "aye");
}
}; };
TEST_F(PropertyRecordingTest, OneProperty) { TEST_F(PropertyRecordingTest, OneProperty) {
...@@ -150,28 +152,28 @@ TEST(NoFixtureTest, ExternalUtilityThatCallsRecordStringValuedProperty) { ...@@ -150,28 +152,28 @@ TEST(NoFixtureTest, ExternalUtilityThatCallsRecordStringValuedProperty) {
class ValueParamTest : public TestWithParam<int> {}; class ValueParamTest : public TestWithParam<int> {};
TEST_P(ValueParamTest, HasValueParamAttribute) {} TEST_P(ValueParamTest, HasValueParamAttribute) {}
TEST_P(ValueParamTest, AnotherTestThatHasValueParamAttribute) {} TEST_P(ValueParamTest, AnotherTestThatHasValueParamAttribute) {}
INSTANTIATE_TEST_CASE_P(Single, ValueParamTest, Values(33, 42)); INSTANTIATE_TEST_SUITE_P(Single, ValueParamTest, Values(33, 42));
#if GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
// Verifies that the type parameter name is output in the 'type_param' // Verifies that the type parameter name is output in the 'type_param'
// XML attribute for typed tests. // XML attribute for typed tests.
template <typename T> class TypedTest : public Test {}; template <typename T> class TypedTest : public Test {};
typedef testing::Types<int, long> TypedTestTypes; typedef testing::Types<int, long> TypedTestTypes;
TYPED_TEST_CASE(TypedTest, TypedTestTypes); TYPED_TEST_SUITE(TypedTest, TypedTestTypes);
TYPED_TEST(TypedTest, HasTypeParamAttribute) {} TYPED_TEST(TypedTest, HasTypeParamAttribute) {}
#endif #endif
#if GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
// Verifies that the type parameter name is output in the 'type_param' // Verifies that the type parameter name is output in the 'type_param'
// XML attribute for type-parameterized tests. // XML attribute for type-parameterized tests.
template <typename T> class TypeParameterizedTestCase : public Test {}; template <typename T>
TYPED_TEST_CASE_P(TypeParameterizedTestCase); class TypeParameterizedTestSuite : public Test {};
TYPED_TEST_P(TypeParameterizedTestCase, HasTypeParamAttribute) {} TYPED_TEST_SUITE_P(TypeParameterizedTestSuite);
REGISTER_TYPED_TEST_CASE_P(TypeParameterizedTestCase, HasTypeParamAttribute); TYPED_TEST_P(TypeParameterizedTestSuite, HasTypeParamAttribute) {}
typedef testing::Types<int, long> TypeParameterizedTestCaseTypes; REGISTER_TYPED_TEST_SUITE_P(TypeParameterizedTestSuite, HasTypeParamAttribute);
INSTANTIATE_TYPED_TEST_CASE_P(Single, typedef testing::Types<int, long> TypeParameterizedTestSuiteTypes; // NOLINT
TypeParameterizedTestCase, INSTANTIATE_TYPED_TEST_SUITE_P(Single, TypeParameterizedTestSuite,
TypeParameterizedTestCaseTypes); TypeParameterizedTestSuiteTypes);
#endif #endif
int main(int argc, char** argv) { int main(int argc, char** argv) {
......
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