Commit 3a460a26 by misterg Committed by Gennadiy Civil

Googletest export

TestCase->TestSuite refactoring PiperOrigin-RevId: 227702164
parent ac8c102d
...@@ -572,7 +572,7 @@ struct MockObjectState { ...@@ -572,7 +572,7 @@ struct MockObjectState {
// invoked on this mock object. // invoked on this mock object.
const char* first_used_file; const char* first_used_file;
int first_used_line; int first_used_line;
::std::string first_used_test_case; ::std::string first_used_test_suite;
::std::string first_used_test; ::std::string first_used_test;
bool leakable; // true iff it's OK to leak the object. bool leakable; // true iff it's OK to leak the object.
FunctionMockers function_mockers; // All registered methods of the object. FunctionMockers function_mockers; // All registered methods of the object.
...@@ -609,8 +609,8 @@ class MockObjectRegistry { ...@@ -609,8 +609,8 @@ class MockObjectRegistry {
state.first_used_line); state.first_used_line);
std::cout << " ERROR: this mock object"; std::cout << " ERROR: this mock object";
if (state.first_used_test != "") { if (state.first_used_test != "") {
std::cout << " (used in test " << state.first_used_test_case << "." std::cout << " (used in test " << state.first_used_test_suite << "."
<< state.first_used_test << ")"; << state.first_used_test << ")";
} }
std::cout << " should be deleted but never is. Its address is @" std::cout << " should be deleted but never is. Its address is @"
<< it->first << "."; << it->first << ".";
...@@ -790,7 +790,7 @@ void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj, ...@@ -790,7 +790,7 @@ void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj,
const TestInfo* const test_info = const TestInfo* const test_info =
UnitTest::GetInstance()->current_test_info(); UnitTest::GetInstance()->current_test_info();
if (test_info != nullptr) { if (test_info != nullptr) {
state.first_used_test_case = test_info->test_case_name(); state.first_used_test_suite = test_info->test_suite_name();
state.first_used_test = test_info->name(); state.first_used_test = test_info->name();
} }
} }
......
...@@ -169,7 +169,7 @@ GTEST_API_ bool InDeathTestChild(); ...@@ -169,7 +169,7 @@ GTEST_API_ bool InDeathTestChild();
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_) GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
// Like ASSERT_EXIT, but continues on to successive tests in the // Like ASSERT_EXIT, but continues on to successive tests in the
// test case, if any: // test suite, if any:
# define EXPECT_EXIT(statement, predicate, regex) \ # define EXPECT_EXIT(statement, predicate, regex) \
GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_) GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
...@@ -180,7 +180,7 @@ GTEST_API_ bool InDeathTestChild(); ...@@ -180,7 +180,7 @@ GTEST_API_ bool InDeathTestChild();
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
// Like ASSERT_DEATH, but continues on to successive tests in the // Like ASSERT_DEATH, but continues on to successive tests in the
// test case, if any: // test suite, if any:
# define EXPECT_DEATH(statement, regex) \ # define EXPECT_DEATH(statement, regex) \
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
...@@ -227,7 +227,7 @@ class GTEST_API_ KilledBySignal { ...@@ -227,7 +227,7 @@ class GTEST_API_ KilledBySignal {
// return 12; // return 12;
// } // }
// //
// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) { // TEST(TestSuite, TestDieOr12WorksInDgbAndOpt) {
// int sideeffect = 0; // int sideeffect = 0;
// // Only asserts in dbg. // // Only asserts in dbg.
// EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death"); // EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
......
...@@ -250,6 +250,7 @@ ...@@ -250,6 +250,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <memory> #include <memory>
#include <type_traits>
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
# include <sys/types.h> # include <sys/types.h>
......
...@@ -31,12 +31,11 @@ ...@@ -31,12 +31,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Type utilities needed for implementing typed and type-parameterized // Type utilities needed for implementing typed and type-parameterized
// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! // tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
// //
// Currently we support at most 50 types in a list, and at most 50 // Currently we support at most 50 types in a list, and at most 50
// type-parameterized tests in one type-parameterized test case. // type-parameterized tests in one type-parameterized test suite.
// Please contact googletestframework@googlegroups.com if you need // Please contact googletestframework@googlegroups.com if you need
// more. // more.
...@@ -3312,8 +3311,8 @@ struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ...@@ -3312,8 +3311,8 @@ struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
}; };
// The TypeList template makes it possible to use either a single type // The TypeList template makes it possible to use either a single type
// or a Types<...> list in TYPED_TEST_CASE() and // or a Types<...> list in TYPED_TEST_SUITE() and
// INSTANTIATE_TYPED_TEST_CASE_P(). // INSTANTIATE_TYPED_TEST_SUITE_P().
template <typename T> template <typename T>
struct TypeList { struct TypeList {
......
...@@ -34,7 +34,7 @@ $var n = 50 $$ Maximum length of type lists we want to support. ...@@ -34,7 +34,7 @@ $var n = 50 $$ Maximum length of type lists we want to support.
// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! // tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
// //
// Currently we support at most $n types in a list, and at most $n // Currently we support at most $n types in a list, and at most $n
// type-parameterized tests in one type-parameterized test case. // type-parameterized tests in one type-parameterized test suite.
// Please contact googletestframework@googlegroups.com if you need // Please contact googletestframework@googlegroups.com if you need
// more. // more.
...@@ -291,8 +291,8 @@ struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> { ...@@ -291,8 +291,8 @@ struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {
]] ]]
// The TypeList template makes it possible to use either a single type // The TypeList template makes it possible to use either a single type
// or a Types<...> list in TYPED_TEST_CASE() and // or a Types<...> list in TYPED_TEST_SUITE() and
// INSTANTIATE_TYPED_TEST_CASE_P(). // INSTANTIATE_TYPED_TEST_SUITE_P().
template <typename T> template <typename T>
struct TypeList { struct TypeList {
......
...@@ -753,9 +753,9 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() { ...@@ -753,9 +753,9 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
FALSE, // The initial state is non-signalled. FALSE, // The initial state is non-signalled.
nullptr)); // The even is unnamed. nullptr)); // The even is unnamed.
GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr); GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr);
const std::string filter_flag = const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + kFilterFlag + "=" + info->test_suite_name() +
info->test_case_name() + "." + info->name(); "." + info->name();
const std::string internal_flag = const std::string internal_flag =
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag +
"=" + file_ + "|" + StreamableToString(line_) + "|" + "=" + file_ + "|" + StreamableToString(line_) + "|" +
...@@ -972,9 +972,9 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { ...@@ -972,9 +972,9 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
FlushInfoLog(); FlushInfoLog();
// Build the child process command line. // Build the child process command line.
const std::string filter_flag = const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" kFilterFlag + "=" + info->test_suite_name() +
+ info->test_case_name() + "." + info->name(); "." + info->name();
const std::string internal_flag = const std::string internal_flag =
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "="
+ file_ + "|" + file_ + "|"
...@@ -1411,9 +1411,9 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() { ...@@ -1411,9 +1411,9 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
// it be closed when the child process does an exec: // it be closed when the child process does an exec:
GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1); GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);
const std::string filter_flag = const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" kFilterFlag + "=" + info->test_suite_name() +
+ info->test_case_name() + "." + info->name(); "." + info->name();
const std::string internal_flag = const std::string internal_flag =
std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "="
+ file_ + "|" + StreamableToString(line_) + "|" + file_ + "|" + StreamableToString(line_) + "|"
......
...@@ -57,7 +57,7 @@ static std::vector<std::string> SplitIntoTestNames(const char* src) { ...@@ -57,7 +57,7 @@ static std::vector<std::string> SplitIntoTestNames(const char* src) {
// Verifies that registered_tests match the test names in // Verifies that registered_tests match the test names in
// registered_tests_; returns registered_tests if successful, or // registered_tests_; returns registered_tests if successful, or
// aborts the program otherwise. // aborts the program otherwise.
const char* TypedTestCasePState::VerifyRegisteredTestNames( const char* TypedTestSuitePState::VerifyRegisteredTestNames(
const char* file, int line, const char* registered_tests) { const char* file, int line, const char* registered_tests) {
typedef RegisteredTestsMap::const_iterator RegisteredTestIter; typedef RegisteredTestsMap::const_iterator RegisteredTestIter;
registered_ = true; registered_ = true;
...@@ -89,7 +89,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames( ...@@ -89,7 +89,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
tests.insert(name); tests.insert(name);
} else { } else {
errors << "No test named " << name errors << "No test named " << name
<< " can be found in this test case.\n"; << " can be found in this test suite.\n";
} }
} }
......
...@@ -140,8 +140,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): ...@@ -140,8 +140,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
def testCatchesCxxExceptionsInSetUpTestCase(self): def testCatchesCxxExceptionsInSetUpTestCase(self):
self.assert_('C++ exception with description "Standard C++ exception"' self.assert_('C++ exception with description "Standard C++ exception"'
' thrown in SetUpTestCase()' ' thrown in SetUpTestSuite()' in EX_BINARY_OUTPUT)
in EX_BINARY_OUTPUT)
self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() ' self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() '
'called as expected.' 'called as expected.'
in EX_BINARY_OUTPUT) in EX_BINARY_OUTPUT)
...@@ -163,8 +162,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): ...@@ -163,8 +162,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
def testCatchesCxxExceptionsInTearDownTestCase(self): def testCatchesCxxExceptionsInTearDownTestCase(self):
self.assert_('C++ exception with description "Standard C++ exception"' self.assert_('C++ exception with description "Standard C++ exception"'
' thrown in TearDownTestCase()' ' thrown in TearDownTestSuite()' in EX_BINARY_OUTPUT)
in EX_BINARY_OUTPUT)
def testCatchesCxxExceptionsInSetUp(self): def testCatchesCxxExceptionsInSetUp(self):
self.assert_('C++ exception with description "Standard C++ exception"' self.assert_('C++ exception with description "Standard C++ exception"'
......
...@@ -12,7 +12,7 @@ Expected equality of these values: ...@@ -12,7 +12,7 @@ Expected equality of these values:
3 3
Stack trace: (omitted) Stack trace: (omitted)
[==========] Running 83 tests from 38 test cases. [==========] Running 83 tests from 38 test suites.
[----------] Global test environment set-up. [----------] Global test environment set-up.
FooEnvironment::SetUp() called. FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called. BarEnvironment::SetUp() called.
...@@ -392,26 +392,26 @@ Stack trace: (omitted) ...@@ -392,26 +392,26 @@ Stack trace: (omitted)
[ RUN ] MixedUpTestCaseTest.ThisShouldFail [ RUN ] MixedUpTestCaseTest.ThisShouldFail
gtest.cc:#: Failure gtest.cc:#: Failure
Failed Failed
All tests in the same test case must use the same test fixture All tests in the same test suite must use the same test fixture
class. However, in test case MixedUpTestCaseTest, class. However, in test suite MixedUpTestCaseTest,
you defined test FirstTestFromNamespaceFoo and test ThisShouldFail you defined test FirstTestFromNamespaceFoo and test ThisShouldFail
using two different test fixture classes. This can happen if using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation the two classes are from different namespaces or translation
units and have the same name. You should probably rename one units and have the same name. You should probably rename one
of the classes to put the tests into different test cases. of the classes to put the tests into different test suites.
Stack trace: (omitted) Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseTest.ThisShouldFail [ FAILED ] MixedUpTestCaseTest.ThisShouldFail
[ RUN ] MixedUpTestCaseTest.ThisShouldFailToo [ RUN ] MixedUpTestCaseTest.ThisShouldFailToo
gtest.cc:#: Failure gtest.cc:#: Failure
Failed Failed
All tests in the same test case must use the same test fixture All tests in the same test suite must use the same test fixture
class. However, in test case MixedUpTestCaseTest, class. However, in test suite MixedUpTestCaseTest,
you defined test FirstTestFromNamespaceFoo and test ThisShouldFailToo you defined test FirstTestFromNamespaceFoo and test ThisShouldFailToo
using two different test fixture classes. This can happen if using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation the two classes are from different namespaces or translation
units and have the same name. You should probably rename one units and have the same name. You should probably rename one
of the classes to put the tests into different test cases. of the classes to put the tests into different test suites.
Stack trace: (omitted) Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseTest.ThisShouldFailToo [ FAILED ] MixedUpTestCaseTest.ThisShouldFailToo
...@@ -421,13 +421,13 @@ Stack trace: (omitted) ...@@ -421,13 +421,13 @@ Stack trace: (omitted)
[ RUN ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail [ RUN ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
gtest.cc:#: Failure gtest.cc:#: Failure
Failed Failed
All tests in the same test case must use the same test fixture All tests in the same test suite must use the same test fixture
class. However, in test case MixedUpTestCaseWithSameTestNameTest, class. However, in test suite MixedUpTestCaseWithSameTestNameTest,
you defined test TheSecondTestWithThisNameShouldFail and test TheSecondTestWithThisNameShouldFail you defined test TheSecondTestWithThisNameShouldFail and test TheSecondTestWithThisNameShouldFail
using two different test fixture classes. This can happen if using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation the two classes are from different namespaces or translation
units and have the same name. You should probably rename one units and have the same name. You should probably rename one
of the classes to put the tests into different test cases. of the classes to put the tests into different test suites.
Stack trace: (omitted) Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail [ FAILED ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
...@@ -437,9 +437,9 @@ Stack trace: (omitted) ...@@ -437,9 +437,9 @@ Stack trace: (omitted)
[ RUN ] TEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail [ RUN ] TEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
gtest.cc:#: Failure gtest.cc:#: Failure
Failed Failed
All tests in the same test case must use the same test fixture All tests in the same test suite must use the same test fixture
class, so mixing TEST_F and TEST in the same test case is class, so mixing TEST_F and TEST in the same test suite is
illegal. In test case TEST_F_before_TEST_in_same_test_case, illegal. In test suite TEST_F_before_TEST_in_same_test_case,
test DefinedUsingTEST_F is defined using TEST_F but test DefinedUsingTEST_F is defined using TEST_F but
test DefinedUsingTESTAndShouldFail is defined using TEST. You probably test DefinedUsingTESTAndShouldFail is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test want to change the TEST to TEST_F or move it to another test
...@@ -453,9 +453,9 @@ Stack trace: (omitted) ...@@ -453,9 +453,9 @@ Stack trace: (omitted)
[ RUN ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail [ RUN ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
gtest.cc:#: Failure gtest.cc:#: Failure
Failed Failed
All tests in the same test case must use the same test fixture All tests in the same test suite must use the same test fixture
class, so mixing TEST_F and TEST in the same test case is class, so mixing TEST_F and TEST in the same test suite is
illegal. In test case TEST_before_TEST_F_in_same_test_case, illegal. In test suite TEST_before_TEST_F_in_same_test_case,
test DefinedUsingTEST_FAndShouldFail is defined using TEST_F but test DefinedUsingTEST_FAndShouldFail is defined using TEST_F but
test DefinedUsingTEST is defined using TEST. You probably test DefinedUsingTEST is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test want to change the TEST to TEST_F or move it to another test
...@@ -912,9 +912,9 @@ DynamicFixture::TearDown ...@@ -912,9 +912,9 @@ DynamicFixture::TearDown
DynamicFixture() DynamicFixture()
gtest.cc:#: Failure gtest.cc:#: Failure
Failed Failed
All tests in the same test case must use the same test fixture All tests in the same test suite must use the same test fixture
class, so mixing TEST_F and TEST in the same test case is class, so mixing TEST_F and TEST in the same test suite is
illegal. In test case BadDynamicFixture1, illegal. In test suite BadDynamicFixture1,
test FixtureBase is defined using TEST_F but test FixtureBase is defined using TEST_F but
test TestBase is defined using TEST. You probably test TestBase is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test want to change the TEST to TEST_F or move it to another test
...@@ -936,13 +936,13 @@ DynamicFixture::TearDown ...@@ -936,13 +936,13 @@ DynamicFixture::TearDown
DynamicFixture() DynamicFixture()
gtest.cc:#: Failure gtest.cc:#: Failure
Failed Failed
All tests in the same test case must use the same test fixture All tests in the same test suite must use the same test fixture
class. However, in test case BadDynamicFixture2, class. However, in test suite BadDynamicFixture2,
you defined test FixtureBase and test Derived you defined test FixtureBase and test Derived
using two different test fixture classes. This can happen if using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation the two classes are from different namespaces or translation
units and have the same name. You should probably rename one units and have the same name. You should probably rename one
of the classes to put the tests into different test cases. of the classes to put the tests into different test suites.
Stack trace: (omitted) Stack trace: (omitted)
~DynamicFixture() ~DynamicFixture()
...@@ -984,7 +984,7 @@ Failed ...@@ -984,7 +984,7 @@ Failed
Expected fatal failure. Expected fatal failure.
Stack trace: (omitted) Stack trace: (omitted)
[==========] 83 tests from 38 test cases ran. [==========] 83 tests from 38 test suites ran.
[ PASSED ] 30 tests. [ PASSED ] 30 tests.
[ FAILED ] 53 tests, listed below: [ FAILED ] 53 tests, listed below:
[ FAILED ] NonfatalFailureTest.EscapesStringOperands [ FAILED ] NonfatalFailureTest.EscapesStringOperands
...@@ -1045,7 +1045,7 @@ Stack trace: (omitted) ...@@ -1045,7 +1045,7 @@ Stack trace: (omitted)
 YOU HAVE 1 DISABLED TEST  YOU HAVE 1 DISABLED TEST
Note: Google Test filter = FatalFailureTest.*:LoggingTest.* Note: Google Test filter = FatalFailureTest.*:LoggingTest.*
[==========] Running 4 tests from 2 test cases. [==========] Running 4 tests from 2 test suites.
[----------] Global test environment set-up. [----------] Global test environment set-up.
[----------] 3 tests from FatalFailureTest [----------] 3 tests from FatalFailureTest
[ RUN ] FatalFailureTest.FatalFailureInSubroutine [ RUN ] FatalFailureTest.FatalFailureInSubroutine
...@@ -1098,7 +1098,7 @@ Stack trace: (omitted) ...@@ -1098,7 +1098,7 @@ Stack trace: (omitted)
[----------] 1 test from LoggingTest (? ms total) [----------] 1 test from LoggingTest (? ms total)
[----------] Global test environment tear-down [----------] Global test environment tear-down
[==========] 4 tests from 2 test cases ran. (? ms total) [==========] 4 tests from 2 test suites ran. (? ms total)
[ PASSED ] 0 tests. [ PASSED ] 0 tests.
[ FAILED ] 4 tests, listed below: [ FAILED ] 4 tests, listed below:
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine [ FAILED ] FatalFailureTest.FatalFailureInSubroutine
...@@ -1108,21 +1108,21 @@ Stack trace: (omitted) ...@@ -1108,21 +1108,21 @@ Stack trace: (omitted)
4 FAILED TESTS 4 FAILED TESTS
Note: Google Test filter = *DISABLED_* Note: Google Test filter = *DISABLED_*
[==========] Running 1 test from 1 test case. [==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up. [----------] Global test environment set-up.
[----------] 1 test from DisabledTestsWarningTest [----------] 1 test from DisabledTestsWarningTest
[ RUN ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning [ RUN ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
[ OK ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning [ OK ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
[----------] Global test environment tear-down [----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. [==========] 1 test from 1 test suite ran.
[ PASSED ] 1 test. [ PASSED ] 1 test.
Note: Google Test filter = PassingTest.* Note: Google Test filter = PassingTest.*
Note: This is test shard 2 of 2. Note: This is test shard 2 of 2.
[==========] Running 1 test from 1 test case. [==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up. [----------] Global test environment set-up.
[----------] 1 test from PassingTest [----------] 1 test from PassingTest
[ RUN ] PassingTest.PassingTest2 [ RUN ] PassingTest.PassingTest2
[ OK ] PassingTest.PassingTest2 [ OK ] PassingTest.PassingTest2
[----------] Global test environment tear-down [----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. [==========] 1 test from 1 test suite ran.
[ PASSED ] 1 test. [ PASSED ] 1 test.
...@@ -249,7 +249,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) { ...@@ -249,7 +249,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) {
TEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) { TEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) {
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED(
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C, D"), state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C, D"),
"foo\\.cc.1.?: No test named D can be found in this test case\\."); "foo\\.cc.1.?: No test named D can be found in this test suite\\.");
} }
TEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) { TEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {
...@@ -264,7 +264,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) { ...@@ -264,7 +264,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C"); state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C");
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED(
state_.AddTestName("foo.cc", 2, "FooTest", "D"), state_.AddTestName("foo.cc", 2, "FooTest", "D"),
"foo\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_CASE_P" "foo\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_SUITE_P"
"\\(FooTest, \\.\\.\\.\\)\\."); "\\(FooTest, \\.\\.\\.\\)\\.");
} }
......
...@@ -5431,6 +5431,67 @@ TEST_F(SetUpTestCaseTest, Test2) { ...@@ -5431,6 +5431,67 @@ TEST_F(SetUpTestCaseTest, Test2) {
EXPECT_STREQ("123", shared_resource_); EXPECT_STREQ("123", shared_resource_);
} }
// Tests SetupTestSuite/TearDown TestSuite API
class SetUpTestSuiteTest : public Test {
protected:
// This will be called once before the first test in this test case
// is run.
static void SetUpTestSuite() {
printf("Setting up the test suite . . .\n");
// Initializes some shared resource. In this simple example, we
// just create a C string. More complex stuff can be done if
// desired.
shared_resource_ = "123";
// Increments the number of test cases that have been set up.
counter_++;
// SetUpTestSuite() should be called only once.
EXPECT_EQ(1, counter_);
}
// This will be called once after the last test in this test case is
// run.
static void TearDownTestSuite() {
printf("Tearing down the test suite . . .\n");
// Decrements the number of test suites that have been set up.
counter_--;
// TearDownTestSuite() should be called only once.
EXPECT_EQ(0, counter_);
// Cleans up the shared resource.
shared_resource_ = nullptr;
}
// This will be called before each test in this test case.
void SetUp() override {
// SetUpTestSuite() should be called only once, so counter_ should
// always be 1.
EXPECT_EQ(1, counter_);
}
// Number of test suites that have been set up.
static int counter_;
// Some resource to be shared by all tests in this test case.
static const char* shared_resource_;
};
int SetUpTestSuiteTest::counter_ = 0;
const char* SetUpTestSuiteTest::shared_resource_ = nullptr;
// A test that uses the shared resource.
TEST_F(SetUpTestSuiteTest, TestSetupTestSuite1) {
EXPECT_STRNE(nullptr, shared_resource_);
}
// Another test that uses the shared resource.
TEST_F(SetUpTestSuiteTest, TestSetupTestSuite2) {
EXPECT_STREQ("123", shared_resource_);
}
// The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly. // The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly.
......
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