mirror of
https://github.com/google/googletest.git
synced 2025-03-10 00:46:56 +00:00
Googletest export
Change tests to use new Test Suite API PiperOrigin-RevId: 228908894
This commit is contained in:
parent
2edadcedf3
commit
0599a7b841
@ -89,9 +89,9 @@ if SUPPORTS_SEH_EXCEPTIONS:
|
|||||||
self.assert_('SEH exception with code 0x2a thrown '
|
self.assert_('SEH exception with code 0x2a thrown '
|
||||||
'in the test fixture\'s destructor'
|
'in the test fixture\'s destructor'
|
||||||
in test_output)
|
in test_output)
|
||||||
self.assert_('SEH exception with code 0x2a thrown in SetUpTestCase()'
|
self.assert_('SEH exception with code 0x2a thrown in SetUpTestSuite()'
|
||||||
in test_output)
|
in test_output)
|
||||||
self.assert_('SEH exception with code 0x2a thrown in TearDownTestCase()'
|
self.assert_('SEH exception with code 0x2a thrown in TearDownTestSuite()'
|
||||||
in test_output)
|
in test_output)
|
||||||
self.assert_('SEH exception with code 0x2a thrown in SetUp()'
|
self.assert_('SEH exception with code 0x2a thrown in SetUp()'
|
||||||
in test_output)
|
in test_output)
|
||||||
@ -134,29 +134,29 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
|
|||||||
'"Standard C++ exception" thrown '
|
'"Standard C++ exception" thrown '
|
||||||
'in the test fixture\'s destructor'
|
'in the test fixture\'s destructor'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() '
|
self.assert_('CxxExceptionInDestructorTest::TearDownTestSuite() '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
|
|
||||||
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 SetUpTestSuite()' in EX_BINARY_OUTPUT)
|
' thrown in SetUpTestSuite()' in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() '
|
self.assert_('CxxExceptionInConstructorTest::TearDownTestSuite() '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInSetUpTestCaseTest constructor '
|
self.assert_('CxxExceptionInSetUpTestSuiteTest constructor '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInSetUpTestCaseTest destructor '
|
self.assert_('CxxExceptionInSetUpTestSuiteTest destructor '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInSetUpTestCaseTest::SetUp() '
|
self.assert_('CxxExceptionInSetUpTestSuiteTest::SetUp() '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInSetUpTestCaseTest::TearDown() '
|
self.assert_('CxxExceptionInSetUpTestSuiteTest::TearDown() '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInSetUpTestCaseTest test body '
|
self.assert_('CxxExceptionInSetUpTestSuiteTest test body '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
|
|||||||
self.assert_('C++ exception with description "Standard C++ exception"'
|
self.assert_('C++ exception with description "Standard C++ exception"'
|
||||||
' thrown in SetUp()'
|
' thrown in SetUp()'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInSetUpTest::TearDownTestCase() '
|
self.assert_('CxxExceptionInSetUpTest::TearDownTestSuite() '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInSetUpTest destructor '
|
self.assert_('CxxExceptionInSetUpTest destructor '
|
||||||
@ -186,7 +186,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
|
|||||||
self.assert_('C++ exception with description "Standard C++ exception"'
|
self.assert_('C++ exception with description "Standard C++ exception"'
|
||||||
' thrown in TearDown()'
|
' thrown in TearDown()'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInTearDownTest::TearDownTestCase() '
|
self.assert_('CxxExceptionInTearDownTest::TearDownTestSuite() '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInTearDownTest destructor '
|
self.assert_('CxxExceptionInTearDownTest destructor '
|
||||||
@ -197,7 +197,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
|
|||||||
self.assert_('C++ exception with description "Standard C++ exception"'
|
self.assert_('C++ exception with description "Standard C++ exception"'
|
||||||
' thrown in the test body'
|
' thrown in the test body'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInTestBodyTest::TearDownTestCase() '
|
self.assert_('CxxExceptionInTestBodyTest::TearDownTestSuite() '
|
||||||
'called as expected.'
|
'called as expected.'
|
||||||
in EX_BINARY_OUTPUT)
|
in EX_BINARY_OUTPUT)
|
||||||
self.assert_('CxxExceptionInTestBodyTest destructor '
|
self.assert_('CxxExceptionInTestBodyTest destructor '
|
||||||
|
@ -64,19 +64,20 @@ class SehExceptionInDestructorTest : public Test {
|
|||||||
|
|
||||||
TEST_F(SehExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
|
TEST_F(SehExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
|
||||||
|
|
||||||
class SehExceptionInSetUpTestCaseTest : public Test {
|
class SehExceptionInSetUpTestSuiteTest : public Test {
|
||||||
public:
|
public:
|
||||||
static void SetUpTestCase() { RaiseException(42, 0, 0, NULL); }
|
static void SetUpTestSuite() { RaiseException(42, 0, 0, NULL); }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(SehExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {}
|
TEST_F(SehExceptionInSetUpTestSuiteTest, ThrowsExceptionInSetUpTestSuite) {}
|
||||||
|
|
||||||
class SehExceptionInTearDownTestCaseTest : public Test {
|
class SehExceptionInTearDownTestSuiteTest : public Test {
|
||||||
public:
|
public:
|
||||||
static void TearDownTestCase() { RaiseException(42, 0, 0, NULL); }
|
static void TearDownTestSuite() { RaiseException(42, 0, 0, NULL); }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(SehExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
|
TEST_F(SehExceptionInTearDownTestSuiteTest,
|
||||||
|
ThrowsExceptionInTearDownTestSuite) {}
|
||||||
|
|
||||||
class SehExceptionInSetUpTest : public Test {
|
class SehExceptionInSetUpTest : public Test {
|
||||||
protected:
|
protected:
|
||||||
@ -109,9 +110,9 @@ class CxxExceptionInConstructorTest : public Test {
|
|||||||
throw std::runtime_error("Standard C++ exception"));
|
throw std::runtime_error("Standard C++ exception"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInConstructorTest::TearDownTestCase() "
|
"CxxExceptionInConstructorTest::TearDownTestSuite() "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,65 +138,65 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
|
|||||||
<< "called unexpectedly.";
|
<< "called unexpectedly.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CxxExceptionInSetUpTestSuiteTest : public Test {
|
||||||
class CxxExceptionInSetUpTestCaseTest : public Test {
|
|
||||||
public:
|
public:
|
||||||
CxxExceptionInSetUpTestCaseTest() {
|
CxxExceptionInSetUpTestSuiteTest() {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInSetUpTestCaseTest constructor "
|
"CxxExceptionInSetUpTestSuiteTest constructor "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestSuite() {
|
||||||
throw std::runtime_error("Standard C++ exception");
|
throw std::runtime_error("Standard C++ exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInSetUpTestCaseTest::TearDownTestCase() "
|
"CxxExceptionInSetUpTestSuiteTest::TearDownTestSuite() "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~CxxExceptionInSetUpTestCaseTest() override {
|
~CxxExceptionInSetUpTestSuiteTest() override {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInSetUpTestCaseTest destructor "
|
"CxxExceptionInSetUpTestSuiteTest destructor "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInSetUpTestCaseTest::SetUp() "
|
"CxxExceptionInSetUpTestSuiteTest::SetUp() "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInSetUpTestCaseTest::TearDown() "
|
"CxxExceptionInSetUpTestSuiteTest::TearDown() "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(CxxExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {
|
TEST_F(CxxExceptionInSetUpTestSuiteTest, ThrowsExceptionInSetUpTestSuite) {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInSetUpTestCaseTest test body "
|
"CxxExceptionInSetUpTestSuiteTest test body "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
class CxxExceptionInTearDownTestCaseTest : public Test {
|
class CxxExceptionInTearDownTestSuiteTest : public Test {
|
||||||
public:
|
public:
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
throw std::runtime_error("Standard C++ exception");
|
throw std::runtime_error("Standard C++ exception");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(CxxExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
|
TEST_F(CxxExceptionInTearDownTestSuiteTest,
|
||||||
|
ThrowsExceptionInTearDownTestSuite) {}
|
||||||
|
|
||||||
class CxxExceptionInSetUpTest : public Test {
|
class CxxExceptionInSetUpTest : public Test {
|
||||||
public:
|
public:
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInSetUpTest::TearDownTestCase() "
|
"CxxExceptionInSetUpTest::TearDownTestSuite() "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,9 +223,9 @@ TEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {
|
|||||||
|
|
||||||
class CxxExceptionInTearDownTest : public Test {
|
class CxxExceptionInTearDownTest : public Test {
|
||||||
public:
|
public:
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInTearDownTest::TearDownTestCase() "
|
"CxxExceptionInTearDownTest::TearDownTestSuite() "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,9 +245,9 @@ TEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
|
|||||||
|
|
||||||
class CxxExceptionInTestBodyTest : public Test {
|
class CxxExceptionInTestBodyTest : public Test {
|
||||||
public:
|
public:
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
printf("%s",
|
printf("%s",
|
||||||
"CxxExceptionInTestBodyTest::TearDownTestCase() "
|
"CxxExceptionInTestBodyTest::TearDownTestSuite() "
|
||||||
"called as expected.\n");
|
"called as expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,12 +1017,12 @@ class MacroLogicDeathTest : public testing::Test {
|
|||||||
static testing::internal::ReplaceDeathTestFactory* replacer_;
|
static testing::internal::ReplaceDeathTestFactory* replacer_;
|
||||||
static MockDeathTestFactory* factory_;
|
static MockDeathTestFactory* factory_;
|
||||||
|
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestSuite() {
|
||||||
factory_ = new MockDeathTestFactory;
|
factory_ = new MockDeathTestFactory;
|
||||||
replacer_ = new testing::internal::ReplaceDeathTestFactory(factory_);
|
replacer_ = new testing::internal::ReplaceDeathTestFactory(factory_);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
delete replacer_;
|
delete replacer_;
|
||||||
replacer_ = nullptr;
|
replacer_ = nullptr;
|
||||||
delete factory_;
|
delete factory_;
|
||||||
|
@ -125,8 +125,8 @@ TEST_P(ParamTest, TestX) {
|
|||||||
TEST_P(ParamTest, TestY) {
|
TEST_P(ParamTest, TestY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(SeqP, ParamTest, testing::Values(1, 2));
|
INSTANTIATE_TEST_SUITE_P(SeqP, ParamTest, testing::Values(1, 2));
|
||||||
INSTANTIATE_TEST_CASE_P(SeqQ, ParamTest, testing::Values(5, 6));
|
INSTANTIATE_TEST_SUITE_P(SeqQ, ParamTest, testing::Values(5, 6));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -241,8 +241,8 @@ EXPECTED_NON_EMPTY = {
|
|||||||
u'disabled': 0,
|
u'disabled': 0,
|
||||||
u'errors': 0,
|
u'errors': 0,
|
||||||
u'time': u'*',
|
u'time': u'*',
|
||||||
u'SetUpTestCase': u'yes',
|
u'SetUpTestSuite': u'yes',
|
||||||
u'TearDownTestCase': u'aye',
|
u'TearDownTestSuite': u'aye',
|
||||||
u'testsuite': [
|
u'testsuite': [
|
||||||
{
|
{
|
||||||
u'name': u'OneProperty',
|
u'name': u'OneProperty',
|
||||||
@ -343,7 +343,7 @@ EXPECTED_NON_EMPTY = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
u'name': u'Single/TypeParameterizedTestCase/0',
|
u'name': u'Single/TypeParameterizedTestSuite/0',
|
||||||
u'tests': 1,
|
u'tests': 1,
|
||||||
u'failures': 0,
|
u'failures': 0,
|
||||||
u'disabled': 0,
|
u'disabled': 0,
|
||||||
@ -355,12 +355,12 @@ EXPECTED_NON_EMPTY = {
|
|||||||
u'type_param': u'int',
|
u'type_param': u'int',
|
||||||
u'status': u'RUN',
|
u'status': u'RUN',
|
||||||
u'time': u'*',
|
u'time': u'*',
|
||||||
u'classname': u'Single/TypeParameterizedTestCase/0'
|
u'classname': u'Single/TypeParameterizedTestSuite/0'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
u'name': u'Single/TypeParameterizedTestCase/1',
|
u'name': u'Single/TypeParameterizedTestSuite/1',
|
||||||
u'tests': 1,
|
u'tests': 1,
|
||||||
u'failures': 0,
|
u'failures': 0,
|
||||||
u'disabled': 0,
|
u'disabled': 0,
|
||||||
@ -372,7 +372,7 @@ EXPECTED_NON_EMPTY = {
|
|||||||
u'type_param': u'long',
|
u'type_param': u'long',
|
||||||
u'status': u'RUN',
|
u'status': u'RUN',
|
||||||
u'time': u'*',
|
u'time': u'*',
|
||||||
u'classname': u'Single/TypeParameterizedTestCase/1'
|
u'classname': u'Single/TypeParameterizedTestSuite/1'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -99,7 +99,7 @@ TEST_P(ValueParamTest, TestA) {
|
|||||||
TEST_P(ValueParamTest, TestB) {
|
TEST_P(ValueParamTest, TestB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
MyInstantiation, ValueParamTest,
|
MyInstantiation, ValueParamTest,
|
||||||
testing::Values(MyType("one line"),
|
testing::Values(MyType("one line"),
|
||||||
MyType("two\nlines"),
|
MyType("two\nlines"),
|
||||||
@ -123,7 +123,7 @@ class MyArray {
|
|||||||
typedef testing::Types<VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName, // NOLINT
|
typedef testing::Types<VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName, // NOLINT
|
||||||
int*, MyArray<bool, 42> > MyTypes;
|
int*, MyArray<bool, 42> > MyTypes;
|
||||||
|
|
||||||
TYPED_TEST_CASE(TypedTest, MyTypes);
|
TYPED_TEST_SUITE(TypedTest, MyTypes);
|
||||||
|
|
||||||
TYPED_TEST(TypedTest, TestA) {
|
TYPED_TEST(TypedTest, TestA) {
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ template <typename T>
|
|||||||
class TypeParamTest : public testing::Test {
|
class TypeParamTest : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(TypeParamTest);
|
TYPED_TEST_SUITE_P(TypeParamTest);
|
||||||
|
|
||||||
TYPED_TEST_P(TypeParamTest, TestA) {
|
TYPED_TEST_P(TypeParamTest, TestA) {
|
||||||
}
|
}
|
||||||
@ -145,9 +145,9 @@ TYPED_TEST_P(TypeParamTest, TestA) {
|
|||||||
TYPED_TEST_P(TypeParamTest, TestB) {
|
TYPED_TEST_P(TypeParamTest, TestB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(TypeParamTest, TestA, TestB);
|
REGISTER_TYPED_TEST_SUITE_P(TypeParamTest, TestA, TestB);
|
||||||
|
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(My, TypeParamTest, MyTypes);
|
INSTANTIATE_TYPED_TEST_SUITE_P(My, TypeParamTest, MyTypes);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
@ -40,7 +40,7 @@ using ::testing::AddGlobalTestEnvironment;
|
|||||||
using ::testing::Environment;
|
using ::testing::Environment;
|
||||||
using ::testing::InitGoogleTest;
|
using ::testing::InitGoogleTest;
|
||||||
using ::testing::Test;
|
using ::testing::Test;
|
||||||
using ::testing::TestCase;
|
using ::testing::TestSuite;
|
||||||
using ::testing::TestEventListener;
|
using ::testing::TestEventListener;
|
||||||
using ::testing::TestInfo;
|
using ::testing::TestInfo;
|
||||||
using ::testing::TestPartResult;
|
using ::testing::TestPartResult;
|
||||||
@ -206,12 +206,12 @@ class EnvironmentInvocationCatcher : public Environment {
|
|||||||
|
|
||||||
class ListenerTest : public Test {
|
class ListenerTest : public Test {
|
||||||
protected:
|
protected:
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestSuite() {
|
||||||
g_events->push_back("ListenerTest::SetUpTestCase");
|
g_events->push_back("ListenerTest::SetUpTestSuite");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
g_events->push_back("ListenerTest::TearDownTestCase");
|
g_events->push_back("ListenerTest::TearDownTestSuite");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUp() override { g_events->push_back("ListenerTest::SetUp"); }
|
void SetUp() override { g_events->push_back("ListenerTest::SetUp"); }
|
||||||
@ -299,7 +299,7 @@ int main(int argc, char **argv) {
|
|||||||
"3rd.OnTestSuiteStart",
|
"3rd.OnTestSuiteStart",
|
||||||
"1st.OnTestCaseStart",
|
"1st.OnTestCaseStart",
|
||||||
"2nd.OnTestCaseStart",
|
"2nd.OnTestCaseStart",
|
||||||
"ListenerTest::SetUpTestCase",
|
"ListenerTest::SetUpTestSuite",
|
||||||
"1st.OnTestStart",
|
"1st.OnTestStart",
|
||||||
"2nd.OnTestStart",
|
"2nd.OnTestStart",
|
||||||
"3rd.OnTestStart",
|
"3rd.OnTestStart",
|
||||||
@ -324,7 +324,7 @@ int main(int argc, char **argv) {
|
|||||||
"3rd.OnTestEnd",
|
"3rd.OnTestEnd",
|
||||||
"2nd.OnTestEnd",
|
"2nd.OnTestEnd",
|
||||||
"1st.OnTestEnd",
|
"1st.OnTestEnd",
|
||||||
"ListenerTest::TearDownTestCase",
|
"ListenerTest::TearDownTestSuite",
|
||||||
"3rd.OnTestSuiteEnd",
|
"3rd.OnTestSuiteEnd",
|
||||||
"2nd.OnTestCaseEnd",
|
"2nd.OnTestCaseEnd",
|
||||||
"1st.OnTestCaseEnd",
|
"1st.OnTestCaseEnd",
|
||||||
@ -351,7 +351,7 @@ int main(int argc, char **argv) {
|
|||||||
"3rd.OnTestSuiteStart",
|
"3rd.OnTestSuiteStart",
|
||||||
"1st.OnTestCaseStart",
|
"1st.OnTestCaseStart",
|
||||||
"2nd.OnTestCaseStart",
|
"2nd.OnTestCaseStart",
|
||||||
"ListenerTest::SetUpTestCase",
|
"ListenerTest::SetUpTestSuite",
|
||||||
"1st.OnTestStart",
|
"1st.OnTestStart",
|
||||||
"2nd.OnTestStart",
|
"2nd.OnTestStart",
|
||||||
"3rd.OnTestStart",
|
"3rd.OnTestStart",
|
||||||
@ -376,7 +376,7 @@ int main(int argc, char **argv) {
|
|||||||
"3rd.OnTestEnd",
|
"3rd.OnTestEnd",
|
||||||
"2nd.OnTestEnd",
|
"2nd.OnTestEnd",
|
||||||
"1st.OnTestEnd",
|
"1st.OnTestEnd",
|
||||||
"ListenerTest::TearDownTestCase",
|
"ListenerTest::TearDownTestSuite",
|
||||||
"3rd.OnTestSuiteEnd",
|
"3rd.OnTestSuiteEnd",
|
||||||
"2nd.OnTestCaseEnd",
|
"2nd.OnTestCaseEnd",
|
||||||
"1st.OnTestCaseEnd",
|
"1st.OnTestCaseEnd",
|
||||||
|
@ -384,16 +384,16 @@ Expected failure in foo.cc
|
|||||||
Stack trace: (omitted)
|
Stack trace: (omitted)
|
||||||
|
|
||||||
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
|
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
|
||||||
[0;32m[----------] [m4 tests from MixedUpTestCaseTest
|
[0;32m[----------] [m4 tests from MixedUpTestSuiteTest
|
||||||
[0;32m[ RUN ] [mMixedUpTestCaseTest.FirstTestFromNamespaceFoo
|
[0;32m[ RUN ] [mMixedUpTestSuiteTest.FirstTestFromNamespaceFoo
|
||||||
[0;32m[ OK ] [mMixedUpTestCaseTest.FirstTestFromNamespaceFoo
|
[0;32m[ OK ] [mMixedUpTestSuiteTest.FirstTestFromNamespaceFoo
|
||||||
[0;32m[ RUN ] [mMixedUpTestCaseTest.SecondTestFromNamespaceFoo
|
[0;32m[ RUN ] [mMixedUpTestSuiteTest.SecondTestFromNamespaceFoo
|
||||||
[0;32m[ OK ] [mMixedUpTestCaseTest.SecondTestFromNamespaceFoo
|
[0;32m[ OK ] [mMixedUpTestSuiteTest.SecondTestFromNamespaceFoo
|
||||||
[0;32m[ RUN ] [mMixedUpTestCaseTest.ThisShouldFail
|
[0;32m[ RUN ] [mMixedUpTestSuiteTest.ThisShouldFail
|
||||||
gtest.cc:#: Failure
|
gtest.cc:#: Failure
|
||||||
Failed
|
Failed
|
||||||
All tests in the same test suite must use the same test fixture
|
All tests in the same test suite must use the same test fixture
|
||||||
class. However, in test suite MixedUpTestCaseTest,
|
class. However, in test suite MixedUpTestSuiteTest,
|
||||||
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
|
||||||
@ -401,12 +401,12 @@ units and have the same name. You should probably rename one
|
|||||||
of the classes to put the tests into different test suites.
|
of the classes to put the tests into different test suites.
|
||||||
Stack trace: (omitted)
|
Stack trace: (omitted)
|
||||||
|
|
||||||
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFail
|
[0;31m[ FAILED ] [mMixedUpTestSuiteTest.ThisShouldFail
|
||||||
[0;32m[ RUN ] [mMixedUpTestCaseTest.ThisShouldFailToo
|
[0;32m[ RUN ] [mMixedUpTestSuiteTest.ThisShouldFailToo
|
||||||
gtest.cc:#: Failure
|
gtest.cc:#: Failure
|
||||||
Failed
|
Failed
|
||||||
All tests in the same test suite must use the same test fixture
|
All tests in the same test suite must use the same test fixture
|
||||||
class. However, in test suite MixedUpTestCaseTest,
|
class. However, in test suite MixedUpTestSuiteTest,
|
||||||
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
|
||||||
@ -414,15 +414,15 @@ units and have the same name. You should probably rename one
|
|||||||
of the classes to put the tests into different test suites.
|
of the classes to put the tests into different test suites.
|
||||||
Stack trace: (omitted)
|
Stack trace: (omitted)
|
||||||
|
|
||||||
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFailToo
|
[0;31m[ FAILED ] [mMixedUpTestSuiteTest.ThisShouldFailToo
|
||||||
[0;32m[----------] [m2 tests from MixedUpTestCaseWithSameTestNameTest
|
[0;32m[----------] [m2 tests from MixedUpTestSuiteWithSameTestNameTest
|
||||||
[0;32m[ RUN ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
[0;32m[ RUN ] [mMixedUpTestSuiteWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
||||||
[0;32m[ OK ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
[0;32m[ OK ] [mMixedUpTestSuiteWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
||||||
[0;32m[ RUN ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
[0;32m[ RUN ] [mMixedUpTestSuiteWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
||||||
gtest.cc:#: Failure
|
gtest.cc:#: Failure
|
||||||
Failed
|
Failed
|
||||||
All tests in the same test suite must use the same test fixture
|
All tests in the same test suite must use the same test fixture
|
||||||
class. However, in test suite MixedUpTestCaseWithSameTestNameTest,
|
class. However, in test suite MixedUpTestSuiteWithSameTestNameTest,
|
||||||
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
|
||||||
@ -430,7 +430,7 @@ units and have the same name. You should probably rename one
|
|||||||
of the classes to put the tests into different test suites.
|
of the classes to put the tests into different test suites.
|
||||||
Stack trace: (omitted)
|
Stack trace: (omitted)
|
||||||
|
|
||||||
[0;31m[ FAILED ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
[0;31m[ FAILED ] [mMixedUpTestSuiteWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
||||||
[0;32m[----------] [m2 tests from TEST_F_before_TEST_in_same_test_case
|
[0;32m[----------] [m2 tests from TEST_F_before_TEST_in_same_test_case
|
||||||
[0;32m[ RUN ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F
|
[0;32m[ RUN ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F
|
||||||
[0;32m[ OK ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F
|
[0;32m[ OK ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F
|
||||||
@ -871,7 +871,7 @@ Stack trace: (omitted)
|
|||||||
|
|
||||||
[0;31m[ FAILED ] [mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
|
[0;31m[ FAILED ] [mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
|
||||||
[0;32m[----------] [m2 tests from DynamicFixture
|
[0;32m[----------] [m2 tests from DynamicFixture
|
||||||
DynamicFixture::SetUpTestCase
|
DynamicFixture::SetUpTestSuite
|
||||||
[0;32m[ RUN ] [mDynamicFixture.DynamicTestPass
|
[0;32m[ RUN ] [mDynamicFixture.DynamicTestPass
|
||||||
DynamicFixture()
|
DynamicFixture()
|
||||||
DynamicFixture::SetUp
|
DynamicFixture::SetUp
|
||||||
@ -890,18 +890,18 @@ Stack trace: (omitted)
|
|||||||
DynamicFixture::TearDown
|
DynamicFixture::TearDown
|
||||||
~DynamicFixture()
|
~DynamicFixture()
|
||||||
[0;31m[ FAILED ] [mDynamicFixture.DynamicTestFail
|
[0;31m[ FAILED ] [mDynamicFixture.DynamicTestFail
|
||||||
DynamicFixture::TearDownTestCase
|
DynamicFixture::TearDownTestSuite
|
||||||
[0;32m[----------] [m1 test from DynamicFixtureAnotherName
|
[0;32m[----------] [m1 test from DynamicFixtureAnotherName
|
||||||
DynamicFixture::SetUpTestCase
|
DynamicFixture::SetUpTestSuite
|
||||||
[0;32m[ RUN ] [mDynamicFixtureAnotherName.DynamicTestPass
|
[0;32m[ RUN ] [mDynamicFixtureAnotherName.DynamicTestPass
|
||||||
DynamicFixture()
|
DynamicFixture()
|
||||||
DynamicFixture::SetUp
|
DynamicFixture::SetUp
|
||||||
DynamicFixture::TearDown
|
DynamicFixture::TearDown
|
||||||
~DynamicFixture()
|
~DynamicFixture()
|
||||||
[0;32m[ OK ] [mDynamicFixtureAnotherName.DynamicTestPass
|
[0;32m[ OK ] [mDynamicFixtureAnotherName.DynamicTestPass
|
||||||
DynamicFixture::TearDownTestCase
|
DynamicFixture::TearDownTestSuite
|
||||||
[0;32m[----------] [m2 tests from BadDynamicFixture1
|
[0;32m[----------] [m2 tests from BadDynamicFixture1
|
||||||
DynamicFixture::SetUpTestCase
|
DynamicFixture::SetUpTestSuite
|
||||||
[0;32m[ RUN ] [mBadDynamicFixture1.FixtureBase
|
[0;32m[ RUN ] [mBadDynamicFixture1.FixtureBase
|
||||||
DynamicFixture()
|
DynamicFixture()
|
||||||
DynamicFixture::SetUp
|
DynamicFixture::SetUp
|
||||||
@ -923,9 +923,9 @@ Stack trace: (omitted)
|
|||||||
|
|
||||||
~DynamicFixture()
|
~DynamicFixture()
|
||||||
[0;31m[ FAILED ] [mBadDynamicFixture1.TestBase
|
[0;31m[ FAILED ] [mBadDynamicFixture1.TestBase
|
||||||
DynamicFixture::TearDownTestCase
|
DynamicFixture::TearDownTestSuite
|
||||||
[0;32m[----------] [m2 tests from BadDynamicFixture2
|
[0;32m[----------] [m2 tests from BadDynamicFixture2
|
||||||
DynamicFixture::SetUpTestCase
|
DynamicFixture::SetUpTestSuite
|
||||||
[0;32m[ RUN ] [mBadDynamicFixture2.FixtureBase
|
[0;32m[ RUN ] [mBadDynamicFixture2.FixtureBase
|
||||||
DynamicFixture()
|
DynamicFixture()
|
||||||
DynamicFixture::SetUp
|
DynamicFixture::SetUp
|
||||||
@ -947,7 +947,7 @@ Stack trace: (omitted)
|
|||||||
|
|
||||||
~DynamicFixture()
|
~DynamicFixture()
|
||||||
[0;31m[ FAILED ] [mBadDynamicFixture2.Derived
|
[0;31m[ FAILED ] [mBadDynamicFixture2.Derived
|
||||||
DynamicFixture::TearDownTestCase
|
DynamicFixture::TearDownTestSuite
|
||||||
[0;32m[----------] [m1 test from PrintingFailingParams/FailingParamTest
|
[0;32m[----------] [m1 test from PrintingFailingParams/FailingParamTest
|
||||||
[0;32m[ RUN ] [mPrintingFailingParams/FailingParamTest.Fails/0
|
[0;32m[ RUN ] [mPrintingFailingParams/FailingParamTest.Fails/0
|
||||||
googletest-output-test_.cc:#: Failure
|
googletest-output-test_.cc:#: Failure
|
||||||
@ -1006,9 +1006,9 @@ Stack trace: (omitted)
|
|||||||
[0;31m[ FAILED ] [mNonFatalFailureInSetUpTest.FailureInSetUp
|
[0;31m[ FAILED ] [mNonFatalFailureInSetUpTest.FailureInSetUp
|
||||||
[0;31m[ FAILED ] [mFatalFailureInSetUpTest.FailureInSetUp
|
[0;31m[ FAILED ] [mFatalFailureInSetUpTest.FailureInSetUp
|
||||||
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
|
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
|
||||||
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFail
|
[0;31m[ FAILED ] [mMixedUpTestSuiteTest.ThisShouldFail
|
||||||
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFailToo
|
[0;31m[ FAILED ] [mMixedUpTestSuiteTest.ThisShouldFailToo
|
||||||
[0;31m[ FAILED ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
[0;31m[ FAILED ] [mMixedUpTestSuiteWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
||||||
[0;31m[ FAILED ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
|
[0;31m[ FAILED ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
|
||||||
[0;31m[ FAILED ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
|
[0;31m[ FAILED ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
|
||||||
[0;31m[ FAILED ] [mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure
|
[0;31m[ FAILED ] [mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure
|
||||||
|
@ -92,9 +92,9 @@ TEST_P(FailingParamTest, Fails) {
|
|||||||
|
|
||||||
// This generates a test which will fail. Google Test is expected to print
|
// This generates a test which will fail. Google Test is expected to print
|
||||||
// its parameter when it outputs the list of all failed tests.
|
// its parameter when it outputs the list of all failed tests.
|
||||||
INSTANTIATE_TEST_CASE_P(PrintingFailingParams,
|
INSTANTIATE_TEST_SUITE_P(PrintingFailingParams,
|
||||||
FailingParamTest,
|
FailingParamTest,
|
||||||
testing::Values(2));
|
testing::Values(2));
|
||||||
|
|
||||||
static const char kGoldenString[] = "\"Line\0 1\"\nLine 2";
|
static const char kGoldenString[] = "\"Line\0 1\"\nLine 2";
|
||||||
|
|
||||||
@ -521,48 +521,48 @@ class DeathTestAndMultiThreadsTest : public testing::Test {
|
|||||||
|
|
||||||
#endif // GTEST_IS_THREADSAFE
|
#endif // GTEST_IS_THREADSAFE
|
||||||
|
|
||||||
// The MixedUpTestCaseTest test case verifies that Google Test will fail a
|
// The MixedUpTestSuiteTest test case verifies that Google Test will fail a
|
||||||
// test if it uses a different fixture class than what other tests in
|
// test if it uses a different fixture class than what other tests in
|
||||||
// the same test case use. It deliberately contains two fixture
|
// the same test case use. It deliberately contains two fixture
|
||||||
// classes with the same name but defined in different namespaces.
|
// classes with the same name but defined in different namespaces.
|
||||||
|
|
||||||
// The MixedUpTestCaseWithSameTestNameTest test case verifies that
|
// The MixedUpTestSuiteWithSameTestNameTest test case verifies that
|
||||||
// when the user defines two tests with the same test case name AND
|
// when the user defines two tests with the same test case name AND
|
||||||
// same test name (but in different namespaces), the second test will
|
// same test name (but in different namespaces), the second test will
|
||||||
// fail.
|
// fail.
|
||||||
|
|
||||||
namespace foo {
|
namespace foo {
|
||||||
|
|
||||||
class MixedUpTestCaseTest : public testing::Test {
|
class MixedUpTestSuiteTest : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(MixedUpTestCaseTest, FirstTestFromNamespaceFoo) {}
|
TEST_F(MixedUpTestSuiteTest, FirstTestFromNamespaceFoo) {}
|
||||||
TEST_F(MixedUpTestCaseTest, SecondTestFromNamespaceFoo) {}
|
TEST_F(MixedUpTestSuiteTest, SecondTestFromNamespaceFoo) {}
|
||||||
|
|
||||||
class MixedUpTestCaseWithSameTestNameTest : public testing::Test {
|
class MixedUpTestSuiteWithSameTestNameTest : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(MixedUpTestCaseWithSameTestNameTest,
|
TEST_F(MixedUpTestSuiteWithSameTestNameTest,
|
||||||
TheSecondTestWithThisNameShouldFail) {}
|
TheSecondTestWithThisNameShouldFail) {}
|
||||||
|
|
||||||
} // namespace foo
|
} // namespace foo
|
||||||
|
|
||||||
namespace bar {
|
namespace bar {
|
||||||
|
|
||||||
class MixedUpTestCaseTest : public testing::Test {
|
class MixedUpTestSuiteTest : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
// The following two tests are expected to fail. We rely on the
|
// The following two tests are expected to fail. We rely on the
|
||||||
// golden file to check that Google Test generates the right error message.
|
// golden file to check that Google Test generates the right error message.
|
||||||
TEST_F(MixedUpTestCaseTest, ThisShouldFail) {}
|
TEST_F(MixedUpTestSuiteTest, ThisShouldFail) {}
|
||||||
TEST_F(MixedUpTestCaseTest, ThisShouldFailToo) {}
|
TEST_F(MixedUpTestSuiteTest, ThisShouldFailToo) {}
|
||||||
|
|
||||||
class MixedUpTestCaseWithSameTestNameTest : public testing::Test {
|
class MixedUpTestSuiteWithSameTestNameTest : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Expected to fail. We rely on the golden file to check that Google Test
|
// Expected to fail. We rely on the golden file to check that Google Test
|
||||||
// generates the right error message.
|
// generates the right error message.
|
||||||
TEST_F(MixedUpTestCaseWithSameTestNameTest,
|
TEST_F(MixedUpTestSuiteWithSameTestNameTest,
|
||||||
TheSecondTestWithThisNameShouldFail) {}
|
TheSecondTestWithThisNameShouldFail) {}
|
||||||
|
|
||||||
} // namespace bar
|
} // namespace bar
|
||||||
@ -773,10 +773,10 @@ TEST_P(ParamTest, Failure) {
|
|||||||
EXPECT_EQ("b", GetParam()) << "Expected failure";
|
EXPECT_EQ("b", GetParam()) << "Expected failure";
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(PrintingStrings,
|
INSTANTIATE_TEST_SUITE_P(PrintingStrings,
|
||||||
ParamTest,
|
ParamTest,
|
||||||
testing::Values(std::string("a")),
|
testing::Values(std::string("a")),
|
||||||
ParamNameFunc);
|
ParamNameFunc);
|
||||||
|
|
||||||
// This #ifdef block tests the output of typed tests.
|
// This #ifdef block tests the output of typed tests.
|
||||||
#if GTEST_HAS_TYPED_TEST
|
#if GTEST_HAS_TYPED_TEST
|
||||||
@ -785,7 +785,7 @@ template <typename T>
|
|||||||
class TypedTest : public testing::Test {
|
class TypedTest : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE(TypedTest, testing::Types<int>);
|
TYPED_TEST_SUITE(TypedTest, testing::Types<int>);
|
||||||
|
|
||||||
TYPED_TEST(TypedTest, Success) {
|
TYPED_TEST(TypedTest, Success) {
|
||||||
EXPECT_EQ(0, TypeParam());
|
EXPECT_EQ(0, TypeParam());
|
||||||
@ -811,7 +811,7 @@ class TypedTestNames {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE(TypedTestWithNames, TypesForTestWithNames, TypedTestNames);
|
TYPED_TEST_SUITE(TypedTestWithNames, TypesForTestWithNames, TypedTestNames);
|
||||||
|
|
||||||
TYPED_TEST(TypedTestWithNames, Success) {}
|
TYPED_TEST(TypedTestWithNames, Success) {}
|
||||||
|
|
||||||
@ -826,7 +826,7 @@ template <typename T>
|
|||||||
class TypedTestP : public testing::Test {
|
class TypedTestP : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(TypedTestP);
|
TYPED_TEST_SUITE_P(TypedTestP);
|
||||||
|
|
||||||
TYPED_TEST_P(TypedTestP, Success) {
|
TYPED_TEST_P(TypedTestP, Success) {
|
||||||
EXPECT_EQ(0U, TypeParam());
|
EXPECT_EQ(0U, TypeParam());
|
||||||
@ -836,10 +836,10 @@ TYPED_TEST_P(TypedTestP, Failure) {
|
|||||||
EXPECT_EQ(1U, TypeParam()) << "Expected failure";
|
EXPECT_EQ(1U, TypeParam()) << "Expected failure";
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(TypedTestP, Success, Failure);
|
REGISTER_TYPED_TEST_SUITE_P(TypedTestP, Success, Failure);
|
||||||
|
|
||||||
typedef testing::Types<unsigned char, unsigned int> UnsignedTypes;
|
typedef testing::Types<unsigned char, unsigned int> UnsignedTypes;
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);
|
INSTANTIATE_TYPED_TEST_SUITE_P(Unsigned, TypedTestP, UnsignedTypes);
|
||||||
|
|
||||||
class TypedTestPNames {
|
class TypedTestPNames {
|
||||||
public:
|
public:
|
||||||
@ -854,7 +854,7 @@ class TypedTestPNames {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(UnsignedCustomName, TypedTestP, UnsignedTypes,
|
INSTANTIATE_TYPED_TEST_SUITE_P(UnsignedCustomName, TypedTestP, UnsignedTypes,
|
||||||
TypedTestPNames);
|
TypedTestPNames);
|
||||||
|
|
||||||
#endif // GTEST_HAS_TYPED_TEST_P
|
#endif // GTEST_HAS_TYPED_TEST_P
|
||||||
@ -877,7 +877,7 @@ class ATypedDeathTest : public testing::Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef testing::Types<int, double> NumericTypes;
|
typedef testing::Types<int, double> NumericTypes;
|
||||||
TYPED_TEST_CASE(ATypedDeathTest, NumericTypes);
|
TYPED_TEST_SUITE(ATypedDeathTest, NumericTypes);
|
||||||
|
|
||||||
TYPED_TEST(ATypedDeathTest, ShouldRunFirst) {
|
TYPED_TEST(ATypedDeathTest, ShouldRunFirst) {
|
||||||
}
|
}
|
||||||
@ -894,14 +894,14 @@ template <typename T>
|
|||||||
class ATypeParamDeathTest : public testing::Test {
|
class ATypeParamDeathTest : public testing::Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(ATypeParamDeathTest);
|
TYPED_TEST_SUITE_P(ATypeParamDeathTest);
|
||||||
|
|
||||||
TYPED_TEST_P(ATypeParamDeathTest, ShouldRunFirst) {
|
TYPED_TEST_P(ATypeParamDeathTest, ShouldRunFirst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(ATypeParamDeathTest, ShouldRunFirst);
|
REGISTER_TYPED_TEST_SUITE_P(ATypeParamDeathTest, ShouldRunFirst);
|
||||||
|
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(My, ATypeParamDeathTest, NumericTypes);
|
INSTANTIATE_TYPED_TEST_SUITE_P(My, ATypeParamDeathTest, NumericTypes);
|
||||||
|
|
||||||
# endif // GTEST_HAS_TYPED_TEST_P
|
# endif // GTEST_HAS_TYPED_TEST_P
|
||||||
|
|
||||||
@ -1031,9 +1031,9 @@ class DynamicFixture : public testing::Test {
|
|||||||
void SetUp() override { printf("DynamicFixture::SetUp\n"); }
|
void SetUp() override { printf("DynamicFixture::SetUp\n"); }
|
||||||
void TearDown() override { printf("DynamicFixture::TearDown\n"); }
|
void TearDown() override { printf("DynamicFixture::TearDown\n"); }
|
||||||
|
|
||||||
static void SetUpTestCase() { printf("DynamicFixture::SetUpTestCase\n"); }
|
static void SetUpTestSuite() { printf("DynamicFixture::SetUpTestSuite\n"); }
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
printf("DynamicFixture::TearDownTestCase\n");
|
printf("DynamicFixture::TearDownTestSuite\n");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ class DummyTest : public ::testing::TestWithParam<const char *> {};
|
|||||||
TEST_P(DummyTest, Dummy) {
|
TEST_P(DummyTest, Dummy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(InvalidTestName,
|
INSTANTIATE_TEST_SUITE_P(InvalidTestName,
|
||||||
DummyTest,
|
DummyTest,
|
||||||
::testing::Values("InvalidWithQuotes"),
|
::testing::Values("InvalidWithQuotes"),
|
||||||
::testing::PrintToStringParamName());
|
::testing::PrintToStringParamName());
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -41,10 +41,10 @@ std::string StringParamTestSuffix(
|
|||||||
TEST_P(DummyTest, Dummy) {
|
TEST_P(DummyTest, Dummy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(DuplicateTestNames,
|
INSTANTIATE_TEST_SUITE_P(DuplicateTestNames,
|
||||||
DummyTest,
|
DummyTest,
|
||||||
::testing::Values("a", "b", "a", "c"),
|
::testing::Values("a", "b", "a", "c"),
|
||||||
StringParamTestSuffix);
|
StringParamTestSuffix);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -542,12 +542,12 @@ TEST(ParamGeneratorTest, AssignmentWorks) {
|
|||||||
|
|
||||||
// This test verifies that the tests are expanded and run as specified:
|
// This test verifies that the tests are expanded and run as specified:
|
||||||
// one test per element from the sequence produced by the generator
|
// one test per element from the sequence produced by the generator
|
||||||
// specified in INSTANTIATE_TEST_CASE_P. It also verifies that the test's
|
// specified in INSTANTIATE_TEST_SUITE_P. It also verifies that the test's
|
||||||
// fixture constructor, SetUp(), and TearDown() have run and have been
|
// fixture constructor, SetUp(), and TearDown() have run and have been
|
||||||
// supplied with the correct parameters.
|
// supplied with the correct parameters.
|
||||||
|
|
||||||
// The use of environment object allows detection of the case where no test
|
// The use of environment object allows detection of the case where no test
|
||||||
// case functionality is run at all. In this case TestCaseTearDown will not
|
// case functionality is run at all. In this case TearDownTestSuite will not
|
||||||
// be able to detect missing tests, naturally.
|
// be able to detect missing tests, naturally.
|
||||||
template <int kExpectedCalls>
|
template <int kExpectedCalls>
|
||||||
class TestGenerationEnvironment : public ::testing::Environment {
|
class TestGenerationEnvironment : public ::testing::Environment {
|
||||||
@ -628,7 +628,7 @@ class TestGenerationTest : public TestWithParam<int> {
|
|||||||
EXPECT_EQ(current_parameter_, GetParam());
|
EXPECT_EQ(current_parameter_, GetParam());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestSuite() {
|
||||||
bool all_tests_in_test_case_selected = true;
|
bool all_tests_in_test_case_selected = true;
|
||||||
|
|
||||||
for (int i = 0; i < PARAMETER_COUNT; ++i) {
|
for (int i = 0; i < PARAMETER_COUNT; ++i) {
|
||||||
@ -649,7 +649,7 @@ class TestGenerationTest : public TestWithParam<int> {
|
|||||||
collected_parameters_.clear();
|
collected_parameters_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
vector<int> expected_values(test_generation_params,
|
vector<int> expected_values(test_generation_params,
|
||||||
test_generation_params + PARAMETER_COUNT);
|
test_generation_params + PARAMETER_COUNT);
|
||||||
// Test execution order is not guaranteed by Google Test,
|
// Test execution order is not guaranteed by Google Test,
|
||||||
@ -675,17 +675,17 @@ TEST_P(TestGenerationTest, TestsExpandedAndRun) {
|
|||||||
EXPECT_EQ(current_parameter_, GetParam());
|
EXPECT_EQ(current_parameter_, GetParam());
|
||||||
collected_parameters_.push_back(GetParam());
|
collected_parameters_.push_back(GetParam());
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(TestExpansionModule, TestGenerationTest,
|
INSTANTIATE_TEST_SUITE_P(TestExpansionModule, TestGenerationTest,
|
||||||
ValuesIn(test_generation_params));
|
ValuesIn(test_generation_params));
|
||||||
|
|
||||||
// This test verifies that the element sequence (third parameter of
|
// This test verifies that the element sequence (third parameter of
|
||||||
// INSTANTIATE_TEST_CASE_P) is evaluated in InitGoogleTest() and neither at
|
// INSTANTIATE_TEST_SUITE_P) is evaluated in InitGoogleTest() and neither at
|
||||||
// the call site of INSTANTIATE_TEST_CASE_P nor in RUN_ALL_TESTS(). For
|
// the call site of INSTANTIATE_TEST_SUITE_P nor in RUN_ALL_TESTS(). For
|
||||||
// that, we declare param_value_ to be a static member of
|
// that, we declare param_value_ to be a static member of
|
||||||
// GeneratorEvaluationTest and initialize it to 0. We set it to 1 in
|
// GeneratorEvaluationTest and initialize it to 0. We set it to 1 in
|
||||||
// main(), just before invocation of InitGoogleTest(). After calling
|
// main(), just before invocation of InitGoogleTest(). After calling
|
||||||
// InitGoogleTest(), we set the value to 2. If the sequence is evaluated
|
// InitGoogleTest(), we set the value to 2. If the sequence is evaluated
|
||||||
// before or after InitGoogleTest, INSTANTIATE_TEST_CASE_P will create a
|
// before or after InitGoogleTest, INSTANTIATE_TEST_SUITE_P will create a
|
||||||
// test with parameter other than 1, and the test body will fail the
|
// test with parameter other than 1, and the test body will fail the
|
||||||
// assertion.
|
// assertion.
|
||||||
class GeneratorEvaluationTest : public TestWithParam<int> {
|
class GeneratorEvaluationTest : public TestWithParam<int> {
|
||||||
@ -701,9 +701,8 @@ int GeneratorEvaluationTest::param_value_ = 0;
|
|||||||
TEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {
|
TEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {
|
||||||
EXPECT_EQ(1, GetParam());
|
EXPECT_EQ(1, GetParam());
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(GenEvalModule,
|
INSTANTIATE_TEST_SUITE_P(GenEvalModule, GeneratorEvaluationTest,
|
||||||
GeneratorEvaluationTest,
|
Values(GeneratorEvaluationTest::param_value()));
|
||||||
Values(GeneratorEvaluationTest::param_value()));
|
|
||||||
|
|
||||||
// Tests that generators defined in a different translation unit are
|
// Tests that generators defined in a different translation unit are
|
||||||
// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.
|
// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.
|
||||||
@ -714,9 +713,8 @@ TEST_P(ExternalGeneratorTest, ExternalGenerator) {
|
|||||||
// which we verify here.
|
// which we verify here.
|
||||||
EXPECT_EQ(GetParam(), 33);
|
EXPECT_EQ(GetParam(), 33);
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(ExternalGeneratorModule,
|
INSTANTIATE_TEST_SUITE_P(ExternalGeneratorModule, ExternalGeneratorTest,
|
||||||
ExternalGeneratorTest,
|
extern_gen);
|
||||||
extern_gen);
|
|
||||||
|
|
||||||
// Tests that a parameterized test case can be defined in one translation
|
// Tests that a parameterized test case can be defined in one translation
|
||||||
// unit and instantiated in another. This test will be instantiated in
|
// unit and instantiated in another. This test will be instantiated in
|
||||||
@ -731,20 +729,19 @@ TEST_P(ExternalInstantiationTest, IsMultipleOf33) {
|
|||||||
class MultipleInstantiationTest : public TestWithParam<int> {};
|
class MultipleInstantiationTest : public TestWithParam<int> {};
|
||||||
TEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {
|
TEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));
|
INSTANTIATE_TEST_SUITE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));
|
||||||
INSTANTIATE_TEST_CASE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));
|
INSTANTIATE_TEST_SUITE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));
|
||||||
|
|
||||||
// Tests that a parameterized test case can be instantiated
|
// Tests that a parameterized test case can be instantiated
|
||||||
// in multiple translation units. This test will be instantiated
|
// in multiple translation units. This test will be instantiated
|
||||||
// here and in gtest-param-test_test2.cc.
|
// here and in gtest-param-test_test2.cc.
|
||||||
// InstantiationInMultipleTranslationUnitsTest fixture class
|
// InstantiationInMultipleTranslationUnitsTest fixture class
|
||||||
// is defined in gtest-param-test_test.h.
|
// is defined in gtest-param-test_test.h.
|
||||||
TEST_P(InstantiationInMultipleTranslaionUnitsTest, IsMultipleOf42) {
|
TEST_P(InstantiationInMultipleTranslationUnitsTest, IsMultipleOf42) {
|
||||||
EXPECT_EQ(0, GetParam() % 42);
|
EXPECT_EQ(0, GetParam() % 42);
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(Sequence1,
|
INSTANTIATE_TEST_SUITE_P(Sequence1, InstantiationInMultipleTranslationUnitsTest,
|
||||||
InstantiationInMultipleTranslaionUnitsTest,
|
Values(42, 42 * 2));
|
||||||
Values(42, 42*2));
|
|
||||||
|
|
||||||
// Tests that each iteration of parameterized test runs in a separate test
|
// Tests that each iteration of parameterized test runs in a separate test
|
||||||
// object.
|
// object.
|
||||||
@ -752,7 +749,7 @@ class SeparateInstanceTest : public TestWithParam<int> {
|
|||||||
public:
|
public:
|
||||||
SeparateInstanceTest() : count_(0) {}
|
SeparateInstanceTest() : count_(0) {}
|
||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
EXPECT_GE(global_count_, 2)
|
EXPECT_GE(global_count_, 2)
|
||||||
<< "If some (but not all) SeparateInstanceTest tests have been "
|
<< "If some (but not all) SeparateInstanceTest tests have been "
|
||||||
<< "filtered out this test will fail. Make sure that all "
|
<< "filtered out this test will fail. Make sure that all "
|
||||||
@ -770,20 +767,20 @@ TEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {
|
|||||||
EXPECT_EQ(0, count_++);
|
EXPECT_EQ(0, count_++);
|
||||||
global_count_++;
|
global_count_++;
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_CASE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));
|
INSTANTIATE_TEST_SUITE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));
|
||||||
|
|
||||||
// Tests that all instantiations of a test have named appropriately. Test
|
// Tests that all instantiations of a test have named appropriately. Test
|
||||||
// defined with TEST_P(TestCaseName, TestName) and instantiated with
|
// defined with TEST_P(TestSuiteName, TestName) and instantiated with
|
||||||
// INSTANTIATE_TEST_CASE_P(SequenceName, TestCaseName, generator) must be named
|
// INSTANTIATE_TEST_SUITE_P(SequenceName, TestSuiteName, generator) must be
|
||||||
// SequenceName/TestCaseName.TestName/i, where i is the 0-based index of the
|
// named SequenceName/TestSuiteName.TestName/i, where i is the 0-based index of
|
||||||
// sequence element used to instantiate the test.
|
// the sequence element used to instantiate the test.
|
||||||
class NamingTest : public TestWithParam<int> {};
|
class NamingTest : public TestWithParam<int> {};
|
||||||
|
|
||||||
TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
|
TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
|
||||||
const ::testing::TestInfo* const test_info =
|
const ::testing::TestInfo* const test_info =
|
||||||
::testing::UnitTest::GetInstance()->current_test_info();
|
::testing::UnitTest::GetInstance()->current_test_info();
|
||||||
|
|
||||||
EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_case_name());
|
EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_suite_name());
|
||||||
|
|
||||||
Message index_stream;
|
Message index_stream;
|
||||||
index_stream << "TestsReportCorrectNamesAndParameters/" << GetParam();
|
index_stream << "TestsReportCorrectNamesAndParameters/" << GetParam();
|
||||||
@ -792,7 +789,7 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
|
|||||||
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
|
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
|
INSTANTIATE_TEST_SUITE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
|
||||||
|
|
||||||
// Tests that macros in test names are expanded correctly.
|
// Tests that macros in test names are expanded correctly.
|
||||||
class MacroNamingTest : public TestWithParam<int> {};
|
class MacroNamingTest : public TestWithParam<int> {};
|
||||||
@ -804,11 +801,11 @@ TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) {
|
|||||||
const ::testing::TestInfo* const test_info =
|
const ::testing::TestInfo* const test_info =
|
||||||
::testing::UnitTest::GetInstance()->current_test_info();
|
::testing::UnitTest::GetInstance()->current_test_info();
|
||||||
|
|
||||||
EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_case_name());
|
EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_suite_name());
|
||||||
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(FortyTwo, MacroNamingTest, Values(42));
|
INSTANTIATE_TEST_SUITE_P(FortyTwo, MacroNamingTest, Values(42));
|
||||||
|
|
||||||
// Tests the same thing for non-parametrized tests.
|
// Tests the same thing for non-parametrized tests.
|
||||||
class MacroNamingTestNonParametrized : public ::testing::Test {};
|
class MacroNamingTestNonParametrized : public ::testing::Test {};
|
||||||
@ -818,7 +815,7 @@ TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized),
|
|||||||
const ::testing::TestInfo* const test_info =
|
const ::testing::TestInfo* const test_info =
|
||||||
::testing::UnitTest::GetInstance()->current_test_info();
|
::testing::UnitTest::GetInstance()->current_test_info();
|
||||||
|
|
||||||
EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_case_name());
|
EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_suite_name());
|
||||||
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
EXPECT_STREQ("FooSomeTestName", test_info->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,17 +832,14 @@ struct CustomParamNameFunctor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(CustomParamNameFunctor,
|
INSTANTIATE_TEST_SUITE_P(CustomParamNameFunctor, CustomFunctorNamingTest,
|
||||||
CustomFunctorNamingTest,
|
Values(std::string("FunctorName")),
|
||||||
Values(std::string("FunctorName")),
|
CustomParamNameFunctor());
|
||||||
CustomParamNameFunctor());
|
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(AllAllowedCharacters,
|
INSTANTIATE_TEST_SUITE_P(AllAllowedCharacters, CustomFunctorNamingTest,
|
||||||
CustomFunctorNamingTest,
|
Values("abcdefghijklmnopqrstuvwxyz",
|
||||||
Values("abcdefghijklmnopqrstuvwxyz",
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "01234567890_"),
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
CustomParamNameFunctor());
|
||||||
"01234567890_"),
|
|
||||||
CustomParamNameFunctor());
|
|
||||||
|
|
||||||
inline std::string CustomParamNameFunction(
|
inline std::string CustomParamNameFunction(
|
||||||
const ::testing::TestParamInfo<std::string>& inf) {
|
const ::testing::TestParamInfo<std::string>& inf) {
|
||||||
@ -855,33 +849,30 @@ inline std::string CustomParamNameFunction(
|
|||||||
class CustomFunctionNamingTest : public TestWithParam<std::string> {};
|
class CustomFunctionNamingTest : public TestWithParam<std::string> {};
|
||||||
TEST_P(CustomFunctionNamingTest, CustomTestNames) {}
|
TEST_P(CustomFunctionNamingTest, CustomTestNames) {}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(CustomParamNameFunction,
|
INSTANTIATE_TEST_SUITE_P(CustomParamNameFunction, CustomFunctionNamingTest,
|
||||||
CustomFunctionNamingTest,
|
Values(std::string("FunctionName")),
|
||||||
Values(std::string("FunctionName")),
|
CustomParamNameFunction);
|
||||||
CustomParamNameFunction);
|
|
||||||
|
|
||||||
// Test custom naming with a lambda
|
// Test custom naming with a lambda
|
||||||
|
|
||||||
class CustomLambdaNamingTest : public TestWithParam<std::string> {};
|
class CustomLambdaNamingTest : public TestWithParam<std::string> {};
|
||||||
TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
|
TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest,
|
INSTANTIATE_TEST_SUITE_P(CustomParamNameLambda, CustomLambdaNamingTest,
|
||||||
Values(std::string("LambdaName")),
|
Values(std::string("LambdaName")),
|
||||||
[](const ::testing::TestParamInfo<std::string>& inf) {
|
[](const ::testing::TestParamInfo<std::string>& inf) {
|
||||||
return inf.param;
|
return inf.param;
|
||||||
});
|
});
|
||||||
|
|
||||||
TEST(CustomNamingTest, CheckNameRegistry) {
|
TEST(CustomNamingTest, CheckNameRegistry) {
|
||||||
::testing::UnitTest* unit_test = ::testing::UnitTest::GetInstance();
|
::testing::UnitTest* unit_test = ::testing::UnitTest::GetInstance();
|
||||||
std::set<std::string> test_names;
|
std::set<std::string> test_names;
|
||||||
for (int case_num = 0;
|
for (int suite_num = 0; suite_num < unit_test->total_test_suite_count();
|
||||||
case_num < unit_test->total_test_case_count();
|
++suite_num) {
|
||||||
++case_num) {
|
const ::testing::TestSuite* test_suite = unit_test->GetTestSuite(suite_num);
|
||||||
const ::testing::TestCase* test_case = unit_test->GetTestCase(case_num);
|
for (int test_num = 0; test_num < test_suite->total_test_count();
|
||||||
for (int test_num = 0;
|
|
||||||
test_num < test_case->total_test_count();
|
|
||||||
++test_num) {
|
++test_num) {
|
||||||
const ::testing::TestInfo* test_info = test_case->GetTestInfo(test_num);
|
const ::testing::TestInfo* test_info = test_suite->GetTestInfo(test_num);
|
||||||
test_names.insert(std::string(test_info->name()));
|
test_names.insert(std::string(test_info->name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -902,10 +893,8 @@ TEST_P(CustomIntegerNamingTest, TestsReportCorrectNames) {
|
|||||||
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(PrintToString,
|
INSTANTIATE_TEST_SUITE_P(PrintToString, CustomIntegerNamingTest, Range(0, 5),
|
||||||
CustomIntegerNamingTest,
|
::testing::PrintToStringParamName());
|
||||||
Range(0, 5),
|
|
||||||
::testing::PrintToStringParamName());
|
|
||||||
|
|
||||||
// Test a custom struct with PrintToString.
|
// Test a custom struct with PrintToString.
|
||||||
|
|
||||||
@ -929,10 +918,9 @@ TEST_P(CustomStructNamingTest, TestsReportCorrectNames) {
|
|||||||
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(PrintToString,
|
INSTANTIATE_TEST_SUITE_P(PrintToString, CustomStructNamingTest,
|
||||||
CustomStructNamingTest,
|
Values(CustomStruct(0), CustomStruct(1)),
|
||||||
Values(CustomStruct(0), CustomStruct(1)),
|
::testing::PrintToStringParamName());
|
||||||
::testing::PrintToStringParamName());
|
|
||||||
|
|
||||||
// Test that using a stateful parameter naming function works as expected.
|
// Test that using a stateful parameter naming function works as expected.
|
||||||
|
|
||||||
@ -961,10 +949,8 @@ TEST_P(StatefulNamingTest, TestsReportCorrectNames) {
|
|||||||
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(StatefulNamingFunctor,
|
INSTANTIATE_TEST_SUITE_P(StatefulNamingFunctor, StatefulNamingTest, Range(0, 5),
|
||||||
StatefulNamingTest,
|
StatefulNamingFunctor());
|
||||||
Range(0, 5),
|
|
||||||
StatefulNamingFunctor());
|
|
||||||
|
|
||||||
// Class that cannot be streamed into an ostream. It needs to be copyable
|
// Class that cannot be streamed into an ostream. It needs to be copyable
|
||||||
// (and, in case of MSVC, also assignable) in order to be a test parameter
|
// (and, in case of MSVC, also assignable) in order to be a test parameter
|
||||||
@ -987,9 +973,8 @@ TEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {
|
|||||||
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
|
EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(InstantiationWithComments,
|
INSTANTIATE_TEST_SUITE_P(InstantiationWithComments, CommentTest,
|
||||||
CommentTest,
|
Values(Unstreamable(1)));
|
||||||
Values(Unstreamable(1)));
|
|
||||||
|
|
||||||
// Verify that we can create a hierarchy of test fixtures, where the base
|
// Verify that we can create a hierarchy of test fixtures, where the base
|
||||||
// class fixture is not parameterized and the derived class is. In this case
|
// class fixture is not parameterized and the derived class is. In this case
|
||||||
@ -1029,7 +1014,8 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
|
|||||||
".* value-parameterized test .*");
|
".* value-parameterized test .*");
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
|
INSTANTIATE_TEST_SUITE_P(RangeZeroToFive, ParameterizedDerivedTest,
|
||||||
|
Range(0, 5));
|
||||||
|
|
||||||
// Tests param generator working with Enums
|
// Tests param generator working with Enums
|
||||||
enum MyEnums {
|
enum MyEnums {
|
||||||
@ -1041,19 +1027,19 @@ enum MyEnums {
|
|||||||
class MyEnumTest : public testing::TestWithParam<MyEnums> {};
|
class MyEnumTest : public testing::TestWithParam<MyEnums> {};
|
||||||
|
|
||||||
TEST_P(MyEnumTest, ChecksParamMoreThanZero) { EXPECT_GE(10, GetParam()); }
|
TEST_P(MyEnumTest, ChecksParamMoreThanZero) { EXPECT_GE(10, GetParam()); }
|
||||||
INSTANTIATE_TEST_CASE_P(MyEnumTests, MyEnumTest,
|
INSTANTIATE_TEST_SUITE_P(MyEnumTests, MyEnumTest,
|
||||||
::testing::Values(ENUM1, ENUM2, 0));
|
::testing::Values(ENUM1, ENUM2, 0));
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
// Used in TestGenerationTest test case.
|
// Used in TestGenerationTest test suite.
|
||||||
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
|
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
|
||||||
// Used in GeneratorEvaluationTest test case. Tests that the updated value
|
// Used in GeneratorEvaluationTest test suite. Tests that the updated value
|
||||||
// will be picked up for instantiating tests in GeneratorEvaluationTest.
|
// will be picked up for instantiating tests in GeneratorEvaluationTest.
|
||||||
GeneratorEvaluationTest::set_param_value(1);
|
GeneratorEvaluationTest::set_param_value(1);
|
||||||
|
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
// Used in GeneratorEvaluationTest test case. Tests that value updated
|
// Used in GeneratorEvaluationTest test suite. Tests that value updated
|
||||||
// here will NOT be used for instantiating tests in
|
// here will NOT be used for instantiating tests in
|
||||||
// GeneratorEvaluationTest.
|
// GeneratorEvaluationTest.
|
||||||
GeneratorEvaluationTest::set_param_value(2);
|
GeneratorEvaluationTest::set_param_value(2);
|
||||||
|
@ -44,7 +44,7 @@ class ExternalInstantiationTest : public ::testing::TestWithParam<int> {
|
|||||||
|
|
||||||
// Test fixture for testing instantiation of a test in multiple
|
// Test fixture for testing instantiation of a test in multiple
|
||||||
// translation units.
|
// translation units.
|
||||||
class InstantiationInMultipleTranslaionUnitsTest
|
class InstantiationInMultipleTranslationUnitsTest
|
||||||
: public ::testing::TestWithParam<int> {
|
: public ::testing::TestWithParam<int> {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,16 +46,16 @@ ParamGenerator<int> extern_gen = Values(33);
|
|||||||
// and instantiated in another. The test is defined in
|
// and instantiated in another. The test is defined in
|
||||||
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
|
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
|
||||||
// defined in gtest-param-test_test.h.
|
// defined in gtest-param-test_test.h.
|
||||||
INSTANTIATE_TEST_CASE_P(MultiplesOf33,
|
INSTANTIATE_TEST_SUITE_P(MultiplesOf33,
|
||||||
ExternalInstantiationTest,
|
ExternalInstantiationTest,
|
||||||
Values(33, 66));
|
Values(33, 66));
|
||||||
|
|
||||||
// Tests that a parameterized test case can be instantiated
|
// Tests that a parameterized test case can be instantiated
|
||||||
// in multiple translation units. Another instantiation is defined
|
// in multiple translation units. Another instantiation is defined
|
||||||
// in googletest-param-test-test.cc and
|
// in googletest-param-test-test.cc and
|
||||||
// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
|
// InstantiationInMultipleTranslationUnitsTest fixture is defined in
|
||||||
// gtest-param-test_test.h
|
// gtest-param-test_test.h
|
||||||
INSTANTIATE_TEST_CASE_P(Sequence2,
|
INSTANTIATE_TEST_SUITE_P(Sequence2,
|
||||||
InstantiationInMultipleTranslaionUnitsTest,
|
InstantiationInMultipleTranslationUnitsTest,
|
||||||
Values(42*3, 42*4, 42*5));
|
Values(42*3, 42*4, 42*5));
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ typedef testing::Types<
|
|||||||
# endif // GTEST_HAS_GLOBAL_STRING
|
# endif // GTEST_HAS_GLOBAL_STRING
|
||||||
const char*> StringTypes;
|
const char*> StringTypes;
|
||||||
|
|
||||||
TYPED_TEST_CASE(RETest, StringTypes);
|
TYPED_TEST_SUITE(RETest, StringTypes);
|
||||||
|
|
||||||
// Tests RE's implicit constructors.
|
// Tests RE's implicit constructors.
|
||||||
TYPED_TEST(RETest, ImplicitConstructorWorks) {
|
TYPED_TEST(RETest, ImplicitConstructorWorks) {
|
||||||
|
@ -46,16 +46,16 @@ ParamGenerator<int> extern_gen_2 = Values(33);
|
|||||||
// and instantiated in another. The test is defined in
|
// and instantiated in another. The test is defined in
|
||||||
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
|
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
|
||||||
// defined in gtest-param-test_test.h.
|
// defined in gtest-param-test_test.h.
|
||||||
INSTANTIATE_TEST_CASE_P(MultiplesOf33,
|
INSTANTIATE_TEST_SUITE_P(MultiplesOf33,
|
||||||
ExternalInstantiationTest,
|
ExternalInstantiationTest,
|
||||||
Values(33, 66));
|
Values(33, 66));
|
||||||
|
|
||||||
// Tests that a parameterized test case can be instantiated
|
// Tests that a parameterized test case can be instantiated
|
||||||
// in multiple translation units. Another instantiation is defined
|
// in multiple translation units. Another instantiation is defined
|
||||||
// in googletest-param-test-test.cc and
|
// in googletest-param-test-test.cc and
|
||||||
// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
|
// InstantiationInMultipleTranslationUnitsTest fixture is defined in
|
||||||
// gtest-param-test_test.h
|
// gtest-param-test_test.h
|
||||||
INSTANTIATE_TEST_CASE_P(Sequence2,
|
INSTANTIATE_TEST_SUITE_P(Sequence2,
|
||||||
InstantiationInMultipleTranslaionUnitsTest,
|
InstantiationInMultipleTranslationUnitsTest,
|
||||||
Values(42*3, 42*4, 42*5));
|
Values(42*3, 42*4, 42*5));
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
// Tests that the same type-parameterized test case can be
|
// Tests that the same type-parameterized test case can be
|
||||||
// instantiated in different translation units linked together.
|
// instantiated in different translation units linked together.
|
||||||
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
|
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest,
|
INSTANTIATE_TYPED_TEST_SUITE_P(Vector, ContainerTest,
|
||||||
testing::Types<std::vector<int> >);
|
testing::Types<std::vector<int> >);
|
||||||
|
|
||||||
#endif // GTEST_HAS_TYPED_TEST_P
|
#endif // GTEST_HAS_TYPED_TEST_P
|
||||||
|
@ -41,19 +41,19 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127 /* conditional expression is constant */)
|
|||||||
|
|
||||||
using testing::Test;
|
using testing::Test;
|
||||||
|
|
||||||
// Used for testing that SetUpTestCase()/TearDownTestCase(), fixture
|
// Used for testing that SetUpTestSuite()/TearDownTestSuite(), fixture
|
||||||
// ctor/dtor, and SetUp()/TearDown() work correctly in typed tests and
|
// ctor/dtor, and SetUp()/TearDown() work correctly in typed tests and
|
||||||
// type-parameterized test.
|
// type-parameterized test.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class CommonTest : public Test {
|
class CommonTest : public Test {
|
||||||
// For some technical reason, SetUpTestCase() and TearDownTestCase()
|
// For some technical reason, SetUpTestSuite() and TearDownTestSuite()
|
||||||
// must be public.
|
// must be public.
|
||||||
public:
|
public:
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestSuite() {
|
||||||
shared_ = new T(5);
|
shared_ = new T(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestCase() {
|
static void TearDownTestSuite() {
|
||||||
delete shared_;
|
delete shared_;
|
||||||
shared_ = nullptr;
|
shared_ = nullptr;
|
||||||
}
|
}
|
||||||
@ -92,11 +92,11 @@ T* CommonTest<T>::shared_ = nullptr;
|
|||||||
|
|
||||||
using testing::Types;
|
using testing::Types;
|
||||||
|
|
||||||
// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,
|
// Tests that SetUpTestSuite()/TearDownTestSuite(), fixture ctor/dtor,
|
||||||
// and SetUp()/TearDown() work correctly in typed tests
|
// and SetUp()/TearDown() work correctly in typed tests
|
||||||
|
|
||||||
typedef Types<char, int> TwoTypes;
|
typedef Types<char, int> TwoTypes;
|
||||||
TYPED_TEST_CASE(CommonTest, TwoTypes);
|
TYPED_TEST_SUITE(CommonTest, TwoTypes);
|
||||||
|
|
||||||
TYPED_TEST(CommonTest, ValuesAreCorrect) {
|
TYPED_TEST(CommonTest, ValuesAreCorrect) {
|
||||||
// Static members of the fixture class template can be visited via
|
// Static members of the fixture class template can be visited via
|
||||||
@ -128,25 +128,25 @@ TYPED_TEST(CommonTest, ValuesAreStillCorrect) {
|
|||||||
EXPECT_EQ(static_cast<TypeParam>(2), this->value_);
|
EXPECT_EQ(static_cast<TypeParam>(2), this->value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that multiple TYPED_TEST_CASE's can be defined in the same
|
// Tests that multiple TYPED_TEST_SUITE's can be defined in the same
|
||||||
// translation unit.
|
// translation unit.
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypedTest1 : public Test {
|
class TypedTest1 : public Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Verifies that the second argument of TYPED_TEST_CASE can be a
|
// Verifies that the second argument of TYPED_TEST_SUITE can be a
|
||||||
// single type.
|
// single type.
|
||||||
TYPED_TEST_CASE(TypedTest1, int);
|
TYPED_TEST_SUITE(TypedTest1, int);
|
||||||
TYPED_TEST(TypedTest1, A) {}
|
TYPED_TEST(TypedTest1, A) {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypedTest2 : public Test {
|
class TypedTest2 : public Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Verifies that the second argument of TYPED_TEST_CASE can be a
|
// Verifies that the second argument of TYPED_TEST_SUITE can be a
|
||||||
// Types<...> type list.
|
// Types<...> type list.
|
||||||
TYPED_TEST_CASE(TypedTest2, Types<int>);
|
TYPED_TEST_SUITE(TypedTest2, Types<int>);
|
||||||
|
|
||||||
// This also verifies that tests from different typed test cases can
|
// This also verifies that tests from different typed test cases can
|
||||||
// share the same name.
|
// share the same name.
|
||||||
@ -161,7 +161,7 @@ class NumericTest : public Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef Types<int, long> NumericTypes;
|
typedef Types<int, long> NumericTypes;
|
||||||
TYPED_TEST_CASE(NumericTest, NumericTypes);
|
TYPED_TEST_SUITE(NumericTest, NumericTypes);
|
||||||
|
|
||||||
TYPED_TEST(NumericTest, DefaultIsZero) {
|
TYPED_TEST(NumericTest, DefaultIsZero) {
|
||||||
EXPECT_EQ(0, TypeParam());
|
EXPECT_EQ(0, TypeParam());
|
||||||
@ -186,9 +186,9 @@ class TypedTestNames {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE(TypedTestWithNames, TwoTypes, TypedTestNames);
|
TYPED_TEST_SUITE(TypedTestWithNames, TwoTypes, TypedTestNames);
|
||||||
|
|
||||||
TYPED_TEST(TypedTestWithNames, TestCaseName) {
|
TYPED_TEST(TypedTestWithNames, TestSuiteName) {
|
||||||
if (testing::internal::IsSame<TypeParam, char>::value) {
|
if (testing::internal::IsSame<TypeParam, char>::value) {
|
||||||
EXPECT_STREQ(::testing::UnitTest::GetInstance()
|
EXPECT_STREQ(::testing::UnitTest::GetInstance()
|
||||||
->current_test_info()
|
->current_test_info()
|
||||||
@ -209,11 +209,11 @@ TYPED_TEST(TypedTestWithNames, TestCaseName) {
|
|||||||
#if GTEST_HAS_TYPED_TEST_P
|
#if GTEST_HAS_TYPED_TEST_P
|
||||||
|
|
||||||
using testing::Types;
|
using testing::Types;
|
||||||
using testing::internal::TypedTestCasePState;
|
using testing::internal::TypedTestSuitePState;
|
||||||
|
|
||||||
// Tests TypedTestCasePState.
|
// Tests TypedTestSuitePState.
|
||||||
|
|
||||||
class TypedTestCasePStateTest : public Test {
|
class TypedTestSuitePStateTest : public Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
state_.AddTestName("foo.cc", 0, "FooTest", "A");
|
state_.AddTestName("foo.cc", 0, "FooTest", "A");
|
||||||
@ -221,10 +221,10 @@ class TypedTestCasePStateTest : public Test {
|
|||||||
state_.AddTestName("foo.cc", 0, "FooTest", "C");
|
state_.AddTestName("foo.cc", 0, "FooTest", "C");
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedTestCasePState state_;
|
TypedTestSuitePState state_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(TypedTestCasePStateTest, SucceedsForMatchingList) {
|
TEST_F(TypedTestSuitePStateTest, SucceedsForMatchingList) {
|
||||||
const char* tests = "A, B, C";
|
const char* tests = "A, B, C";
|
||||||
EXPECT_EQ(tests,
|
EXPECT_EQ(tests,
|
||||||
state_.VerifyRegisteredTestNames("foo.cc", 1, tests));
|
state_.VerifyRegisteredTestNames("foo.cc", 1, tests));
|
||||||
@ -232,27 +232,27 @@ TEST_F(TypedTestCasePStateTest, SucceedsForMatchingList) {
|
|||||||
|
|
||||||
// Makes sure that the order of the tests and spaces around the names
|
// Makes sure that the order of the tests and spaces around the names
|
||||||
// don't matter.
|
// don't matter.
|
||||||
TEST_F(TypedTestCasePStateTest, IgnoresOrderAndSpaces) {
|
TEST_F(TypedTestSuitePStateTest, IgnoresOrderAndSpaces) {
|
||||||
const char* tests = "A,C, B";
|
const char* tests = "A,C, B";
|
||||||
EXPECT_EQ(tests,
|
EXPECT_EQ(tests,
|
||||||
state_.VerifyRegisteredTestNames("foo.cc", 1, tests));
|
state_.VerifyRegisteredTestNames("foo.cc", 1, tests));
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef TypedTestCasePStateTest TypedTestCasePStateDeathTest;
|
using TypedTestSuitePStateDeathTest = TypedTestSuitePStateTest;
|
||||||
|
|
||||||
TEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) {
|
TEST_F(TypedTestSuitePStateDeathTest, DetectsDuplicates) {
|
||||||
EXPECT_DEATH_IF_SUPPORTED(
|
EXPECT_DEATH_IF_SUPPORTED(
|
||||||
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, A, C"),
|
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, A, C"),
|
||||||
"foo\\.cc.1.?: Test A is listed more than once\\.");
|
"foo\\.cc.1.?: Test A is listed more than once\\.");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) {
|
TEST_F(TypedTestSuitePStateDeathTest, 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 suite\\.");
|
"foo\\.cc.1.?: No test named D can be found in this test suite\\.");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {
|
TEST_F(TypedTestSuitePStateDeathTest, DetectsMissedTest) {
|
||||||
EXPECT_DEATH_IF_SUPPORTED(
|
EXPECT_DEATH_IF_SUPPORTED(
|
||||||
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, C"),
|
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, C"),
|
||||||
"foo\\.cc.1.?: You forgot to list test B\\.");
|
"foo\\.cc.1.?: You forgot to list test B\\.");
|
||||||
@ -260,7 +260,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {
|
|||||||
|
|
||||||
// Tests that defining a test for a parameterized test case generates
|
// Tests that defining a test for a parameterized test case generates
|
||||||
// a run-time error if the test case has been registered.
|
// a run-time error if the test case has been registered.
|
||||||
TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
|
TEST_F(TypedTestSuitePStateDeathTest, 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"),
|
||||||
@ -268,14 +268,14 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
|
|||||||
"\\(FooTest, \\.\\.\\.\\)\\.");
|
"\\(FooTest, \\.\\.\\.\\)\\.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,
|
// Tests that SetUpTestSuite()/TearDownTestSuite(), fixture ctor/dtor,
|
||||||
// and SetUp()/TearDown() work correctly in type-parameterized tests.
|
// and SetUp()/TearDown() work correctly in type-parameterized tests.
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class DerivedTest : public CommonTest<T> {
|
class DerivedTest : public CommonTest<T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(DerivedTest);
|
TYPED_TEST_SUITE_P(DerivedTest);
|
||||||
|
|
||||||
TYPED_TEST_P(DerivedTest, ValuesAreCorrect) {
|
TYPED_TEST_P(DerivedTest, ValuesAreCorrect) {
|
||||||
// Static members of the fixture class template can be visited via
|
// Static members of the fixture class template can be visited via
|
||||||
@ -297,20 +297,20 @@ TYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) {
|
|||||||
EXPECT_EQ(2, this->value_);
|
EXPECT_EQ(2, this->value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(DerivedTest,
|
REGISTER_TYPED_TEST_SUITE_P(DerivedTest,
|
||||||
ValuesAreCorrect, ValuesAreStillCorrect);
|
ValuesAreCorrect, ValuesAreStillCorrect);
|
||||||
|
|
||||||
typedef Types<short, long> MyTwoTypes;
|
typedef Types<short, long> MyTwoTypes;
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(My, DerivedTest, MyTwoTypes);
|
INSTANTIATE_TYPED_TEST_SUITE_P(My, DerivedTest, MyTwoTypes);
|
||||||
|
|
||||||
// Tests that custom names work with type parametrized tests. We reuse the
|
// Tests that custom names work with type parametrized tests. We reuse the
|
||||||
// TwoTypes from above here.
|
// TwoTypes from above here.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypeParametrizedTestWithNames : public Test {};
|
class TypeParametrizedTestWithNames : public Test {};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(TypeParametrizedTestWithNames);
|
TYPED_TEST_SUITE_P(TypeParametrizedTestWithNames);
|
||||||
|
|
||||||
TYPED_TEST_P(TypeParametrizedTestWithNames, TestCaseName) {
|
TYPED_TEST_P(TypeParametrizedTestWithNames, TestSuiteName) {
|
||||||
if (testing::internal::IsSame<TypeParam, char>::value) {
|
if (testing::internal::IsSame<TypeParam, char>::value) {
|
||||||
EXPECT_STREQ(::testing::UnitTest::GetInstance()
|
EXPECT_STREQ(::testing::UnitTest::GetInstance()
|
||||||
->current_test_info()
|
->current_test_info()
|
||||||
@ -325,7 +325,7 @@ TYPED_TEST_P(TypeParametrizedTestWithNames, TestCaseName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(TypeParametrizedTestWithNames, TestCaseName);
|
REGISTER_TYPED_TEST_SUITE_P(TypeParametrizedTestWithNames, TestSuiteName);
|
||||||
|
|
||||||
class TypeParametrizedTestNames {
|
class TypeParametrizedTestNames {
|
||||||
public:
|
public:
|
||||||
@ -340,62 +340,62 @@ class TypeParametrizedTestNames {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(CustomName, TypeParametrizedTestWithNames,
|
INSTANTIATE_TYPED_TEST_SUITE_P(CustomName, TypeParametrizedTestWithNames,
|
||||||
TwoTypes, TypeParametrizedTestNames);
|
TwoTypes, TypeParametrizedTestNames);
|
||||||
|
|
||||||
// Tests that multiple TYPED_TEST_CASE_P's can be defined in the same
|
// Tests that multiple TYPED_TEST_SUITE_P's can be defined in the same
|
||||||
// translation unit.
|
// translation unit.
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypedTestP1 : public Test {
|
class TypedTestP1 : public Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(TypedTestP1);
|
TYPED_TEST_SUITE_P(TypedTestP1);
|
||||||
|
|
||||||
// For testing that the code between TYPED_TEST_CASE_P() and
|
// For testing that the code between TYPED_TEST_SUITE_P() and
|
||||||
// TYPED_TEST_P() is not enclosed in a namespace.
|
// TYPED_TEST_P() is not enclosed in a namespace.
|
||||||
typedef int IntAfterTypedTestCaseP;
|
using IntAfterTypedTestSuiteP = int;
|
||||||
|
|
||||||
TYPED_TEST_P(TypedTestP1, A) {}
|
TYPED_TEST_P(TypedTestP1, A) {}
|
||||||
TYPED_TEST_P(TypedTestP1, B) {}
|
TYPED_TEST_P(TypedTestP1, B) {}
|
||||||
|
|
||||||
// For testing that the code between TYPED_TEST_P() and
|
// For testing that the code between TYPED_TEST_P() and
|
||||||
// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.
|
// REGISTER_TYPED_TEST_SUITE_P() is not enclosed in a namespace.
|
||||||
typedef int IntBeforeRegisterTypedTestCaseP;
|
using IntBeforeRegisterTypedTestSuiteP = int;
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(TypedTestP1, A, B);
|
REGISTER_TYPED_TEST_SUITE_P(TypedTestP1, A, B);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypedTestP2 : public Test {
|
class TypedTestP2 : public Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(TypedTestP2);
|
TYPED_TEST_SUITE_P(TypedTestP2);
|
||||||
|
|
||||||
// This also verifies that tests from different type-parameterized
|
// This also verifies that tests from different type-parameterized
|
||||||
// test cases can share the same name.
|
// test cases can share the same name.
|
||||||
TYPED_TEST_P(TypedTestP2, A) {}
|
TYPED_TEST_P(TypedTestP2, A) {}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(TypedTestP2, A);
|
REGISTER_TYPED_TEST_SUITE_P(TypedTestP2, A);
|
||||||
|
|
||||||
// Verifies that the code between TYPED_TEST_CASE_P() and
|
// Verifies that the code between TYPED_TEST_SUITE_P() and
|
||||||
// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.
|
// REGISTER_TYPED_TEST_SUITE_P() is not enclosed in a namespace.
|
||||||
IntAfterTypedTestCaseP after = 0;
|
IntAfterTypedTestSuiteP after = 0;
|
||||||
IntBeforeRegisterTypedTestCaseP before = 0;
|
IntBeforeRegisterTypedTestSuiteP before = 0;
|
||||||
|
|
||||||
// Verifies that the last argument of INSTANTIATE_TYPED_TEST_CASE_P()
|
// Verifies that the last argument of INSTANTIATE_TYPED_TEST_SUITE_P()
|
||||||
// can be either a single type or a Types<...> type list.
|
// can be either a single type or a Types<...> type list.
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP1, int);
|
INSTANTIATE_TYPED_TEST_SUITE_P(Int, TypedTestP1, int);
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP2, Types<int>);
|
INSTANTIATE_TYPED_TEST_SUITE_P(Int, TypedTestP2, Types<int>);
|
||||||
|
|
||||||
// Tests that the same type-parameterized test case can be
|
// Tests that the same type-parameterized test case can be
|
||||||
// instantiated more than once in the same translation unit.
|
// instantiated more than once in the same translation unit.
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(Double, TypedTestP2, Types<double>);
|
INSTANTIATE_TYPED_TEST_SUITE_P(Double, TypedTestP2, Types<double>);
|
||||||
|
|
||||||
// Tests that the same type-parameterized test case can be
|
// Tests that the same type-parameterized test case can be
|
||||||
// instantiated in different translation units linked together.
|
// instantiated in different translation units linked together.
|
||||||
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
|
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
|
||||||
typedef Types<std::vector<double>, std::set<char> > MyContainers;
|
typedef Types<std::vector<double>, std::set<char> > MyContainers;
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(My, ContainerTest, MyContainers);
|
INSTANTIATE_TYPED_TEST_SUITE_P(My, ContainerTest, MyContainers);
|
||||||
|
|
||||||
// Tests that a type-parameterized test case can be defined and
|
// Tests that a type-parameterized test case can be defined and
|
||||||
// instantiated in a namespace.
|
// instantiated in a namespace.
|
||||||
@ -406,7 +406,7 @@ template <typename T>
|
|||||||
class NumericTest : public Test {
|
class NumericTest : public Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(NumericTest);
|
TYPED_TEST_SUITE_P(NumericTest);
|
||||||
|
|
||||||
TYPED_TEST_P(NumericTest, DefaultIsZero) {
|
TYPED_TEST_P(NumericTest, DefaultIsZero) {
|
||||||
EXPECT_EQ(0, TypeParam());
|
EXPECT_EQ(0, TypeParam());
|
||||||
@ -416,29 +416,29 @@ TYPED_TEST_P(NumericTest, ZeroIsLessThanOne) {
|
|||||||
EXPECT_LT(TypeParam(0), TypeParam(1));
|
EXPECT_LT(TypeParam(0), TypeParam(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(NumericTest,
|
REGISTER_TYPED_TEST_SUITE_P(NumericTest,
|
||||||
DefaultIsZero, ZeroIsLessThanOne);
|
DefaultIsZero, ZeroIsLessThanOne);
|
||||||
typedef Types<int, double> NumericTypes;
|
typedef Types<int, double> NumericTypes;
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(My, NumericTest, NumericTypes);
|
INSTANTIATE_TYPED_TEST_SUITE_P(My, NumericTest, NumericTypes);
|
||||||
|
|
||||||
static const char* GetTestName() {
|
static const char* GetTestName() {
|
||||||
return testing::UnitTest::GetInstance()->current_test_info()->name();
|
return testing::UnitTest::GetInstance()->current_test_info()->name();
|
||||||
}
|
}
|
||||||
// Test the stripping of space from test names
|
// Test the stripping of space from test names
|
||||||
template <typename T> class TrimmedTest : public Test { };
|
template <typename T> class TrimmedTest : public Test { };
|
||||||
TYPED_TEST_CASE_P(TrimmedTest);
|
TYPED_TEST_SUITE_P(TrimmedTest);
|
||||||
TYPED_TEST_P(TrimmedTest, Test1) { EXPECT_STREQ("Test1", GetTestName()); }
|
TYPED_TEST_P(TrimmedTest, Test1) { EXPECT_STREQ("Test1", GetTestName()); }
|
||||||
TYPED_TEST_P(TrimmedTest, Test2) { EXPECT_STREQ("Test2", GetTestName()); }
|
TYPED_TEST_P(TrimmedTest, Test2) { EXPECT_STREQ("Test2", GetTestName()); }
|
||||||
TYPED_TEST_P(TrimmedTest, Test3) { EXPECT_STREQ("Test3", GetTestName()); }
|
TYPED_TEST_P(TrimmedTest, Test3) { EXPECT_STREQ("Test3", GetTestName()); }
|
||||||
TYPED_TEST_P(TrimmedTest, Test4) { EXPECT_STREQ("Test4", GetTestName()); }
|
TYPED_TEST_P(TrimmedTest, Test4) { EXPECT_STREQ("Test4", GetTestName()); }
|
||||||
TYPED_TEST_P(TrimmedTest, Test5) { EXPECT_STREQ("Test5", GetTestName()); }
|
TYPED_TEST_P(TrimmedTest, Test5) { EXPECT_STREQ("Test5", GetTestName()); }
|
||||||
REGISTER_TYPED_TEST_CASE_P(
|
REGISTER_TYPED_TEST_SUITE_P(
|
||||||
TrimmedTest,
|
TrimmedTest,
|
||||||
Test1, Test2,Test3 , Test4 ,Test5 ); // NOLINT
|
Test1, Test2,Test3 , Test4 ,Test5 ); // NOLINT
|
||||||
template <typename T1, typename T2> struct MyPair {};
|
template <typename T1, typename T2> struct MyPair {};
|
||||||
// Be sure to try a type with a comma in its name just in case it matters.
|
// Be sure to try a type with a comma in its name just in case it matters.
|
||||||
typedef Types<int, double, MyPair<int, int> > TrimTypes;
|
typedef Types<int, double, MyPair<int, int> > TrimTypes;
|
||||||
INSTANTIATE_TYPED_TEST_CASE_P(My, TrimmedTest, TrimTypes);
|
INSTANTIATE_TYPED_TEST_SUITE_P(My, TrimmedTest, TrimTypes);
|
||||||
|
|
||||||
} // namespace library2
|
} // namespace library2
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ template <typename T>
|
|||||||
class ContainerTest : public Test {
|
class ContainerTest : public Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
TYPED_TEST_CASE_P(ContainerTest);
|
TYPED_TEST_SUITE_P(ContainerTest);
|
||||||
|
|
||||||
TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) {
|
TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) {
|
||||||
TypeParam container;
|
TypeParam container;
|
||||||
@ -57,8 +57,8 @@ TYPED_TEST_P(ContainerTest, InitialSizeIsZero) {
|
|||||||
EXPECT_EQ(0U, container.size());
|
EXPECT_EQ(0U, container.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPED_TEST_CASE_P(ContainerTest,
|
REGISTER_TYPED_TEST_SUITE_P(ContainerTest,
|
||||||
CanBeDefaultConstructed, InitialSizeIsZero);
|
CanBeDefaultConstructed, InitialSizeIsZero);
|
||||||
|
|
||||||
#endif // GTEST_HAS_TYPED_TEST_P
|
#endif // GTEST_HAS_TYPED_TEST_P
|
||||||
|
|
||||||
|
@ -51,59 +51,59 @@ struct LessByName {
|
|||||||
|
|
||||||
class UnitTestHelper {
|
class UnitTestHelper {
|
||||||
public:
|
public:
|
||||||
// Returns the array of pointers to all test cases sorted by the test case
|
// Returns the array of pointers to all test suites sorted by the test suite
|
||||||
// name. The caller is responsible for deleting the array.
|
// name. The caller is responsible for deleting the array.
|
||||||
static TestCase const** GetSortedTestCases() {
|
static TestSuite const** GetSortedTestSuites() {
|
||||||
UnitTest& unit_test = *UnitTest::GetInstance();
|
UnitTest& unit_test = *UnitTest::GetInstance();
|
||||||
TestCase const** const test_cases =
|
auto const** const test_suites =
|
||||||
new const TestCase*[unit_test.total_test_case_count()];
|
new const TestSuite*[unit_test.total_test_suite_count()];
|
||||||
|
|
||||||
for (int i = 0; i < unit_test.total_test_case_count(); ++i)
|
for (int i = 0; i < unit_test.total_test_suite_count(); ++i)
|
||||||
test_cases[i] = unit_test.GetTestCase(i);
|
test_suites[i] = unit_test.GetTestSuite(i);
|
||||||
|
|
||||||
std::sort(test_cases,
|
std::sort(test_suites,
|
||||||
test_cases + unit_test.total_test_case_count(),
|
test_suites + unit_test.total_test_suite_count(),
|
||||||
LessByName<TestCase>());
|
LessByName<TestSuite>());
|
||||||
return test_cases;
|
return test_suites;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the test case by its name. The caller doesn't own the returned
|
// Returns the test suite by its name. The caller doesn't own the returned
|
||||||
// pointer.
|
// pointer.
|
||||||
static const TestCase* FindTestCase(const char* name) {
|
static const TestSuite* FindTestSuite(const char* name) {
|
||||||
UnitTest& unit_test = *UnitTest::GetInstance();
|
UnitTest& unit_test = *UnitTest::GetInstance();
|
||||||
for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
|
for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
|
||||||
const TestCase* test_case = unit_test.GetTestCase(i);
|
const TestSuite* test_suite = unit_test.GetTestSuite(i);
|
||||||
if (0 == strcmp(test_case->name(), name))
|
if (0 == strcmp(test_suite->name(), name))
|
||||||
return test_case;
|
return test_suite;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the array of pointers to all tests in a particular test case
|
// Returns the array of pointers to all tests in a particular test suite
|
||||||
// sorted by the test name. The caller is responsible for deleting the
|
// sorted by the test name. The caller is responsible for deleting the
|
||||||
// array.
|
// array.
|
||||||
static TestInfo const** GetSortedTests(const TestCase* test_case) {
|
static TestInfo const** GetSortedTests(const TestSuite* test_suite) {
|
||||||
TestInfo const** const tests =
|
TestInfo const** const tests =
|
||||||
new const TestInfo*[test_case->total_test_count()];
|
new const TestInfo*[test_suite->total_test_count()];
|
||||||
|
|
||||||
for (int i = 0; i < test_case->total_test_count(); ++i)
|
for (int i = 0; i < test_suite->total_test_count(); ++i)
|
||||||
tests[i] = test_case->GetTestInfo(i);
|
tests[i] = test_suite->GetTestInfo(i);
|
||||||
|
|
||||||
std::sort(tests, tests + test_case->total_test_count(),
|
std::sort(tests, tests + test_suite->total_test_count(),
|
||||||
LessByName<TestInfo>());
|
LessByName<TestInfo>());
|
||||||
return tests;
|
return tests;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if GTEST_HAS_TYPED_TEST
|
#if GTEST_HAS_TYPED_TEST
|
||||||
template <typename T> class TestCaseWithCommentTest : public Test {};
|
template <typename T> class TestSuiteWithCommentTest : public Test {};
|
||||||
TYPED_TEST_CASE(TestCaseWithCommentTest, Types<int>);
|
TYPED_TEST_SUITE(TestSuiteWithCommentTest, Types<int>);
|
||||||
TYPED_TEST(TestCaseWithCommentTest, Dummy) {}
|
TYPED_TEST(TestSuiteWithCommentTest, Dummy) {}
|
||||||
|
|
||||||
const int kTypedTestCases = 1;
|
const int kTypedTestSuites = 1;
|
||||||
const int kTypedTests = 1;
|
const int kTypedTests = 1;
|
||||||
#else
|
#else
|
||||||
const int kTypedTestCases = 0;
|
const int kTypedTestSuites = 0;
|
||||||
const int kTypedTests = 0;
|
const int kTypedTests = 0;
|
||||||
#endif // GTEST_HAS_TYPED_TEST
|
#endif // GTEST_HAS_TYPED_TEST
|
||||||
|
|
||||||
@ -113,21 +113,21 @@ const int kTypedTests = 0;
|
|||||||
TEST(ApiTest, UnitTestImmutableAccessorsWork) {
|
TEST(ApiTest, UnitTestImmutableAccessorsWork) {
|
||||||
UnitTest* unit_test = UnitTest::GetInstance();
|
UnitTest* unit_test = UnitTest::GetInstance();
|
||||||
|
|
||||||
ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());
|
ASSERT_EQ(2 + kTypedTestSuites, unit_test->total_test_suite_count());
|
||||||
EXPECT_EQ(1 + kTypedTestCases, unit_test->test_case_to_run_count());
|
EXPECT_EQ(1 + kTypedTestSuites, unit_test->test_suite_to_run_count());
|
||||||
EXPECT_EQ(2, unit_test->disabled_test_count());
|
EXPECT_EQ(2, unit_test->disabled_test_count());
|
||||||
EXPECT_EQ(5 + kTypedTests, unit_test->total_test_count());
|
EXPECT_EQ(5 + kTypedTests, unit_test->total_test_count());
|
||||||
EXPECT_EQ(3 + kTypedTests, unit_test->test_to_run_count());
|
EXPECT_EQ(3 + kTypedTests, unit_test->test_to_run_count());
|
||||||
|
|
||||||
const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();
|
const TestSuite** const test_suites = UnitTestHelper::GetSortedTestSuites();
|
||||||
|
|
||||||
EXPECT_STREQ("ApiTest", test_cases[0]->name());
|
EXPECT_STREQ("ApiTest", test_suites[0]->name());
|
||||||
EXPECT_STREQ("DISABLED_Test", test_cases[1]->name());
|
EXPECT_STREQ("DISABLED_Test", test_suites[1]->name());
|
||||||
#if GTEST_HAS_TYPED_TEST
|
#if GTEST_HAS_TYPED_TEST
|
||||||
EXPECT_STREQ("TestCaseWithCommentTest/0", test_cases[2]->name());
|
EXPECT_STREQ("TestSuiteWithCommentTest/0", test_suites[2]->name());
|
||||||
#endif // GTEST_HAS_TYPED_TEST
|
#endif // GTEST_HAS_TYPED_TEST
|
||||||
|
|
||||||
delete[] test_cases;
|
delete[] test_suites;
|
||||||
|
|
||||||
// The following lines initiate actions to verify certain methods in
|
// The following lines initiate actions to verify certain methods in
|
||||||
// FinalSuccessChecker::TearDown.
|
// FinalSuccessChecker::TearDown.
|
||||||
@ -143,39 +143,39 @@ AssertionResult IsNull(const char* str) {
|
|||||||
return AssertionSuccess();
|
return AssertionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ApiTest, TestCaseImmutableAccessorsWork) {
|
TEST(ApiTest, TestSuiteImmutableAccessorsWork) {
|
||||||
const TestCase* test_case = UnitTestHelper::FindTestCase("ApiTest");
|
const TestSuite* test_suite = UnitTestHelper::FindTestSuite("ApiTest");
|
||||||
ASSERT_TRUE(test_case != nullptr);
|
ASSERT_TRUE(test_suite != nullptr);
|
||||||
|
|
||||||
EXPECT_STREQ("ApiTest", test_case->name());
|
EXPECT_STREQ("ApiTest", test_suite->name());
|
||||||
EXPECT_TRUE(IsNull(test_case->type_param()));
|
EXPECT_TRUE(IsNull(test_suite->type_param()));
|
||||||
EXPECT_TRUE(test_case->should_run());
|
EXPECT_TRUE(test_suite->should_run());
|
||||||
EXPECT_EQ(1, test_case->disabled_test_count());
|
EXPECT_EQ(1, test_suite->disabled_test_count());
|
||||||
EXPECT_EQ(3, test_case->test_to_run_count());
|
EXPECT_EQ(3, test_suite->test_to_run_count());
|
||||||
ASSERT_EQ(4, test_case->total_test_count());
|
ASSERT_EQ(4, test_suite->total_test_count());
|
||||||
|
|
||||||
const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);
|
const TestInfo** tests = UnitTestHelper::GetSortedTests(test_suite);
|
||||||
|
|
||||||
EXPECT_STREQ("DISABLED_Dummy1", tests[0]->name());
|
EXPECT_STREQ("DISABLED_Dummy1", tests[0]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[0]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[0]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[0]->value_param()));
|
EXPECT_TRUE(IsNull(tests[0]->value_param()));
|
||||||
EXPECT_TRUE(IsNull(tests[0]->type_param()));
|
EXPECT_TRUE(IsNull(tests[0]->type_param()));
|
||||||
EXPECT_FALSE(tests[0]->should_run());
|
EXPECT_FALSE(tests[0]->should_run());
|
||||||
|
|
||||||
EXPECT_STREQ("TestCaseDisabledAccessorsWork", tests[1]->name());
|
EXPECT_STREQ("TestSuiteDisabledAccessorsWork", tests[1]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[1]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[1]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[1]->value_param()));
|
EXPECT_TRUE(IsNull(tests[1]->value_param()));
|
||||||
EXPECT_TRUE(IsNull(tests[1]->type_param()));
|
EXPECT_TRUE(IsNull(tests[1]->type_param()));
|
||||||
EXPECT_TRUE(tests[1]->should_run());
|
EXPECT_TRUE(tests[1]->should_run());
|
||||||
|
|
||||||
EXPECT_STREQ("TestCaseImmutableAccessorsWork", tests[2]->name());
|
EXPECT_STREQ("TestSuiteImmutableAccessorsWork", tests[2]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[2]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[2]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[2]->value_param()));
|
EXPECT_TRUE(IsNull(tests[2]->value_param()));
|
||||||
EXPECT_TRUE(IsNull(tests[2]->type_param()));
|
EXPECT_TRUE(IsNull(tests[2]->type_param()));
|
||||||
EXPECT_TRUE(tests[2]->should_run());
|
EXPECT_TRUE(tests[2]->should_run());
|
||||||
|
|
||||||
EXPECT_STREQ("UnitTestImmutableAccessorsWork", tests[3]->name());
|
EXPECT_STREQ("UnitTestImmutableAccessorsWork", tests[3]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[3]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[3]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[3]->value_param()));
|
EXPECT_TRUE(IsNull(tests[3]->value_param()));
|
||||||
EXPECT_TRUE(IsNull(tests[3]->type_param()));
|
EXPECT_TRUE(IsNull(tests[3]->type_param()));
|
||||||
EXPECT_TRUE(tests[3]->should_run());
|
EXPECT_TRUE(tests[3]->should_run());
|
||||||
@ -184,20 +184,20 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
|
|||||||
tests = nullptr;
|
tests = nullptr;
|
||||||
|
|
||||||
#if GTEST_HAS_TYPED_TEST
|
#if GTEST_HAS_TYPED_TEST
|
||||||
test_case = UnitTestHelper::FindTestCase("TestCaseWithCommentTest/0");
|
test_suite = UnitTestHelper::FindTestSuite("TestSuiteWithCommentTest/0");
|
||||||
ASSERT_TRUE(test_case != nullptr);
|
ASSERT_TRUE(test_suite != nullptr);
|
||||||
|
|
||||||
EXPECT_STREQ("TestCaseWithCommentTest/0", test_case->name());
|
EXPECT_STREQ("TestSuiteWithCommentTest/0", test_suite->name());
|
||||||
EXPECT_STREQ(GetTypeName<int>().c_str(), test_case->type_param());
|
EXPECT_STREQ(GetTypeName<int>().c_str(), test_suite->type_param());
|
||||||
EXPECT_TRUE(test_case->should_run());
|
EXPECT_TRUE(test_suite->should_run());
|
||||||
EXPECT_EQ(0, test_case->disabled_test_count());
|
EXPECT_EQ(0, test_suite->disabled_test_count());
|
||||||
EXPECT_EQ(1, test_case->test_to_run_count());
|
EXPECT_EQ(1, test_suite->test_to_run_count());
|
||||||
ASSERT_EQ(1, test_case->total_test_count());
|
ASSERT_EQ(1, test_suite->total_test_count());
|
||||||
|
|
||||||
tests = UnitTestHelper::GetSortedTests(test_case);
|
tests = UnitTestHelper::GetSortedTests(test_suite);
|
||||||
|
|
||||||
EXPECT_STREQ("Dummy", tests[0]->name());
|
EXPECT_STREQ("Dummy", tests[0]->name());
|
||||||
EXPECT_STREQ("TestCaseWithCommentTest/0", tests[0]->test_case_name());
|
EXPECT_STREQ("TestSuiteWithCommentTest/0", tests[0]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[0]->value_param()));
|
EXPECT_TRUE(IsNull(tests[0]->value_param()));
|
||||||
EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());
|
EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());
|
||||||
EXPECT_TRUE(tests[0]->should_run());
|
EXPECT_TRUE(tests[0]->should_run());
|
||||||
@ -206,27 +206,27 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
|
|||||||
#endif // GTEST_HAS_TYPED_TEST
|
#endif // GTEST_HAS_TYPED_TEST
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ApiTest, TestCaseDisabledAccessorsWork) {
|
TEST(ApiTest, TestSuiteDisabledAccessorsWork) {
|
||||||
const TestCase* test_case = UnitTestHelper::FindTestCase("DISABLED_Test");
|
const TestSuite* test_suite = UnitTestHelper::FindTestSuite("DISABLED_Test");
|
||||||
ASSERT_TRUE(test_case != nullptr);
|
ASSERT_TRUE(test_suite != nullptr);
|
||||||
|
|
||||||
EXPECT_STREQ("DISABLED_Test", test_case->name());
|
EXPECT_STREQ("DISABLED_Test", test_suite->name());
|
||||||
EXPECT_TRUE(IsNull(test_case->type_param()));
|
EXPECT_TRUE(IsNull(test_suite->type_param()));
|
||||||
EXPECT_FALSE(test_case->should_run());
|
EXPECT_FALSE(test_suite->should_run());
|
||||||
EXPECT_EQ(1, test_case->disabled_test_count());
|
EXPECT_EQ(1, test_suite->disabled_test_count());
|
||||||
EXPECT_EQ(0, test_case->test_to_run_count());
|
EXPECT_EQ(0, test_suite->test_to_run_count());
|
||||||
ASSERT_EQ(1, test_case->total_test_count());
|
ASSERT_EQ(1, test_suite->total_test_count());
|
||||||
|
|
||||||
const TestInfo* const test_info = test_case->GetTestInfo(0);
|
const TestInfo* const test_info = test_suite->GetTestInfo(0);
|
||||||
EXPECT_STREQ("Dummy2", test_info->name());
|
EXPECT_STREQ("Dummy2", test_info->name());
|
||||||
EXPECT_STREQ("DISABLED_Test", test_info->test_case_name());
|
EXPECT_STREQ("DISABLED_Test", test_info->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(test_info->value_param()));
|
EXPECT_TRUE(IsNull(test_info->value_param()));
|
||||||
EXPECT_TRUE(IsNull(test_info->type_param()));
|
EXPECT_TRUE(IsNull(test_info->type_param()));
|
||||||
EXPECT_FALSE(test_info->should_run());
|
EXPECT_FALSE(test_info->should_run());
|
||||||
}
|
}
|
||||||
|
|
||||||
// These two tests are here to provide support for testing
|
// These two tests are here to provide support for testing
|
||||||
// test_case_to_run_count, disabled_test_count, and test_to_run_count.
|
// test_suite_to_run_count, disabled_test_count, and test_to_run_count.
|
||||||
TEST(ApiTest, DISABLED_Dummy1) {}
|
TEST(ApiTest, DISABLED_Dummy1) {}
|
||||||
TEST(DISABLED_Test, Dummy2) {}
|
TEST(DISABLED_Test, Dummy2) {}
|
||||||
|
|
||||||
@ -235,62 +235,62 @@ class FinalSuccessChecker : public Environment {
|
|||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
UnitTest* unit_test = UnitTest::GetInstance();
|
UnitTest* unit_test = UnitTest::GetInstance();
|
||||||
|
|
||||||
EXPECT_EQ(1 + kTypedTestCases, unit_test->successful_test_case_count());
|
EXPECT_EQ(1 + kTypedTestSuites, unit_test->successful_test_suite_count());
|
||||||
EXPECT_EQ(3 + kTypedTests, unit_test->successful_test_count());
|
EXPECT_EQ(3 + kTypedTests, unit_test->successful_test_count());
|
||||||
EXPECT_EQ(0, unit_test->failed_test_case_count());
|
EXPECT_EQ(0, unit_test->failed_test_suite_count());
|
||||||
EXPECT_EQ(0, unit_test->failed_test_count());
|
EXPECT_EQ(0, unit_test->failed_test_count());
|
||||||
EXPECT_TRUE(unit_test->Passed());
|
EXPECT_TRUE(unit_test->Passed());
|
||||||
EXPECT_FALSE(unit_test->Failed());
|
EXPECT_FALSE(unit_test->Failed());
|
||||||
ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());
|
ASSERT_EQ(2 + kTypedTestSuites, unit_test->total_test_suite_count());
|
||||||
|
|
||||||
const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();
|
const TestSuite** const test_suites = UnitTestHelper::GetSortedTestSuites();
|
||||||
|
|
||||||
EXPECT_STREQ("ApiTest", test_cases[0]->name());
|
EXPECT_STREQ("ApiTest", test_suites[0]->name());
|
||||||
EXPECT_TRUE(IsNull(test_cases[0]->type_param()));
|
EXPECT_TRUE(IsNull(test_suites[0]->type_param()));
|
||||||
EXPECT_TRUE(test_cases[0]->should_run());
|
EXPECT_TRUE(test_suites[0]->should_run());
|
||||||
EXPECT_EQ(1, test_cases[0]->disabled_test_count());
|
EXPECT_EQ(1, test_suites[0]->disabled_test_count());
|
||||||
ASSERT_EQ(4, test_cases[0]->total_test_count());
|
ASSERT_EQ(4, test_suites[0]->total_test_count());
|
||||||
EXPECT_EQ(3, test_cases[0]->successful_test_count());
|
EXPECT_EQ(3, test_suites[0]->successful_test_count());
|
||||||
EXPECT_EQ(0, test_cases[0]->failed_test_count());
|
EXPECT_EQ(0, test_suites[0]->failed_test_count());
|
||||||
EXPECT_TRUE(test_cases[0]->Passed());
|
EXPECT_TRUE(test_suites[0]->Passed());
|
||||||
EXPECT_FALSE(test_cases[0]->Failed());
|
EXPECT_FALSE(test_suites[0]->Failed());
|
||||||
|
|
||||||
EXPECT_STREQ("DISABLED_Test", test_cases[1]->name());
|
EXPECT_STREQ("DISABLED_Test", test_suites[1]->name());
|
||||||
EXPECT_TRUE(IsNull(test_cases[1]->type_param()));
|
EXPECT_TRUE(IsNull(test_suites[1]->type_param()));
|
||||||
EXPECT_FALSE(test_cases[1]->should_run());
|
EXPECT_FALSE(test_suites[1]->should_run());
|
||||||
EXPECT_EQ(1, test_cases[1]->disabled_test_count());
|
EXPECT_EQ(1, test_suites[1]->disabled_test_count());
|
||||||
ASSERT_EQ(1, test_cases[1]->total_test_count());
|
ASSERT_EQ(1, test_suites[1]->total_test_count());
|
||||||
EXPECT_EQ(0, test_cases[1]->successful_test_count());
|
EXPECT_EQ(0, test_suites[1]->successful_test_count());
|
||||||
EXPECT_EQ(0, test_cases[1]->failed_test_count());
|
EXPECT_EQ(0, test_suites[1]->failed_test_count());
|
||||||
|
|
||||||
#if GTEST_HAS_TYPED_TEST
|
#if GTEST_HAS_TYPED_TEST
|
||||||
EXPECT_STREQ("TestCaseWithCommentTest/0", test_cases[2]->name());
|
EXPECT_STREQ("TestSuiteWithCommentTest/0", test_suites[2]->name());
|
||||||
EXPECT_STREQ(GetTypeName<int>().c_str(), test_cases[2]->type_param());
|
EXPECT_STREQ(GetTypeName<int>().c_str(), test_suites[2]->type_param());
|
||||||
EXPECT_TRUE(test_cases[2]->should_run());
|
EXPECT_TRUE(test_suites[2]->should_run());
|
||||||
EXPECT_EQ(0, test_cases[2]->disabled_test_count());
|
EXPECT_EQ(0, test_suites[2]->disabled_test_count());
|
||||||
ASSERT_EQ(1, test_cases[2]->total_test_count());
|
ASSERT_EQ(1, test_suites[2]->total_test_count());
|
||||||
EXPECT_EQ(1, test_cases[2]->successful_test_count());
|
EXPECT_EQ(1, test_suites[2]->successful_test_count());
|
||||||
EXPECT_EQ(0, test_cases[2]->failed_test_count());
|
EXPECT_EQ(0, test_suites[2]->failed_test_count());
|
||||||
EXPECT_TRUE(test_cases[2]->Passed());
|
EXPECT_TRUE(test_suites[2]->Passed());
|
||||||
EXPECT_FALSE(test_cases[2]->Failed());
|
EXPECT_FALSE(test_suites[2]->Failed());
|
||||||
#endif // GTEST_HAS_TYPED_TEST
|
#endif // GTEST_HAS_TYPED_TEST
|
||||||
|
|
||||||
const TestCase* test_case = UnitTestHelper::FindTestCase("ApiTest");
|
const TestSuite* test_suite = UnitTestHelper::FindTestSuite("ApiTest");
|
||||||
const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);
|
const TestInfo** tests = UnitTestHelper::GetSortedTests(test_suite);
|
||||||
EXPECT_STREQ("DISABLED_Dummy1", tests[0]->name());
|
EXPECT_STREQ("DISABLED_Dummy1", tests[0]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[0]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[0]->test_suite_name());
|
||||||
EXPECT_FALSE(tests[0]->should_run());
|
EXPECT_FALSE(tests[0]->should_run());
|
||||||
|
|
||||||
EXPECT_STREQ("TestCaseDisabledAccessorsWork", tests[1]->name());
|
EXPECT_STREQ("TestSuiteDisabledAccessorsWork", tests[1]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[1]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[1]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[1]->value_param()));
|
EXPECT_TRUE(IsNull(tests[1]->value_param()));
|
||||||
EXPECT_TRUE(IsNull(tests[1]->type_param()));
|
EXPECT_TRUE(IsNull(tests[1]->type_param()));
|
||||||
EXPECT_TRUE(tests[1]->should_run());
|
EXPECT_TRUE(tests[1]->should_run());
|
||||||
EXPECT_TRUE(tests[1]->result()->Passed());
|
EXPECT_TRUE(tests[1]->result()->Passed());
|
||||||
EXPECT_EQ(0, tests[1]->result()->test_property_count());
|
EXPECT_EQ(0, tests[1]->result()->test_property_count());
|
||||||
|
|
||||||
EXPECT_STREQ("TestCaseImmutableAccessorsWork", tests[2]->name());
|
EXPECT_STREQ("TestSuiteImmutableAccessorsWork", tests[2]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[2]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[2]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[2]->value_param()));
|
EXPECT_TRUE(IsNull(tests[2]->value_param()));
|
||||||
EXPECT_TRUE(IsNull(tests[2]->type_param()));
|
EXPECT_TRUE(IsNull(tests[2]->type_param()));
|
||||||
EXPECT_TRUE(tests[2]->should_run());
|
EXPECT_TRUE(tests[2]->should_run());
|
||||||
@ -298,7 +298,7 @@ class FinalSuccessChecker : public Environment {
|
|||||||
EXPECT_EQ(0, tests[2]->result()->test_property_count());
|
EXPECT_EQ(0, tests[2]->result()->test_property_count());
|
||||||
|
|
||||||
EXPECT_STREQ("UnitTestImmutableAccessorsWork", tests[3]->name());
|
EXPECT_STREQ("UnitTestImmutableAccessorsWork", tests[3]->name());
|
||||||
EXPECT_STREQ("ApiTest", tests[3]->test_case_name());
|
EXPECT_STREQ("ApiTest", tests[3]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[3]->value_param()));
|
EXPECT_TRUE(IsNull(tests[3]->value_param()));
|
||||||
EXPECT_TRUE(IsNull(tests[3]->type_param()));
|
EXPECT_TRUE(IsNull(tests[3]->type_param()));
|
||||||
EXPECT_TRUE(tests[3]->should_run());
|
EXPECT_TRUE(tests[3]->should_run());
|
||||||
@ -311,11 +311,11 @@ class FinalSuccessChecker : public Environment {
|
|||||||
delete[] tests;
|
delete[] tests;
|
||||||
|
|
||||||
#if GTEST_HAS_TYPED_TEST
|
#if GTEST_HAS_TYPED_TEST
|
||||||
test_case = UnitTestHelper::FindTestCase("TestCaseWithCommentTest/0");
|
test_suite = UnitTestHelper::FindTestSuite("TestSuiteWithCommentTest/0");
|
||||||
tests = UnitTestHelper::GetSortedTests(test_case);
|
tests = UnitTestHelper::GetSortedTests(test_suite);
|
||||||
|
|
||||||
EXPECT_STREQ("Dummy", tests[0]->name());
|
EXPECT_STREQ("Dummy", tests[0]->name());
|
||||||
EXPECT_STREQ("TestCaseWithCommentTest/0", tests[0]->test_case_name());
|
EXPECT_STREQ("TestSuiteWithCommentTest/0", tests[0]->test_suite_name());
|
||||||
EXPECT_TRUE(IsNull(tests[0]->value_param()));
|
EXPECT_TRUE(IsNull(tests[0]->value_param()));
|
||||||
EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());
|
EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());
|
||||||
EXPECT_TRUE(tests[0]->should_run());
|
EXPECT_TRUE(tests[0]->should_run());
|
||||||
@ -324,7 +324,7 @@ class FinalSuccessChecker : public Environment {
|
|||||||
|
|
||||||
delete[] tests;
|
delete[] tests;
|
||||||
#endif // GTEST_HAS_TYPED_TEST
|
#endif // GTEST_HAS_TYPED_TEST
|
||||||
delete[] test_cases;
|
delete[] test_suites;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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 {
|
|||||||
// 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 {
|
|||||||
|
|
||||||
// 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) {
|
|||||||
// 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(
|
|||||||
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(
|
|||||||
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(
|
|||||||
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) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(UnitTestRecordPropertyTest,
|
TEST_F(UnitTestRecordPropertyTest,
|
||||||
AddFailureInsideTestsWhenUsingTestCaseReservedKeys) {
|
AddFailureInsideTestsWhenUsingTestSuiteReservedKeys) {
|
||||||
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
|
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
|
||||||
"name");
|
"name");
|
||||||
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
|
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
|
||||||
@ -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) {
|
|||||||
|
|
||||||
// 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 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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>
|
|||||||
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>
|
|||||||
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) {
|
|||||||
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 {
|
|||||||
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) {
|
|||||||
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>
|
|||||||
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_); }
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
|
|
||||||
// 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 {
|
|||||||
|
|
||||||
// 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) {
|
|||||||
// 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) {
|
|||||||
|
|
||||||
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(
|
|||||||
|
|
||||||
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>
|
|||||||
<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>
|
|||||||
<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"?>
|
|||||||
<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) {
|
|||||||
|
|
||||||
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) {
|
|||||||
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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user