Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
0599a7b8
Commit
0599a7b8
authored
Jan 11, 2019
by
misterg
Committed by
Gennadiy Civil
Jan 11, 2019
Browse files
Googletest export
Change tests to use new Test Suite API PiperOrigin-RevId: 228908894
parent
2edadced
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
394 additions
and
407 deletions
+394
-407
googletest/test/googletest-catch-exceptions-test.py
googletest/test/googletest-catch-exceptions-test.py
+12
-12
googletest/test/googletest-catch-exceptions-test_.cc
googletest/test/googletest-catch-exceptions-test_.cc
+31
-30
googletest/test/googletest-death-test-test.cc
googletest/test/googletest-death-test-test.cc
+2
-2
googletest/test/googletest-filter-unittest_.cc
googletest/test/googletest-filter-unittest_.cc
+2
-2
googletest/test/googletest-json-output-unittest.py
googletest/test/googletest-json-output-unittest.py
+6
-6
googletest/test/googletest-list-tests-unittest_.cc
googletest/test/googletest-list-tests-unittest_.cc
+5
-5
googletest/test/googletest-listener-test.cc
googletest/test/googletest-listener-test.cc
+9
-9
googletest/test/googletest-output-test-golden-lin.txt
googletest/test/googletest-output-test-golden-lin.txt
+28
-28
googletest/test/googletest-output-test_.cc
googletest/test/googletest-output-test_.cc
+32
-32
googletest/test/googletest-param-test-invalid-name1-test_.cc
googletest/test/googletest-param-test-invalid-name1-test_.cc
+4
-4
googletest/test/googletest-param-test-invalid-name2-test_.cc
googletest/test/googletest-param-test-invalid-name2-test_.cc
+4
-4
googletest/test/googletest-param-test-test.cc
googletest/test/googletest-param-test-test.cc
+65
-79
googletest/test/googletest-param-test-test.h
googletest/test/googletest-param-test-test.h
+1
-1
googletest/test/googletest-param-test2-test.cc
googletest/test/googletest-param-test2-test.cc
+7
-7
googletest/test/googletest-port-test.cc
googletest/test/googletest-port-test.cc
+1
-1
googletest/test/googletest-test2_test.cc
googletest/test/googletest-test2_test.cc
+7
-7
googletest/test/gtest-typed-test2_test.cc
googletest/test/gtest-typed-test2_test.cc
+2
-2
googletest/test/gtest-typed-test_test.cc
googletest/test/gtest-typed-test_test.cc
+57
-57
googletest/test/gtest-typed-test_test.h
googletest/test/gtest-typed-test_test.h
+3
-3
googletest/test/gtest-unittest-api_test.cc
googletest/test/gtest-unittest-api_test.cc
+116
-116
No files found.
googletest/test/googletest-catch-exceptions-test.py
View file @
0599a7b8
...
...
@@ -89,9 +89,9 @@ if SUPPORTS_SEH_EXCEPTIONS:
self
.
assert_
(
'SEH exception with code 0x2a thrown '
'in the test fixture
\'
s destructor'
in
test_output
)
self
.
assert_
(
'SEH exception with code 0x2a thrown in SetUpTest
Cas
e()'
self
.
assert_
(
'SEH exception with code 0x2a thrown in SetUpTest
Suit
e()'
in
test_output
)
self
.
assert_
(
'SEH exception with code 0x2a thrown in TearDownTest
Cas
e()'
self
.
assert_
(
'SEH exception with code 0x2a thrown in TearDownTest
Suit
e()'
in
test_output
)
self
.
assert_
(
'SEH exception with code 0x2a thrown in SetUp()'
in
test_output
)
...
...
@@ -134,29 +134,29 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
'"Standard C++ exception" thrown '
'in the test fixture
\'
s destructor'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInDestructorTest::TearDownTest
Cas
e() '
self
.
assert_
(
'CxxExceptionInDestructorTest::TearDownTest
Suit
e() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
def
testCatchesCxxExceptionsInSetUpTestCase
(
self
):
self
.
assert_
(
'C++ exception with description "Standard C++ exception"'
' thrown in SetUpTestSuite()'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInConstructorTest::TearDownTest
Cas
e() '
self
.
assert_
(
'CxxExceptionInConstructorTest::TearDownTest
Suit
e() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInSetUpTest
Cas
eTest constructor '
self
.
assert_
(
'CxxExceptionInSetUpTest
Suit
eTest constructor '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInSetUpTest
Cas
eTest destructor '
self
.
assert_
(
'CxxExceptionInSetUpTest
Suit
eTest destructor '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInSetUpTest
Cas
eTest::SetUp() '
self
.
assert_
(
'CxxExceptionInSetUpTest
Suit
eTest::SetUp() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInSetUpTest
Cas
eTest::TearDown() '
self
.
assert_
(
'CxxExceptionInSetUpTest
Suit
eTest::TearDown() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInSetUpTest
Cas
eTest test body '
self
.
assert_
(
'CxxExceptionInSetUpTest
Suit
eTest test body '
'called as expected.'
in
EX_BINARY_OUTPUT
)
...
...
@@ -168,7 +168,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
self
.
assert_
(
'C++ exception with description "Standard C++ exception"'
' thrown in SetUp()'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInSetUpTest::TearDownTest
Cas
e() '
self
.
assert_
(
'CxxExceptionInSetUpTest::TearDownTest
Suit
e() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInSetUpTest destructor '
...
...
@@ -186,7 +186,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
self
.
assert_
(
'C++ exception with description "Standard C++ exception"'
' thrown in TearDown()'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInTearDownTest::TearDownTest
Cas
e() '
self
.
assert_
(
'CxxExceptionInTearDownTest::TearDownTest
Suit
e() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInTearDownTest destructor '
...
...
@@ -197,7 +197,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
self
.
assert_
(
'C++ exception with description "Standard C++ exception"'
' thrown in the test body'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInTestBodyTest::TearDownTest
Cas
e() '
self
.
assert_
(
'CxxExceptionInTestBodyTest::TearDownTest
Suit
e() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInTestBodyTest destructor '
...
...
googletest/test/googletest-catch-exceptions-test_.cc
View file @
0599a7b8
...
...
@@ -64,19 +64,20 @@ class SehExceptionInDestructorTest : public Test {
TEST_F
(
SehExceptionInDestructorTest
,
ThrowsExceptionInDestructor
)
{}
class
SehExceptionInSetUpTest
Cas
eTest
:
public
Test
{
class
SehExceptionInSetUpTest
Suit
eTest
:
public
Test
{
public:
static
void
SetUpTest
Cas
e
()
{
RaiseException
(
42
,
0
,
0
,
NULL
);
}
static
void
SetUpTest
Suit
e
()
{
RaiseException
(
42
,
0
,
0
,
NULL
);
}
};
TEST_F
(
SehExceptionInSetUpTest
Cas
eTest
,
ThrowsExceptionInSetUpTest
Cas
e
)
{}
TEST_F
(
SehExceptionInSetUpTest
Suit
eTest
,
ThrowsExceptionInSetUpTest
Suit
e
)
{}
class
SehExceptionInTearDownTest
Cas
eTest
:
public
Test
{
class
SehExceptionInTearDownTest
Suit
eTest
:
public
Test
{
public:
static
void
TearDownTest
Cas
e
()
{
RaiseException
(
42
,
0
,
0
,
NULL
);
}
static
void
TearDownTest
Suit
e
()
{
RaiseException
(
42
,
0
,
0
,
NULL
);
}
};
TEST_F
(
SehExceptionInTearDownTestCaseTest
,
ThrowsExceptionInTearDownTestCase
)
{}
TEST_F
(
SehExceptionInTearDownTestSuiteTest
,
ThrowsExceptionInTearDownTestSuite
)
{}
class
SehExceptionInSetUpTest
:
public
Test
{
protected:
...
...
@@ -109,9 +110,9 @@ class CxxExceptionInConstructorTest : public Test {
throw
std
::
runtime_error
(
"Standard C++ exception"
));
}
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
printf
(
"%s"
,
"CxxExceptionInConstructorTest::TearDownTest
Cas
e() "
"CxxExceptionInConstructorTest::TearDownTest
Suit
e() "
"called as expected.
\n
"
);
}
...
...
@@ -137,65 +138,65 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
<<
"called unexpectedly."
;
}
class
CxxExceptionInSetUpTestCaseTest
:
public
Test
{
class
CxxExceptionInSetUpTestSuiteTest
:
public
Test
{
public:
CxxExceptionInSetUpTest
Cas
eTest
()
{
CxxExceptionInSetUpTest
Suit
eTest
()
{
printf
(
"%s"
,
"CxxExceptionInSetUpTest
Cas
eTest constructor "
"CxxExceptionInSetUpTest
Suit
eTest constructor "
"called as expected.
\n
"
);
}
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
throw
std
::
runtime_error
(
"Standard C++ exception"
);
}
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
printf
(
"%s"
,
"CxxExceptionInSetUpTest
Cas
eTest::TearDownTest
Cas
e() "
"CxxExceptionInSetUpTest
Suit
eTest::TearDownTest
Suit
e() "
"called as expected.
\n
"
);
}
protected:
~
CxxExceptionInSetUpTest
Cas
eTest
()
override
{
~
CxxExceptionInSetUpTest
Suit
eTest
()
override
{
printf
(
"%s"
,
"CxxExceptionInSetUpTest
Cas
eTest destructor "
"CxxExceptionInSetUpTest
Suit
eTest destructor "
"called as expected.
\n
"
);
}
void
SetUp
()
override
{
printf
(
"%s"
,
"CxxExceptionInSetUpTest
Cas
eTest::SetUp() "
"CxxExceptionInSetUpTest
Suit
eTest::SetUp() "
"called as expected.
\n
"
);
}
void
TearDown
()
override
{
printf
(
"%s"
,
"CxxExceptionInSetUpTest
Cas
eTest::TearDown() "
"CxxExceptionInSetUpTest
Suit
eTest::TearDown() "
"called as expected.
\n
"
);
}
};
TEST_F
(
CxxExceptionInSetUpTest
Cas
eTest
,
ThrowsExceptionInSetUpTest
Cas
e
)
{
TEST_F
(
CxxExceptionInSetUpTest
Suit
eTest
,
ThrowsExceptionInSetUpTest
Suit
e
)
{
printf
(
"%s"
,
"CxxExceptionInSetUpTest
Cas
eTest test body "
"CxxExceptionInSetUpTest
Suit
eTest test body "
"called as expected.
\n
"
);
}
class
CxxExceptionInTearDownTest
Cas
eTest
:
public
Test
{
class
CxxExceptionInTearDownTest
Suit
eTest
:
public
Test
{
public:
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
throw
std
::
runtime_error
(
"Standard C++ exception"
);
}
};
TEST_F
(
CxxExceptionInTearDownTestCaseTest
,
ThrowsExceptionInTearDownTestCase
)
{}
TEST_F
(
CxxExceptionInTearDownTestSuiteTest
,
ThrowsExceptionInTearDownTestSuite
)
{}
class
CxxExceptionInSetUpTest
:
public
Test
{
public:
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
printf
(
"%s"
,
"CxxExceptionInSetUpTest::TearDownTest
Cas
e() "
"CxxExceptionInSetUpTest::TearDownTest
Suit
e() "
"called as expected.
\n
"
);
}
...
...
@@ -222,9 +223,9 @@ TEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {
class
CxxExceptionInTearDownTest
:
public
Test
{
public:
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
printf
(
"%s"
,
"CxxExceptionInTearDownTest::TearDownTest
Cas
e() "
"CxxExceptionInTearDownTest::TearDownTest
Suit
e() "
"called as expected.
\n
"
);
}
...
...
@@ -244,9 +245,9 @@ TEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
class
CxxExceptionInTestBodyTest
:
public
Test
{
public:
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
printf
(
"%s"
,
"CxxExceptionInTestBodyTest::TearDownTest
Cas
e() "
"CxxExceptionInTestBodyTest::TearDownTest
Suit
e() "
"called as expected.
\n
"
);
}
...
...
googletest/test/googletest-death-test-test.cc
View file @
0599a7b8
...
...
@@ -1017,12 +1017,12 @@ class MacroLogicDeathTest : public testing::Test {
static
testing
::
internal
::
ReplaceDeathTestFactory
*
replacer_
;
static
MockDeathTestFactory
*
factory_
;
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
factory_
=
new
MockDeathTestFactory
;
replacer_
=
new
testing
::
internal
::
ReplaceDeathTestFactory
(
factory_
);
}
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
delete
replacer_
;
replacer_
=
nullptr
;
delete
factory_
;
...
...
googletest/test/googletest-filter-unittest_.cc
View file @
0599a7b8
...
...
@@ -125,8 +125,8 @@ TEST_P(ParamTest, TestX) {
TEST_P
(
ParamTest
,
TestY
)
{
}
INSTANTIATE_TEST_
CAS
E_P
(
SeqP
,
ParamTest
,
testing
::
Values
(
1
,
2
));
INSTANTIATE_TEST_
CAS
E_P
(
SeqQ
,
ParamTest
,
testing
::
Values
(
5
,
6
));
INSTANTIATE_TEST_
SUIT
E_P
(
SeqP
,
ParamTest
,
testing
::
Values
(
1
,
2
));
INSTANTIATE_TEST_
SUIT
E_P
(
SeqQ
,
ParamTest
,
testing
::
Values
(
5
,
6
));
}
// namespace
...
...
googletest/test/googletest-json-output-unittest.py
View file @
0599a7b8
...
...
@@ -241,8 +241,8 @@ EXPECTED_NON_EMPTY = {
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'SetUpTest
Cas
e'
:
u
'yes'
,
u
'TearDownTest
Cas
e'
:
u
'aye'
,
u
'SetUpTest
Suit
e'
:
u
'yes'
,
u
'TearDownTest
Suit
e'
:
u
'aye'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'OneProperty'
,
...
...
@@ -343,7 +343,7 @@ EXPECTED_NON_EMPTY = {
]
},
{
u
'name'
:
u
'Single/TypeParameterizedTest
Cas
e/0'
,
u
'name'
:
u
'Single/TypeParameterizedTest
Suit
e/0'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
...
...
@@ -355,12 +355,12 @@ EXPECTED_NON_EMPTY = {
u
'type_param'
:
u
'int'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/TypeParameterizedTest
Cas
e/0'
u
'classname'
:
u
'Single/TypeParameterizedTest
Suit
e/0'
}
]
},
{
u
'name'
:
u
'Single/TypeParameterizedTest
Cas
e/1'
,
u
'name'
:
u
'Single/TypeParameterizedTest
Suit
e/1'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
...
...
@@ -372,7 +372,7 @@ EXPECTED_NON_EMPTY = {
u
'type_param'
:
u
'long'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/TypeParameterizedTest
Cas
e/1'
u
'classname'
:
u
'Single/TypeParameterizedTest
Suit
e/1'
}
]
},
...
...
googletest/test/googletest-list-tests-unittest_.cc
View file @
0599a7b8
...
...
@@ -99,7 +99,7 @@ TEST_P(ValueParamTest, TestA) {
TEST_P
(
ValueParamTest
,
TestB
)
{
}
INSTANTIATE_TEST_
CAS
E_P
(
INSTANTIATE_TEST_
SUIT
E_P
(
MyInstantiation
,
ValueParamTest
,
testing
::
Values
(
MyType
(
"one line"
),
MyType
(
"two
\n
lines"
),
...
...
@@ -123,7 +123,7 @@ class MyArray {
typedef
testing
::
Types
<
VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName
,
// NOLINT
int
*
,
MyArray
<
bool
,
42
>
>
MyTypes
;
TYPED_TEST_
CAS
E
(
TypedTest
,
MyTypes
);
TYPED_TEST_
SUIT
E
(
TypedTest
,
MyTypes
);
TYPED_TEST
(
TypedTest
,
TestA
)
{
}
...
...
@@ -137,7 +137,7 @@ template <typename T>
class
TypeParamTest
:
public
testing
::
Test
{
};
TYPED_TEST_
CAS
E_P
(
TypeParamTest
);
TYPED_TEST_
SUIT
E_P
(
TypeParamTest
);
TYPED_TEST_P
(
TypeParamTest
,
TestA
)
{
}
...
...
@@ -145,9 +145,9 @@ TYPED_TEST_P(TypeParamTest, TestA) {
TYPED_TEST_P
(
TypeParamTest
,
TestB
)
{
}
REGISTER_TYPED_TEST_
CAS
E_P
(
TypeParamTest
,
TestA
,
TestB
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
TypeParamTest
,
TestA
,
TestB
);
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
TypeParamTest
,
MyTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
TypeParamTest
,
MyTypes
);
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
googletest/test/googletest-listener-test.cc
View file @
0599a7b8
...
...
@@ -40,7 +40,7 @@ using ::testing::AddGlobalTestEnvironment;
using
::
testing
::
Environment
;
using
::
testing
::
InitGoogleTest
;
using
::
testing
::
Test
;
using
::
testing
::
Test
Cas
e
;
using
::
testing
::
Test
Suit
e
;
using
::
testing
::
TestEventListener
;
using
::
testing
::
TestInfo
;
using
::
testing
::
TestPartResult
;
...
...
@@ -206,12 +206,12 @@ class EnvironmentInvocationCatcher : public Environment {
class
ListenerTest
:
public
Test
{
protected:
static
void
SetUpTest
Cas
e
()
{
g_events
->
push_back
(
"ListenerTest::SetUpTest
Cas
e"
);
static
void
SetUpTest
Suit
e
()
{
g_events
->
push_back
(
"ListenerTest::SetUpTest
Suit
e"
);
}
static
void
TearDownTest
Cas
e
()
{
g_events
->
push_back
(
"ListenerTest::TearDownTest
Cas
e"
);
static
void
TearDownTest
Suit
e
()
{
g_events
->
push_back
(
"ListenerTest::TearDownTest
Suit
e"
);
}
void
SetUp
()
override
{
g_events
->
push_back
(
"ListenerTest::SetUp"
);
}
...
...
@@ -299,7 +299,7 @@ int main(int argc, char **argv) {
"3rd.OnTestSuiteStart"
,
"1st.OnTestCaseStart"
,
"2nd.OnTestCaseStart"
,
"ListenerTest::SetUpTest
Cas
e"
,
"ListenerTest::SetUpTest
Suit
e"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
...
...
@@ -324,7 +324,7 @@ int main(int argc, char **argv) {
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTest
Cas
e"
,
"ListenerTest::TearDownTest
Suit
e"
,
"3rd.OnTestSuiteEnd"
,
"2nd.OnTestCaseEnd"
,
"1st.OnTestCaseEnd"
,
...
...
@@ -351,7 +351,7 @@ int main(int argc, char **argv) {
"3rd.OnTestSuiteStart"
,
"1st.OnTestCaseStart"
,
"2nd.OnTestCaseStart"
,
"ListenerTest::SetUpTest
Cas
e"
,
"ListenerTest::SetUpTest
Suit
e"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
...
...
@@ -376,7 +376,7 @@ int main(int argc, char **argv) {
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTest
Cas
e"
,
"ListenerTest::TearDownTest
Suit
e"
,
"3rd.OnTestSuiteEnd"
,
"2nd.OnTestCaseEnd"
,
"1st.OnTestCaseEnd"
,
...
...
googletest/test/googletest-output-test-golden-lin.txt
View file @
0599a7b8
...
...
@@ -384,16 +384,16 @@ Expected failure in foo.cc
Stack trace: (omitted)
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[0;32m[----------] [m4 tests from MixedUpTest
Cas
eTest
[0;32m[ RUN ] [mMixedUpTest
Cas
eTest.FirstTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTest
Cas
eTest.FirstTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTest
Cas
eTest.SecondTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTest
Cas
eTest.SecondTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTest
Cas
eTest.ThisShouldFail
[0;32m[----------] [m4 tests from MixedUpTest
Suit
eTest
[0;32m[ RUN ] [mMixedUpTest
Suit
eTest.FirstTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTest
Suit
eTest.FirstTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTest
Suit
eTest.SecondTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTest
Suit
eTest.SecondTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTest
Suit
eTest.ThisShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test suite must use the same test fixture
class. However, in test suite MixedUpTest
Cas
eTest,
class. However, in test suite MixedUpTest
Suit
eTest,
you defined test FirstTestFromNamespaceFoo and test ThisShouldFail
using two different test fixture classes. This can happen if
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.
Stack trace: (omitted)
[0;31m[ FAILED ] [mMixedUpTest
Cas
eTest.ThisShouldFail
[0;32m[ RUN ] [mMixedUpTest
Cas
eTest.ThisShouldFailToo
[0;31m[ FAILED ] [mMixedUpTest
Suit
eTest.ThisShouldFail
[0;32m[ RUN ] [mMixedUpTest
Suit
eTest.ThisShouldFailToo
gtest.cc:#: Failure
Failed
All tests in the same test suite must use the same test fixture
class. However, in test suite MixedUpTest
Cas
eTest,
class. However, in test suite MixedUpTest
Suit
eTest,
you defined test FirstTestFromNamespaceFoo and test ThisShouldFailToo
using two different test fixture classes. This can happen if
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.
Stack trace: (omitted)
[0;31m[ FAILED ] [mMixedUpTest
Cas
eTest.ThisShouldFailToo
[0;32m[----------] [m2 tests from MixedUpTest
Cas
eWithSameTestNameTest
[0;32m[ RUN ] [mMixedUpTest
Cas
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;32m[ OK ] [mMixedUpTest
Cas
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;32m[ RUN ] [mMixedUpTest
Cas
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;31m[ FAILED ] [mMixedUpTest
Suit
eTest.ThisShouldFailToo
[0;32m[----------] [m2 tests from MixedUpTest
Suit
eWithSameTestNameTest
[0;32m[ RUN ] [mMixedUpTest
Suit
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;32m[ OK ] [mMixedUpTest
Suit
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;32m[ RUN ] [mMixedUpTest
Suit
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test suite must use the same test fixture
class. However, in test suite MixedUpTest
Cas
eWithSameTestNameTest,
class. However, in test suite MixedUpTest
Suit
eWithSameTestNameTest,
you defined test TheSecondTestWithThisNameShouldFail and test TheSecondTestWithThisNameShouldFail
using two different test fixture classes. This can happen if
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.
Stack trace: (omitted)
[0;31m[ FAILED ] [mMixedUpTest
Cas
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;31m[ FAILED ] [mMixedUpTest
Suit
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[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[ OK ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F
...
...
@@ -871,7 +871,7 @@ Stack trace: (omitted)
[0;31m[ FAILED ] [mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[0;32m[----------] [m2 tests from DynamicFixture
DynamicFixture::SetUpTest
Cas
e
DynamicFixture::SetUpTest
Suit
e
[0;32m[ RUN ] [mDynamicFixture.DynamicTestPass
DynamicFixture()
DynamicFixture::SetUp
...
...
@@ -890,18 +890,18 @@ Stack trace: (omitted)
DynamicFixture::TearDown
~DynamicFixture()
[0;31m[ FAILED ] [mDynamicFixture.DynamicTestFail
DynamicFixture::TearDownTest
Cas
e
DynamicFixture::TearDownTest
Suit
e
[0;32m[----------] [m1 test from DynamicFixtureAnotherName
DynamicFixture::SetUpTest
Cas
e
DynamicFixture::SetUpTest
Suit
e
[0;32m[ RUN ] [mDynamicFixtureAnotherName.DynamicTestPass
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[0;32m[ OK ] [mDynamicFixtureAnotherName.DynamicTestPass
DynamicFixture::TearDownTest
Cas
e
DynamicFixture::TearDownTest
Suit
e
[0;32m[----------] [m2 tests from BadDynamicFixture1
DynamicFixture::SetUpTest
Cas
e
DynamicFixture::SetUpTest
Suit
e
[0;32m[ RUN ] [mBadDynamicFixture1.FixtureBase
DynamicFixture()
DynamicFixture::SetUp
...
...
@@ -923,9 +923,9 @@ Stack trace: (omitted)
~DynamicFixture()
[0;31m[ FAILED ] [mBadDynamicFixture1.TestBase
DynamicFixture::TearDownTest
Cas
e
DynamicFixture::TearDownTest
Suit
e
[0;32m[----------] [m2 tests from BadDynamicFixture2
DynamicFixture::SetUpTest
Cas
e
DynamicFixture::SetUpTest
Suit
e
[0;32m[ RUN ] [mBadDynamicFixture2.FixtureBase
DynamicFixture()
DynamicFixture::SetUp
...
...
@@ -947,7 +947,7 @@ Stack trace: (omitted)
~DynamicFixture()
[0;31m[ FAILED ] [mBadDynamicFixture2.Derived
DynamicFixture::TearDownTest
Cas
e
DynamicFixture::TearDownTest
Suit
e
[0;32m[----------] [m1 test from PrintingFailingParams/FailingParamTest
[0;32m[ RUN ] [mPrintingFailingParams/FailingParamTest.Fails/0
googletest-output-test_.cc:#: Failure
...
...
@@ -1006,9 +1006,9 @@ Stack trace: (omitted)
[0;31m[ FAILED ] [mNonFatalFailureInSetUpTest.FailureInSetUp
[0;31m[ FAILED ] [mFatalFailureInSetUpTest.FailureInSetUp
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[0;31m[ FAILED ] [mMixedUpTest
Cas
eTest.ThisShouldFail
[0;31m[ FAILED ] [mMixedUpTest
Cas
eTest.ThisShouldFailToo
[0;31m[ FAILED ] [mMixedUpTest
Cas
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;31m[ FAILED ] [mMixedUpTest
Suit
eTest.ThisShouldFail
[0;31m[ FAILED ] [mMixedUpTest
Suit
eTest.ThisShouldFailToo
[0;31m[ FAILED ] [mMixedUpTest
Suit
eWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[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 ] [mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure
...
...
googletest/test/googletest-output-test_.cc
View file @
0599a7b8
...
...
@@ -92,9 +92,9 @@ TEST_P(FailingParamTest, Fails) {
// This generates a test which will fail. Google Test is expected to print
// its parameter when it outputs the list of all failed tests.
INSTANTIATE_TEST_
CAS
E_P
(
PrintingFailingParams
,
FailingParamTest
,
testing
::
Values
(
2
));
INSTANTIATE_TEST_
SUIT
E_P
(
PrintingFailingParams
,
FailingParamTest
,
testing
::
Values
(
2
));
static
const
char
kGoldenString
[]
=
"
\"
Line
\0
1
\"\n
Line 2"
;
...
...
@@ -521,48 +521,48 @@ class DeathTestAndMultiThreadsTest : public testing::Test {
#endif // GTEST_IS_THREADSAFE
// The MixedUpTest
Cas
eTest test case verifies that Google Test will fail a
// The MixedUpTest
Suit
eTest test case verifies that Google Test will fail a
// test if it uses a different fixture class than what other tests in
// the same test case use. It deliberately contains two fixture
// classes with the same name but defined in different namespaces.
// The MixedUpTest
Cas
eWithSameTestNameTest test case verifies that
// The MixedUpTest
Suit
eWithSameTestNameTest test case verifies that
// when the user defines two tests with the same test case name AND
// same test name (but in different namespaces), the second test will
// fail.
namespace
foo
{
class
MixedUpTest
Cas
eTest
:
public
testing
::
Test
{
class
MixedUpTest
Suit
eTest
:
public
testing
::
Test
{
};
TEST_F
(
MixedUpTest
Cas
eTest
,
FirstTestFromNamespaceFoo
)
{}
TEST_F
(
MixedUpTest
Cas
eTest
,
SecondTestFromNamespaceFoo
)
{}
TEST_F
(
MixedUpTest
Suit
eTest
,
FirstTestFromNamespaceFoo
)
{}
TEST_F
(
MixedUpTest
Suit
eTest
,
SecondTestFromNamespaceFoo
)
{}
class
MixedUpTest
Cas
eWithSameTestNameTest
:
public
testing
::
Test
{
class
MixedUpTest
Suit
eWithSameTestNameTest
:
public
testing
::
Test
{
};
TEST_F
(
MixedUpTest
Cas
eWithSameTestNameTest
,
TEST_F
(
MixedUpTest
Suit
eWithSameTestNameTest
,
TheSecondTestWithThisNameShouldFail
)
{}
}
// namespace foo
namespace
bar
{
class
MixedUpTest
Cas
eTest
:
public
testing
::
Test
{
class
MixedUpTest
Suit
eTest
:
public
testing
::
Test
{
};
// The following two tests are expected to fail. We rely on the
// golden file to check that Google Test generates the right error message.
TEST_F
(
MixedUpTest
Cas
eTest
,
ThisShouldFail
)
{}
TEST_F
(
MixedUpTest
Cas
eTest
,
ThisShouldFailToo
)
{}
TEST_F
(
MixedUpTest
Suit
eTest
,
ThisShouldFail
)
{}
TEST_F
(
MixedUpTest
Suit
eTest
,
ThisShouldFailToo
)
{}
class
MixedUpTest
Cas
eWithSameTestNameTest
:
public
testing
::
Test
{
class
MixedUpTest
Suit
eWithSameTestNameTest
:
public
testing
::
Test
{
};
// Expected to fail. We rely on the golden file to check that Google Test
// generates the right error message.
TEST_F
(
MixedUpTest
Cas
eWithSameTestNameTest
,
TEST_F
(
MixedUpTest
Suit
eWithSameTestNameTest
,
TheSecondTestWithThisNameShouldFail
)
{}
}
// namespace bar
...
...
@@ -773,10 +773,10 @@ TEST_P(ParamTest, Failure) {
EXPECT_EQ
(
"b"
,
GetParam
())
<<
"Expected failure"
;
}
INSTANTIATE_TEST_
CAS
E_P
(
PrintingStrings
,
ParamTest
,
testing
::
Values
(
std
::
string
(
"a"
)),
ParamNameFunc
);
INSTANTIATE_TEST_
SUIT
E_P
(
PrintingStrings
,
ParamTest
,
testing
::
Values
(
std
::
string
(
"a"
)),
ParamNameFunc
);
// This #ifdef block tests the output of typed tests.
#if GTEST_HAS_TYPED_TEST
...
...
@@ -785,7 +785,7 @@ template <typename T>
class
TypedTest
:
public
testing
::
Test
{
};
TYPED_TEST_
CAS
E
(
TypedTest
,
testing
::
Types
<
int
>
);
TYPED_TEST_
SUIT
E
(
TypedTest
,
testing
::
Types
<
int
>
);
TYPED_TEST
(
TypedTest
,
Success
)
{
EXPECT_EQ
(
0
,
TypeParam
());
...
...
@@ -811,7 +811,7 @@ class TypedTestNames {
}
};
TYPED_TEST_
CAS
E
(
TypedTestWithNames
,
TypesForTestWithNames
,
TypedTestNames
);
TYPED_TEST_
SUIT
E
(
TypedTestWithNames
,
TypesForTestWithNames
,
TypedTestNames
);
TYPED_TEST
(
TypedTestWithNames
,
Success
)
{}
...
...
@@ -826,7 +826,7 @@ template <typename T>
class
TypedTestP
:
public
testing
::
Test
{
};
TYPED_TEST_
CAS
E_P
(
TypedTestP
);
TYPED_TEST_
SUIT
E_P
(
TypedTestP
);
TYPED_TEST_P
(
TypedTestP
,
Success
)
{
EXPECT_EQ
(
0U
,
TypeParam
());
...
...
@@ -836,10 +836,10 @@ TYPED_TEST_P(TypedTestP, Failure) {
EXPECT_EQ
(
1U
,
TypeParam
())
<<
"Expected failure"
;
}
REGISTER_TYPED_TEST_
CAS
E_P
(
TypedTestP
,
Success
,
Failure
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
TypedTestP
,
Success
,
Failure
);
typedef
testing
::
Types
<
unsigned
char
,
unsigned
int
>
UnsignedTypes
;
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
Unsigned
,
TypedTestP
,
UnsignedTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
Unsigned
,
TypedTestP
,
UnsignedTypes
);
class
TypedTestPNames
{
public:
...
...
@@ -854,7 +854,7 @@ class TypedTestPNames {
}
};
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
UnsignedCustomName
,
TypedTestP
,
UnsignedTypes
,
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
UnsignedCustomName
,
TypedTestP
,
UnsignedTypes
,
TypedTestPNames
);
#endif // GTEST_HAS_TYPED_TEST_P
...
...
@@ -877,7 +877,7 @@ class ATypedDeathTest : public testing::Test {
};
typedef
testing
::
Types
<
int
,
double
>
NumericTypes
;
TYPED_TEST_
CAS
E
(
ATypedDeathTest
,
NumericTypes
);
TYPED_TEST_
SUIT
E
(
ATypedDeathTest
,
NumericTypes
);
TYPED_TEST
(
ATypedDeathTest
,
ShouldRunFirst
)
{
}
...
...
@@ -894,14 +894,14 @@ template <typename T>
class
ATypeParamDeathTest
:
public
testing
::
Test
{
};
TYPED_TEST_
CAS
E_P
(
ATypeParamDeathTest
);
TYPED_TEST_
SUIT
E_P
(
ATypeParamDeathTest
);
TYPED_TEST_P
(
ATypeParamDeathTest
,
ShouldRunFirst
)
{
}
REGISTER_TYPED_TEST_
CAS
E_P
(
ATypeParamDeathTest
,
ShouldRunFirst
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
ATypeParamDeathTest
,
ShouldRunFirst
);
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
ATypeParamDeathTest
,
NumericTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
ATypeParamDeathTest
,
NumericTypes
);
# endif // GTEST_HAS_TYPED_TEST_P
...
...
@@ -1031,9 +1031,9 @@ class DynamicFixture : public testing::Test {
void
SetUp
()
override
{
printf
(
"DynamicFixture::SetUp
\n
"
);
}
void
TearDown
()
override
{
printf
(
"DynamicFixture::TearDown
\n
"
);
}
static
void
SetUpTest
Cas
e
()
{
printf
(
"DynamicFixture::SetUpTest
Cas
e
\n
"
);
}
static
void
TearDownTest
Cas
e
()
{
printf
(
"DynamicFixture::TearDownTest
Cas
e
\n
"
);
static
void
SetUpTest
Suit
e
()
{
printf
(
"DynamicFixture::SetUpTest
Suit
e
\n
"
);
}
static
void
TearDownTest
Suit
e
()
{
printf
(
"DynamicFixture::TearDownTest
Suit
e
\n
"
);
}
};
...
...
googletest/test/googletest-param-test-invalid-name1-test_.cc
View file @
0599a7b8
...
...
@@ -36,10 +36,10 @@ class DummyTest : public ::testing::TestWithParam<const char *> {};
TEST_P
(
DummyTest
,
Dummy
)
{
}
INSTANTIATE_TEST_
CAS
E_P
(
InvalidTestName
,
DummyTest
,
::
testing
::
Values
(
"InvalidWithQuotes"
),
::
testing
::
PrintToStringParamName
());
INSTANTIATE_TEST_
SUIT
E_P
(
InvalidTestName
,
DummyTest
,
::
testing
::
Values
(
"InvalidWithQuotes"
),
::
testing
::
PrintToStringParamName
());
}
// namespace
...
...
googletest/test/googletest-param-test-invalid-name2-test_.cc
View file @
0599a7b8
...
...
@@ -41,10 +41,10 @@ std::string StringParamTestSuffix(
TEST_P
(
DummyTest
,
Dummy
)
{
}
INSTANTIATE_TEST_
CAS
E_P
(
DuplicateTestNames
,
DummyTest
,
::
testing
::
Values
(
"a"
,
"b"
,
"a"
,
"c"
),
StringParamTestSuffix
);
INSTANTIATE_TEST_
SUIT
E_P
(
DuplicateTestNames
,
DummyTest
,
::
testing
::
Values
(
"a"
,
"b"
,
"a"
,
"c"
),
StringParamTestSuffix
);
}
// namespace
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
googletest/test/googletest-param-test-test.cc
View file @
0599a7b8
...
...
@@ -542,12 +542,12 @@ TEST(ParamGeneratorTest, AssignmentWorks) {
// This test verifies that the tests are expanded and run as specified:
// one test per element from the sequence produced by the generator
// specified in INSTANTIATE_TEST_
CAS
E_P. It also verifies that the test's
// specified in INSTANTIATE_TEST_
SUIT
E_P. It also verifies that the test's
// fixture constructor, SetUp(), and TearDown() have run and have been
// supplied with the correct parameters.
// The use of environment object allows detection of the case where no test
// case functionality is run at all. In this case Te
stCaseTearDown
will not
// case functionality is run at all. In this case Te
arDownTestSuite
will not
// be able to detect missing tests, naturally.
template
<
int
kExpectedCalls
>
class
TestGenerationEnvironment
:
public
::
testing
::
Environment
{
...
...
@@ -628,7 +628,7 @@ class TestGenerationTest : public TestWithParam<int> {
EXPECT_EQ
(
current_parameter_
,
GetParam
());
}
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
bool
all_tests_in_test_case_selected
=
true
;
for
(
int
i
=
0
;
i
<
PARAMETER_COUNT
;
++
i
)
{
...
...
@@ -649,7 +649,7 @@ class TestGenerationTest : public TestWithParam<int> {
collected_parameters_
.
clear
();
}
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
vector
<
int
>
expected_values
(
test_generation_params
,
test_generation_params
+
PARAMETER_COUNT
);
// Test execution order is not guaranteed by Google Test,
...
...
@@ -675,17 +675,17 @@ TEST_P(TestGenerationTest, TestsExpandedAndRun) {
EXPECT_EQ
(
current_parameter_
,
GetParam
());
collected_parameters_
.
push_back
(
GetParam
());
}
INSTANTIATE_TEST_
CAS
E_P
(
TestExpansionModule
,
TestGenerationTest
,
ValuesIn
(
test_generation_params
));
INSTANTIATE_TEST_
SUIT
E_P
(
TestExpansionModule
,
TestGenerationTest
,
ValuesIn
(
test_generation_params
));
// This test verifies that the element sequence (third parameter of
// INSTANTIATE_TEST_
CAS
E_P) is evaluated in InitGoogleTest() and neither at
// the call site of INSTANTIATE_TEST_
CAS
E_P nor in RUN_ALL_TESTS(). For
// INSTANTIATE_TEST_
SUIT
E_P) is evaluated in InitGoogleTest() and neither at
// the call site of INSTANTIATE_TEST_
SUIT
E_P nor in RUN_ALL_TESTS(). For
// that, we declare param_value_ to be a static member of
// GeneratorEvaluationTest and initialize it to 0. We set it to 1 in
// main(), just before invocation of InitGoogleTest(). After calling
// InitGoogleTest(), we set the value to 2. If the sequence is evaluated
// before or after InitGoogleTest, INSTANTIATE_TEST_
CAS
E_P will create a
// before or after InitGoogleTest, INSTANTIATE_TEST_
SUIT
E_P will create a
// test with parameter other than 1, and the test body will fail the
// assertion.
class
GeneratorEvaluationTest
:
public
TestWithParam
<
int
>
{
...
...
@@ -701,9 +701,8 @@ int GeneratorEvaluationTest::param_value_ = 0;
TEST_P
(
GeneratorEvaluationTest
,
GeneratorsEvaluatedInMain
)
{
EXPECT_EQ
(
1
,
GetParam
());
}
INSTANTIATE_TEST_CASE_P
(
GenEvalModule
,
GeneratorEvaluationTest
,
Values
(
GeneratorEvaluationTest
::
param_value
()));
INSTANTIATE_TEST_SUITE_P
(
GenEvalModule
,
GeneratorEvaluationTest
,
Values
(
GeneratorEvaluationTest
::
param_value
()));
// Tests that generators defined in a different translation unit are
// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.
...
...
@@ -714,9 +713,8 @@ TEST_P(ExternalGeneratorTest, ExternalGenerator) {
// which we verify here.
EXPECT_EQ
(
GetParam
(),
33
);
}
INSTANTIATE_TEST_CASE_P
(
ExternalGeneratorModule
,
ExternalGeneratorTest
,
extern_gen
);
INSTANTIATE_TEST_SUITE_P
(
ExternalGeneratorModule
,
ExternalGeneratorTest
,
extern_gen
);
// Tests that a parameterized test case can be defined in one translation
// unit and instantiated in another. This test will be instantiated in
...
...
@@ -731,20 +729,19 @@ TEST_P(ExternalInstantiationTest, IsMultipleOf33) {
class
MultipleInstantiationTest
:
public
TestWithParam
<
int
>
{};
TEST_P
(
MultipleInstantiationTest
,
AllowsMultipleInstances
)
{
}
INSTANTIATE_TEST_
CAS
E_P
(
Sequence1
,
MultipleInstantiationTest
,
Values
(
1
,
2
));
INSTANTIATE_TEST_
CAS
E_P
(
Sequence2
,
MultipleInstantiationTest
,
Range
(
3
,
5
));
INSTANTIATE_TEST_
SUIT
E_P
(
Sequence1
,
MultipleInstantiationTest
,
Values
(
1
,
2
));
INSTANTIATE_TEST_
SUIT
E_P
(
Sequence2
,
MultipleInstantiationTest
,
Range
(
3
,
5
));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. This test will be instantiated
// here and in gtest-param-test_test2.cc.
// InstantiationInMultipleTranslationUnitsTest fixture class
// is defined in gtest-param-test_test.h.
TEST_P
(
InstantiationInMultipleTranslaionUnitsTest
,
IsMultipleOf42
)
{
TEST_P
(
InstantiationInMultipleTransla
t
ionUnitsTest
,
IsMultipleOf42
)
{
EXPECT_EQ
(
0
,
GetParam
()
%
42
);
}
INSTANTIATE_TEST_CASE_P
(
Sequence1
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
,
42
*
2
));
INSTANTIATE_TEST_SUITE_P
(
Sequence1
,
InstantiationInMultipleTranslationUnitsTest
,
Values
(
42
,
42
*
2
));
// Tests that each iteration of parameterized test runs in a separate test
// object.
...
...
@@ -752,7 +749,7 @@ class SeparateInstanceTest : public TestWithParam<int> {
public:
SeparateInstanceTest
()
:
count_
(
0
)
{}
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
EXPECT_GE
(
global_count_
,
2
)
<<
"If some (but not all) SeparateInstanceTest tests have been "
<<
"filtered out this test will fail. Make sure that all "
...
...
@@ -770,20 +767,20 @@ TEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {
EXPECT_EQ
(
0
,
count_
++
);
global_count_
++
;
}
INSTANTIATE_TEST_
CAS
E_P
(
FourElemSequence
,
SeparateInstanceTest
,
Range
(
1
,
4
));
INSTANTIATE_TEST_
SUIT
E_P
(
FourElemSequence
,
SeparateInstanceTest
,
Range
(
1
,
4
));
// Tests that all instantiations of a test have named appropriately. Test
// defined with TEST_P(Test
Cas
eName, TestName) and instantiated with
// INSTANTIATE_TEST_
CAS
E_P(SequenceName, Test
Cas
eName, generator) must be
named
// SequenceName/Test
Cas
eName.TestName/i, where i is the 0-based index of
the
// sequence element used to instantiate the test.
// defined with TEST_P(Test
Suit
eName, TestName) and instantiated with
// INSTANTIATE_TEST_
SUIT
E_P(SequenceName, Test
Suit
eName, generator) must be
//
named
SequenceName/Test
Suit
eName.TestName/i, where i is the 0-based index of
//
the
sequence element used to instantiate the test.
class
NamingTest
:
public
TestWithParam
<
int
>
{};
TEST_P
(
NamingTest
,
TestsReportCorrectNamesAndParameters
)
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_STREQ
(
"ZeroToFiveSequence/NamingTest"
,
test_info
->
test_
cas
e_name
());
EXPECT_STREQ
(
"ZeroToFiveSequence/NamingTest"
,
test_info
->
test_
suit
e_name
());
Message
index_stream
;
index_stream
<<
"TestsReportCorrectNamesAndParameters/"
<<
GetParam
();
...
...
@@ -792,7 +789,7 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
EXPECT_EQ
(
::
testing
::
PrintToString
(
GetParam
()),
test_info
->
value_param
());
}
INSTANTIATE_TEST_
CAS
E_P
(
ZeroToFiveSequence
,
NamingTest
,
Range
(
0
,
5
));
INSTANTIATE_TEST_
SUIT
E_P
(
ZeroToFiveSequence
,
NamingTest
,
Range
(
0
,
5
));
// Tests that macros in test names are expanded correctly.
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
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_STREQ
(
"FortyTwo/MacroNamingTest"
,
test_info
->
test_
cas
e_name
());
EXPECT_STREQ
(
"FortyTwo/MacroNamingTest"
,
test_info
->
test_
suit
e_name
());
EXPECT_STREQ
(
"FooSomeTestName"
,
test_info
->
name
());
}
INSTANTIATE_TEST_
CAS
E_P
(
FortyTwo
,
MacroNamingTest
,
Values
(
42
));
INSTANTIATE_TEST_
SUIT
E_P
(
FortyTwo
,
MacroNamingTest
,
Values
(
42
));
// Tests the same thing for non-parametrized tests.
class
MacroNamingTestNonParametrized
:
public
::
testing
::
Test
{};
...
...
@@ -818,7 +815,7 @@ TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized),
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_STREQ
(
"MacroNamingTestNonParametrized"
,
test_info
->
test_
cas
e_name
());
EXPECT_STREQ
(
"MacroNamingTestNonParametrized"
,
test_info
->
test_
suit
e_name
());
EXPECT_STREQ
(
"FooSomeTestName"
,
test_info
->
name
());
}
...
...
@@ -835,17 +832,14 @@ struct CustomParamNameFunctor {
}
};
INSTANTIATE_TEST_CASE_P
(
CustomParamNameFunctor
,
CustomFunctorNamingTest
,
Values
(
std
::
string
(
"FunctorName"
)),
CustomParamNameFunctor
());
INSTANTIATE_TEST_SUITE_P
(
CustomParamNameFunctor
,
CustomFunctorNamingTest
,
Values
(
std
::
string
(
"FunctorName"
)),
CustomParamNameFunctor
());
INSTANTIATE_TEST_CASE_P
(
AllAllowedCharacters
,
CustomFunctorNamingTest
,
Values
(
"abcdefghijklmnopqrstuvwxyz"
,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
,
"01234567890_"
),
CustomParamNameFunctor
());
INSTANTIATE_TEST_SUITE_P
(
AllAllowedCharacters
,
CustomFunctorNamingTest
,
Values
(
"abcdefghijklmnopqrstuvwxyz"
,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
,
"01234567890_"
),
CustomParamNameFunctor
());
inline
std
::
string
CustomParamNameFunction
(
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
...
...
@@ -855,33 +849,30 @@ inline std::string CustomParamNameFunction(
class
CustomFunctionNamingTest
:
public
TestWithParam
<
std
::
string
>
{};
TEST_P
(
CustomFunctionNamingTest
,
CustomTestNames
)
{}
INSTANTIATE_TEST_CASE_P
(
CustomParamNameFunction
,
CustomFunctionNamingTest
,
Values
(
std
::
string
(
"FunctionName"
)),
CustomParamNameFunction
);
INSTANTIATE_TEST_SUITE_P
(
CustomParamNameFunction
,
CustomFunctionNamingTest
,
Values
(
std
::
string
(
"FunctionName"
)),
CustomParamNameFunction
);
// Test custom naming with a lambda
class
CustomLambdaNamingTest
:
public
TestWithParam
<
std
::
string
>
{};
TEST_P
(
CustomLambdaNamingTest
,
CustomTestNames
)
{}
INSTANTIATE_TEST_
CAS
E_P
(
CustomParamNameLambda
,
CustomLambdaNamingTest
,
Values
(
std
::
string
(
"LambdaName"
)),
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
});
INSTANTIATE_TEST_
SUIT
E_P
(
CustomParamNameLambda
,
CustomLambdaNamingTest
,
Values
(
std
::
string
(
"LambdaName"
)),
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
});
TEST
(
CustomNamingTest
,
CheckNameRegistry
)
{
::
testing
::
UnitTest
*
unit_test
=
::
testing
::
UnitTest
::
GetInstance
();
std
::
set
<
std
::
string
>
test_names
;
for
(
int
case_num
=
0
;
case_num
<
unit_test
->
total_test_case_count
();
++
case_num
)
{
const
::
testing
::
TestCase
*
test_case
=
unit_test
->
GetTestCase
(
case_num
);
for
(
int
test_num
=
0
;
test_num
<
test_case
->
total_test_count
();
for
(
int
suite_num
=
0
;
suite_num
<
unit_test
->
total_test_suite_count
();
++
suite_num
)
{
const
::
testing
::
TestSuite
*
test_suite
=
unit_test
->
GetTestSuite
(
suite_num
);
for
(
int
test_num
=
0
;
test_num
<
test_suite
->
total_test_count
();
++
test_num
)
{
const
::
testing
::
TestInfo
*
test_info
=
test_
cas
e
->
GetTestInfo
(
test_num
);
const
::
testing
::
TestInfo
*
test_info
=
test_
suit
e
->
GetTestInfo
(
test_num
);
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
());
}
INSTANTIATE_TEST_CASE_P
(
PrintToString
,
CustomIntegerNamingTest
,
Range
(
0
,
5
),
::
testing
::
PrintToStringParamName
());
INSTANTIATE_TEST_SUITE_P
(
PrintToString
,
CustomIntegerNamingTest
,
Range
(
0
,
5
),
::
testing
::
PrintToStringParamName
());
// 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
());
}
INSTANTIATE_TEST_CASE_P
(
PrintToString
,
CustomStructNamingTest
,
Values
(
CustomStruct
(
0
),
CustomStruct
(
1
)),
::
testing
::
PrintToStringParamName
());
INSTANTIATE_TEST_SUITE_P
(
PrintToString
,
CustomStructNamingTest
,
Values
(
CustomStruct
(
0
),
CustomStruct
(
1
)),
::
testing
::
PrintToStringParamName
());
// 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
());
}
INSTANTIATE_TEST_CASE_P
(
StatefulNamingFunctor
,
StatefulNamingTest
,
Range
(
0
,
5
),
StatefulNamingFunctor
());
INSTANTIATE_TEST_SUITE_P
(
StatefulNamingFunctor
,
StatefulNamingTest
,
Range
(
0
,
5
),
StatefulNamingFunctor
());
// 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
...
...
@@ -987,9 +973,8 @@ TEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {
EXPECT_EQ
(
::
testing
::
PrintToString
(
GetParam
()),
test_info
->
value_param
());
}
INSTANTIATE_TEST_CASE_P
(
InstantiationWithComments
,
CommentTest
,
Values
(
Unstreamable
(
1
)));
INSTANTIATE_TEST_SUITE_P
(
InstantiationWithComments
,
CommentTest
,
Values
(
Unstreamable
(
1
)));
// 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
...
...
@@ -1029,7 +1014,8 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
".* 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
enum
MyEnums
{
...
...
@@ -1041,19 +1027,19 @@ enum MyEnums {
class
MyEnumTest
:
public
testing
::
TestWithParam
<
MyEnums
>
{};
TEST_P
(
MyEnumTest
,
ChecksParamMoreThanZero
)
{
EXPECT_GE
(
10
,
GetParam
());
}
INSTANTIATE_TEST_
CAS
E_P
(
MyEnumTests
,
MyEnumTest
,
::
testing
::
Values
(
ENUM1
,
ENUM2
,
0
));
INSTANTIATE_TEST_
SUIT
E_P
(
MyEnumTests
,
MyEnumTest
,
::
testing
::
Values
(
ENUM1
,
ENUM2
,
0
));
int
main
(
int
argc
,
char
**
argv
)
{
// Used in TestGenerationTest test
cas
e.
// Used in TestGenerationTest test
suit
e.
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
// Used in GeneratorEvaluationTest test
cas
e. Tests that the updated value
// Used in GeneratorEvaluationTest test
suit
e. Tests that the updated value
// will be picked up for instantiating tests in GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
1
);
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
// Used in GeneratorEvaluationTest test
cas
e. Tests that value updated
// Used in GeneratorEvaluationTest test
suit
e. Tests that value updated
// here will NOT be used for instantiating tests in
// GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
2
);
...
...
googletest/test/googletest-param-test-test.h
View file @
0599a7b8
...
...
@@ -44,7 +44,7 @@ class ExternalInstantiationTest : public ::testing::TestWithParam<int> {
// Test fixture for testing instantiation of a test in multiple
// translation units.
class
InstantiationInMultipleTranslaionUnitsTest
class
InstantiationInMultipleTransla
t
ionUnitsTest
:
public
::
testing
::
TestWithParam
<
int
>
{
};
...
...
googletest/test/googletest-param-test2-test.cc
View file @
0599a7b8
...
...
@@ -46,16 +46,16 @@ ParamGenerator<int> extern_gen = Values(33);
// and instantiated in another. The test is defined in
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
// defined in gtest-param-test_test.h.
INSTANTIATE_TEST_
CAS
E_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
INSTANTIATE_TEST_
SUIT
E_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
// in googletest-param-test-test.cc and
// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
// InstantiationInMultipleTransla
t
ionUnitsTest fixture is defined in
// gtest-param-test_test.h
INSTANTIATE_TEST_
CAS
E_P
(
Sequence2
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
INSTANTIATE_TEST_
SUIT
E_P
(
Sequence2
,
InstantiationInMultipleTransla
t
ionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
googletest/test/googletest-port-test.cc
View file @
0599a7b8
...
...
@@ -393,7 +393,7 @@ typedef testing::Types<
# endif // GTEST_HAS_GLOBAL_STRING
const
char
*>
StringTypes
;
TYPED_TEST_
CAS
E
(
RETest
,
StringTypes
);
TYPED_TEST_
SUIT
E
(
RETest
,
StringTypes
);
// Tests RE's implicit constructors.
TYPED_TEST
(
RETest
,
ImplicitConstructorWorks
)
{
...
...
googletest/test/googletest-test2_test.cc
View file @
0599a7b8
...
...
@@ -46,16 +46,16 @@ ParamGenerator<int> extern_gen_2 = Values(33);
// and instantiated in another. The test is defined in
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
// defined in gtest-param-test_test.h.
INSTANTIATE_TEST_
CAS
E_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
INSTANTIATE_TEST_
SUIT
E_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
// in googletest-param-test-test.cc and
// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
// InstantiationInMultipleTransla
t
ionUnitsTest fixture is defined in
// gtest-param-test_test.h
INSTANTIATE_TEST_
CAS
E_P
(
Sequence2
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
INSTANTIATE_TEST_
SUIT
E_P
(
Sequence2
,
InstantiationInMultipleTransla
t
ionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
googletest/test/gtest-typed-test2_test.cc
View file @
0599a7b8
...
...
@@ -38,7 +38,7 @@
// Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together.
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
Vector
,
ContainerTest
,
testing
::
Types
<
std
::
vector
<
int
>
>
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
Vector
,
ContainerTest
,
testing
::
Types
<
std
::
vector
<
int
>
>
);
#endif // GTEST_HAS_TYPED_TEST_P
googletest/test/gtest-typed-test_test.cc
View file @
0599a7b8
...
...
@@ -41,19 +41,19 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127 /* conditional expression is constant */)
using
testing
::
Test
;
// Used for testing that SetUpTest
Cas
e()/TearDownTest
Cas
e(), fixture
// Used for testing that SetUpTest
Suit
e()/TearDownTest
Suit
e(), fixture
// ctor/dtor, and SetUp()/TearDown() work correctly in typed tests and
// type-parameterized test.
template
<
typename
T
>
class
CommonTest
:
public
Test
{
// For some technical reason, SetUpTest
Cas
e() and TearDownTest
Cas
e()
// For some technical reason, SetUpTest
Suit
e() and TearDownTest
Suit
e()
// must be public.
public:
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
shared_
=
new
T
(
5
);
}
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
delete
shared_
;
shared_
=
nullptr
;
}
...
...
@@ -92,11 +92,11 @@ T* CommonTest<T>::shared_ = nullptr;
using
testing
::
Types
;
// Tests that SetUpTest
Cas
e()/TearDownTest
Cas
e(), fixture ctor/dtor,
// Tests that SetUpTest
Suit
e()/TearDownTest
Suit
e(), fixture ctor/dtor,
// and SetUp()/TearDown() work correctly in typed tests
typedef
Types
<
char
,
int
>
TwoTypes
;
TYPED_TEST_
CAS
E
(
CommonTest
,
TwoTypes
);
TYPED_TEST_
SUIT
E
(
CommonTest
,
TwoTypes
);
TYPED_TEST
(
CommonTest
,
ValuesAreCorrect
)
{
// 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_
);
}
// Tests that multiple TYPED_TEST_
CAS
E's can be defined in the same
// Tests that multiple TYPED_TEST_
SUIT
E's can be defined in the same
// translation unit.
template
<
typename
T
>
class
TypedTest1
:
public
Test
{
};
// Verifies that the second argument of TYPED_TEST_
CAS
E can be a
// Verifies that the second argument of TYPED_TEST_
SUIT
E can be a
// single type.
TYPED_TEST_
CAS
E
(
TypedTest1
,
int
);
TYPED_TEST_
SUIT
E
(
TypedTest1
,
int
);
TYPED_TEST
(
TypedTest1
,
A
)
{}
template
<
typename
T
>
class
TypedTest2
:
public
Test
{
};
// Verifies that the second argument of TYPED_TEST_
CAS
E can be a
// Verifies that the second argument of TYPED_TEST_
SUIT
E can be a
// Types<...> type list.
TYPED_TEST_
CAS
E
(
TypedTest2
,
Types
<
int
>
);
TYPED_TEST_
SUIT
E
(
TypedTest2
,
Types
<
int
>
);
// This also verifies that tests from different typed test cases can
// share the same name.
...
...
@@ -161,7 +161,7 @@ class NumericTest : public Test {
};
typedef
Types
<
int
,
long
>
NumericTypes
;
TYPED_TEST_
CAS
E
(
NumericTest
,
NumericTypes
);
TYPED_TEST_
SUIT
E
(
NumericTest
,
NumericTypes
);
TYPED_TEST
(
NumericTest
,
DefaultIsZero
)
{
EXPECT_EQ
(
0
,
TypeParam
());
...
...
@@ -186,9 +186,9 @@ class TypedTestNames {
}
};
TYPED_TEST_
CAS
E
(
TypedTestWithNames
,
TwoTypes
,
TypedTestNames
);
TYPED_TEST_
SUIT
E
(
TypedTestWithNames
,
TwoTypes
,
TypedTestNames
);
TYPED_TEST
(
TypedTestWithNames
,
Test
Cas
eName
)
{
TYPED_TEST
(
TypedTestWithNames
,
Test
Suit
eName
)
{
if
(
testing
::
internal
::
IsSame
<
TypeParam
,
char
>::
value
)
{
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
...
...
@@ -209,11 +209,11 @@ TYPED_TEST(TypedTestWithNames, TestCaseName) {
#if GTEST_HAS_TYPED_TEST_P
using
testing
::
Types
;
using
testing
::
internal
::
TypedTest
Cas
ePState
;
using
testing
::
internal
::
TypedTest
Suit
ePState
;
// Tests TypedTest
Cas
ePState.
// Tests TypedTest
Suit
ePState.
class
TypedTest
Cas
ePStateTest
:
public
Test
{
class
TypedTest
Suit
ePStateTest
:
public
Test
{
protected:
void
SetUp
()
override
{
state_
.
AddTestName
(
"foo.cc"
,
0
,
"FooTest"
,
"A"
);
...
...
@@ -221,10 +221,10 @@ class TypedTestCasePStateTest : public Test {
state_
.
AddTestName
(
"foo.cc"
,
0
,
"FooTest"
,
"C"
);
}
TypedTest
Cas
ePState
state_
;
TypedTest
Suit
ePState
state_
;
};
TEST_F
(
TypedTest
Cas
ePStateTest
,
SucceedsForMatchingList
)
{
TEST_F
(
TypedTest
Suit
ePStateTest
,
SucceedsForMatchingList
)
{
const
char
*
tests
=
"A, B, C"
;
EXPECT_EQ
(
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
// don't matter.
TEST_F
(
TypedTest
Cas
ePStateTest
,
IgnoresOrderAndSpaces
)
{
TEST_F
(
TypedTest
Suit
ePStateTest
,
IgnoresOrderAndSpaces
)
{
const
char
*
tests
=
"A,C, B"
;
EXPECT_EQ
(
tests
,
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
tests
));
}
typedef
TypedTest
Cas
ePStateTest
TypedTest
Cas
ePState
Death
Test
;
using
TypedTest
Suit
ePState
Death
Test
=
TypedTest
Suit
ePStateTest
;
TEST_F
(
TypedTest
Cas
ePStateDeathTest
,
DetectsDuplicates
)
{
TEST_F
(
TypedTest
Suit
ePStateDeathTest
,
DetectsDuplicates
)
{
EXPECT_DEATH_IF_SUPPORTED
(
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, A, C"
),
"foo
\\
.cc.1.?: Test A is listed more than once
\\
."
);
}
TEST_F
(
TypedTest
Cas
ePStateDeathTest
,
DetectsExtraTest
)
{
TEST_F
(
TypedTest
Suit
ePStateDeathTest
,
DetectsExtraTest
)
{
EXPECT_DEATH_IF_SUPPORTED
(
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, C, D"
),
"foo
\\
.cc.1.?: No test named D can be found in this test suite
\\
."
);
}
TEST_F
(
TypedTest
Cas
ePStateDeathTest
,
DetectsMissedTest
)
{
TEST_F
(
TypedTest
Suit
ePStateDeathTest
,
DetectsMissedTest
)
{
EXPECT_DEATH_IF_SUPPORTED
(
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, C"
),
"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
// a run-time error if the test case has been registered.
TEST_F
(
TypedTest
Cas
ePStateDeathTest
,
DetectsTestAfterRegistration
)
{
TEST_F
(
TypedTest
Suit
ePStateDeathTest
,
DetectsTestAfterRegistration
)
{
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, C"
);
EXPECT_DEATH_IF_SUPPORTED
(
state_
.
AddTestName
(
"foo.cc"
,
2
,
"FooTest"
,
"D"
),
...
...
@@ -268,14 +268,14 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
"
\\
(FooTest,
\\
.
\\
.
\\
.
\\
)
\\
."
);
}
// Tests that SetUpTest
Cas
e()/TearDownTest
Cas
e(), fixture ctor/dtor,
// Tests that SetUpTest
Suit
e()/TearDownTest
Suit
e(), fixture ctor/dtor,
// and SetUp()/TearDown() work correctly in type-parameterized tests.
template
<
typename
T
>
class
DerivedTest
:
public
CommonTest
<
T
>
{
};
TYPED_TEST_
CAS
E_P
(
DerivedTest
);
TYPED_TEST_
SUIT
E_P
(
DerivedTest
);
TYPED_TEST_P
(
DerivedTest
,
ValuesAreCorrect
)
{
// 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_
);
}
REGISTER_TYPED_TEST_
CAS
E_P
(
DerivedTest
,
REGISTER_TYPED_TEST_
SUIT
E_P
(
DerivedTest
,
ValuesAreCorrect
,
ValuesAreStillCorrect
);
typedef
Types
<
short
,
long
>
MyTwoTypes
;
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
DerivedTest
,
MyTwoTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
DerivedTest
,
MyTwoTypes
);
// Tests that custom names work with type parametrized tests. We reuse the
// TwoTypes from above here.
template
<
typename
T
>
class
TypeParametrizedTestWithNames
:
public
Test
{};
TYPED_TEST_
CAS
E_P
(
TypeParametrizedTestWithNames
);
TYPED_TEST_
SUIT
E_P
(
TypeParametrizedTestWithNames
);
TYPED_TEST_P
(
TypeParametrizedTestWithNames
,
Test
Cas
eName
)
{
TYPED_TEST_P
(
TypeParametrizedTestWithNames
,
Test
Suit
eName
)
{
if
(
testing
::
internal
::
IsSame
<
TypeParam
,
char
>::
value
)
{
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
...
...
@@ -325,7 +325,7 @@ TYPED_TEST_P(TypeParametrizedTestWithNames, TestCaseName) {
}
}
REGISTER_TYPED_TEST_
CAS
E_P
(
TypeParametrizedTestWithNames
,
Test
Cas
eName
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
TypeParametrizedTestWithNames
,
Test
Suit
eName
);
class
TypeParametrizedTestNames
{
public:
...
...
@@ -340,62 +340,62 @@ class TypeParametrizedTestNames {
}
};
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
CustomName
,
TypeParametrizedTestWithNames
,
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
CustomName
,
TypeParametrizedTestWithNames
,
TwoTypes
,
TypeParametrizedTestNames
);
// Tests that multiple TYPED_TEST_
CAS
E_P's can be defined in the same
// Tests that multiple TYPED_TEST_
SUIT
E_P's can be defined in the same
// translation unit.
template
<
typename
T
>
class
TypedTestP1
:
public
Test
{
};
TYPED_TEST_
CAS
E_P
(
TypedTestP1
);
TYPED_TEST_
SUIT
E_P
(
TypedTestP1
);
// For testing that the code between TYPED_TEST_
CAS
E_P() and
// For testing that the code between TYPED_TEST_
SUIT
E_P() and
// TYPED_TEST_P() is not enclosed in a namespace.
typedef
in
t
IntAfterTypedTest
CaseP
;
us
in
g
IntAfterTypedTest
SuiteP
=
int
;
TYPED_TEST_P
(
TypedTestP1
,
A
)
{}
TYPED_TEST_P
(
TypedTestP1
,
B
)
{}
// For testing that the code between TYPED_TEST_P() and
// REGISTER_TYPED_TEST_
CAS
E_P() is not enclosed in a namespace.
typedef
in
t
IntBeforeRegisterTypedTest
CaseP
;
// REGISTER_TYPED_TEST_
SUIT
E_P() is not enclosed in a namespace.
us
in
g
IntBeforeRegisterTypedTest
SuiteP
=
int
;
REGISTER_TYPED_TEST_
CAS
E_P
(
TypedTestP1
,
A
,
B
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
TypedTestP1
,
A
,
B
);
template
<
typename
T
>
class
TypedTestP2
:
public
Test
{
};
TYPED_TEST_
CAS
E_P
(
TypedTestP2
);
TYPED_TEST_
SUIT
E_P
(
TypedTestP2
);
// This also verifies that tests from different type-parameterized
// test cases can share the same name.
TYPED_TEST_P
(
TypedTestP2
,
A
)
{}
REGISTER_TYPED_TEST_
CAS
E_P
(
TypedTestP2
,
A
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
TypedTestP2
,
A
);
// Verifies that the code between TYPED_TEST_
CAS
E_P() and
// REGISTER_TYPED_TEST_
CAS
E_P() is not enclosed in a namespace.
IntAfterTypedTest
Cas
eP
after
=
0
;
IntBeforeRegisterTypedTest
Cas
eP
before
=
0
;
// Verifies that the code between TYPED_TEST_
SUIT
E_P() and
// REGISTER_TYPED_TEST_
SUIT
E_P() is not enclosed in a namespace.
IntAfterTypedTest
Suit
eP
after
=
0
;
IntBeforeRegisterTypedTest
Suit
eP
before
=
0
;
// Verifies that the last argument of INSTANTIATE_TYPED_TEST_
CAS
E_P()
// Verifies that the last argument of INSTANTIATE_TYPED_TEST_
SUIT
E_P()
// can be either a single type or a Types<...> type list.
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
Int
,
TypedTestP1
,
int
);
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
Int
,
TypedTestP2
,
Types
<
int
>
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
Int
,
TypedTestP1
,
int
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
Int
,
TypedTestP2
,
Types
<
int
>
);
// Tests that the same type-parameterized test case can be
// instantiated more than once in the same translation unit.
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
Double
,
TypedTestP2
,
Types
<
double
>
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
Double
,
TypedTestP2
,
Types
<
double
>
);
// Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together.
// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
typedef
Types
<
std
::
vector
<
double
>
,
std
::
set
<
char
>
>
MyContainers
;
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
ContainerTest
,
MyContainers
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
ContainerTest
,
MyContainers
);
// Tests that a type-parameterized test case can be defined and
// instantiated in a namespace.
...
...
@@ -406,7 +406,7 @@ template <typename T>
class
NumericTest
:
public
Test
{
};
TYPED_TEST_
CAS
E_P
(
NumericTest
);
TYPED_TEST_
SUIT
E_P
(
NumericTest
);
TYPED_TEST_P
(
NumericTest
,
DefaultIsZero
)
{
EXPECT_EQ
(
0
,
TypeParam
());
...
...
@@ -416,29 +416,29 @@ TYPED_TEST_P(NumericTest, ZeroIsLessThanOne) {
EXPECT_LT
(
TypeParam
(
0
),
TypeParam
(
1
));
}
REGISTER_TYPED_TEST_
CAS
E_P
(
NumericTest
,
REGISTER_TYPED_TEST_
SUIT
E_P
(
NumericTest
,
DefaultIsZero
,
ZeroIsLessThanOne
);
typedef
Types
<
int
,
double
>
NumericTypes
;
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
NumericTest
,
NumericTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
NumericTest
,
NumericTypes
);
static
const
char
*
GetTestName
()
{
return
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
name
();
}
// Test the stripping of space from test names
template
<
typename
T
>
class
TrimmedTest
:
public
Test
{
};
TYPED_TEST_
CAS
E_P
(
TrimmedTest
);
TYPED_TEST_
SUIT
E_P
(
TrimmedTest
);
TYPED_TEST_P
(
TrimmedTest
,
Test1
)
{
EXPECT_STREQ
(
"Test1"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test2
)
{
EXPECT_STREQ
(
"Test2"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test3
)
{
EXPECT_STREQ
(
"Test3"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test4
)
{
EXPECT_STREQ
(
"Test4"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test5
)
{
EXPECT_STREQ
(
"Test5"
,
GetTestName
());
}
REGISTER_TYPED_TEST_
CAS
E_P
(
REGISTER_TYPED_TEST_
SUIT
E_P
(
TrimmedTest
,
Test1
,
Test2
,
Test3
,
Test4
,
Test5
);
// NOLINT
template
<
typename
T1
,
typename
T2
>
struct
MyPair
{};
// 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
;
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
TrimmedTest
,
TrimTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
TrimmedTest
,
TrimTypes
);
}
// namespace library2
...
...
googletest/test/gtest-typed-test_test.h
View file @
0599a7b8
...
...
@@ -46,7 +46,7 @@ template <typename T>
class
ContainerTest
:
public
Test
{
};
TYPED_TEST_
CAS
E_P
(
ContainerTest
);
TYPED_TEST_
SUIT
E_P
(
ContainerTest
);
TYPED_TEST_P
(
ContainerTest
,
CanBeDefaultConstructed
)
{
TypeParam
container
;
...
...
@@ -57,8 +57,8 @@ TYPED_TEST_P(ContainerTest, InitialSizeIsZero) {
EXPECT_EQ
(
0U
,
container
.
size
());
}
REGISTER_TYPED_TEST_
CAS
E_P
(
ContainerTest
,
CanBeDefaultConstructed
,
InitialSizeIsZero
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
ContainerTest
,
CanBeDefaultConstructed
,
InitialSizeIsZero
);
#endif // GTEST_HAS_TYPED_TEST_P
...
...
googletest/test/gtest-unittest-api_test.cc
View file @
0599a7b8
...
...
@@ -51,59 +51,59 @@ struct LessByName {
class
UnitTestHelper
{
public:
// Returns the array of pointers to all test
cas
es sorted by the test
cas
e
// Returns the array of pointers to all test
suit
es sorted by the test
suit
e
// name. The caller is responsible for deleting the array.
static
Test
Cas
e
const
**
GetSortedTest
Cas
es
()
{
static
Test
Suit
e
const
**
GetSortedTest
Suit
es
()
{
UnitTest
&
unit_test
=
*
UnitTest
::
GetInstance
();
TestCase
const
**
const
test_
cas
es
=
new
const
Test
Cas
e
*
[
unit_test
.
total_test_
cas
e_count
()];
auto
const
**
const
test_
suit
es
=
new
const
Test
Suit
e
*
[
unit_test
.
total_test_
suit
e_count
()];
for
(
int
i
=
0
;
i
<
unit_test
.
total_test_
cas
e_count
();
++
i
)
test_
cas
es
[
i
]
=
unit_test
.
GetTest
Cas
e
(
i
);
for
(
int
i
=
0
;
i
<
unit_test
.
total_test_
suit
e_count
();
++
i
)
test_
suit
es
[
i
]
=
unit_test
.
GetTest
Suit
e
(
i
);
std
::
sort
(
test_
cas
es
,
test_
cas
es
+
unit_test
.
total_test_
cas
e_count
(),
LessByName
<
Test
Cas
e
>
());
return
test_
cas
es
;
std
::
sort
(
test_
suit
es
,
test_
suit
es
+
unit_test
.
total_test_
suit
e_count
(),
LessByName
<
Test
Suit
e
>
());
return
test_
suit
es
;
}
// Returns the test
cas
e by its name. The caller doesn't own the returned
// Returns the test
suit
e by its name. The caller doesn't own the returned
// pointer.
static
const
Test
Cas
e
*
FindTest
Cas
e
(
const
char
*
name
)
{
static
const
Test
Suit
e
*
FindTest
Suit
e
(
const
char
*
name
)
{
UnitTest
&
unit_test
=
*
UnitTest
::
GetInstance
();
for
(
int
i
=
0
;
i
<
unit_test
.
total_test_
cas
e_count
();
++
i
)
{
const
Test
Cas
e
*
test_
cas
e
=
unit_test
.
GetTest
Cas
e
(
i
);
if
(
0
==
strcmp
(
test_
cas
e
->
name
(),
name
))
return
test_
cas
e
;
for
(
int
i
=
0
;
i
<
unit_test
.
total_test_
suit
e_count
();
++
i
)
{
const
Test
Suit
e
*
test_
suit
e
=
unit_test
.
GetTest
Suit
e
(
i
);
if
(
0
==
strcmp
(
test_
suit
e
->
name
(),
name
))
return
test_
suit
e
;
}
return
nullptr
;
}
// Returns the array of pointers to all tests in a particular test
cas
e
// Returns the array of pointers to all tests in a particular test
suit
e
// sorted by the test name. The caller is responsible for deleting the
// array.
static
TestInfo
const
**
GetSortedTests
(
const
Test
Cas
e
*
test_
cas
e
)
{
static
TestInfo
const
**
GetSortedTests
(
const
Test
Suit
e
*
test_
suit
e
)
{
TestInfo
const
**
const
tests
=
new
const
TestInfo
*
[
test_
cas
e
->
total_test_count
()];
new
const
TestInfo
*
[
test_
suit
e
->
total_test_count
()];
for
(
int
i
=
0
;
i
<
test_
cas
e
->
total_test_count
();
++
i
)
tests
[
i
]
=
test_
cas
e
->
GetTestInfo
(
i
);
for
(
int
i
=
0
;
i
<
test_
suit
e
->
total_test_count
();
++
i
)
tests
[
i
]
=
test_
suit
e
->
GetTestInfo
(
i
);
std
::
sort
(
tests
,
tests
+
test_
cas
e
->
total_test_count
(),
std
::
sort
(
tests
,
tests
+
test_
suit
e
->
total_test_count
(),
LessByName
<
TestInfo
>
());
return
tests
;
}
};
#if GTEST_HAS_TYPED_TEST
template
<
typename
T
>
class
Test
Cas
eWithCommentTest
:
public
Test
{};
TYPED_TEST_
CAS
E
(
Test
Cas
eWithCommentTest
,
Types
<
int
>
);
TYPED_TEST
(
Test
Cas
eWithCommentTest
,
Dummy
)
{}
template
<
typename
T
>
class
Test
Suit
eWithCommentTest
:
public
Test
{};
TYPED_TEST_
SUIT
E
(
Test
Suit
eWithCommentTest
,
Types
<
int
>
);
TYPED_TEST
(
Test
Suit
eWithCommentTest
,
Dummy
)
{}
const
int
kTypedTest
Cas
es
=
1
;
const
int
kTypedTest
Suit
es
=
1
;
const
int
kTypedTests
=
1
;
#else
const
int
kTypedTest
Cas
es
=
0
;
const
int
kTypedTest
Suit
es
=
0
;
const
int
kTypedTests
=
0
;
#endif // GTEST_HAS_TYPED_TEST
...
...
@@ -113,21 +113,21 @@ const int kTypedTests = 0;
TEST
(
ApiTest
,
UnitTestImmutableAccessorsWork
)
{
UnitTest
*
unit_test
=
UnitTest
::
GetInstance
();
ASSERT_EQ
(
2
+
kTypedTest
Cas
es
,
unit_test
->
total_test_
cas
e_count
());
EXPECT_EQ
(
1
+
kTypedTest
Cas
es
,
unit_test
->
test_
cas
e_to_run_count
());
ASSERT_EQ
(
2
+
kTypedTest
Suit
es
,
unit_test
->
total_test_
suit
e_count
());
EXPECT_EQ
(
1
+
kTypedTest
Suit
es
,
unit_test
->
test_
suit
e_to_run_count
());
EXPECT_EQ
(
2
,
unit_test
->
disabled_test_count
());
EXPECT_EQ
(
5
+
kTypedTests
,
unit_test
->
total_test_count
());
EXPECT_EQ
(
3
+
kTypedTests
,
unit_test
->
test_to_run_count
());
const
Test
Cas
e
**
const
test_
cas
es
=
UnitTestHelper
::
GetSortedTest
Cas
es
();
const
Test
Suit
e
**
const
test_
suit
es
=
UnitTestHelper
::
GetSortedTest
Suit
es
();
EXPECT_STREQ
(
"ApiTest"
,
test_
cas
es
[
0
]
->
name
());
EXPECT_STREQ
(
"DISABLED_Test"
,
test_
cas
es
[
1
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
test_
suit
es
[
0
]
->
name
());
EXPECT_STREQ
(
"DISABLED_Test"
,
test_
suit
es
[
1
]
->
name
());
#if GTEST_HAS_TYPED_TEST
EXPECT_STREQ
(
"Test
Cas
eWithCommentTest/0"
,
test_
cas
es
[
2
]
->
name
());
EXPECT_STREQ
(
"Test
Suit
eWithCommentTest/0"
,
test_
suit
es
[
2
]
->
name
());
#endif // GTEST_HAS_TYPED_TEST
delete
[]
test_
cas
es
;
delete
[]
test_
suit
es
;
// The following lines initiate actions to verify certain methods in
// FinalSuccessChecker::TearDown.
...
...
@@ -143,39 +143,39 @@ AssertionResult IsNull(const char* str) {
return
AssertionSuccess
();
}
TEST
(
ApiTest
,
Test
Cas
eImmutableAccessorsWork
)
{
const
Test
Cas
e
*
test_
cas
e
=
UnitTestHelper
::
FindTest
Cas
e
(
"ApiTest"
);
ASSERT_TRUE
(
test_
cas
e
!=
nullptr
);
TEST
(
ApiTest
,
Test
Suit
eImmutableAccessorsWork
)
{
const
Test
Suit
e
*
test_
suit
e
=
UnitTestHelper
::
FindTest
Suit
e
(
"ApiTest"
);
ASSERT_TRUE
(
test_
suit
e
!=
nullptr
);
EXPECT_STREQ
(
"ApiTest"
,
test_
cas
e
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
cas
e
->
type_param
()));
EXPECT_TRUE
(
test_
cas
e
->
should_run
());
EXPECT_EQ
(
1
,
test_
cas
e
->
disabled_test_count
());
EXPECT_EQ
(
3
,
test_
cas
e
->
test_to_run_count
());
ASSERT_EQ
(
4
,
test_
cas
e
->
total_test_count
());
EXPECT_STREQ
(
"ApiTest"
,
test_
suit
e
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
suit
e
->
type_param
()));
EXPECT_TRUE
(
test_
suit
e
->
should_run
());
EXPECT_EQ
(
1
,
test_
suit
e
->
disabled_test_count
());
EXPECT_EQ
(
3
,
test_
suit
e
->
test_to_run_count
());
ASSERT_EQ
(
4
,
test_
suit
e
->
total_test_count
());
const
TestInfo
**
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
cas
e
);
const
TestInfo
**
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
suit
e
);
EXPECT_STREQ
(
"DISABLED_Dummy1"
,
tests
[
0
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
0
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
0
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
0
]
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
tests
[
0
]
->
type_param
()));
EXPECT_FALSE
(
tests
[
0
]
->
should_run
());
EXPECT_STREQ
(
"Test
Cas
eDisabledAccessorsWork"
,
tests
[
1
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
1
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"Test
Suit
eDisabledAccessorsWork"
,
tests
[
1
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
1
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
1
]
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
tests
[
1
]
->
type_param
()));
EXPECT_TRUE
(
tests
[
1
]
->
should_run
());
EXPECT_STREQ
(
"Test
Cas
eImmutableAccessorsWork"
,
tests
[
2
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
2
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"Test
Suit
eImmutableAccessorsWork"
,
tests
[
2
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
2
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
2
]
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
tests
[
2
]
->
type_param
()));
EXPECT_TRUE
(
tests
[
2
]
->
should_run
());
EXPECT_STREQ
(
"UnitTestImmutableAccessorsWork"
,
tests
[
3
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
3
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
3
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
3
]
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
tests
[
3
]
->
type_param
()));
EXPECT_TRUE
(
tests
[
3
]
->
should_run
());
...
...
@@ -184,20 +184,20 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
tests
=
nullptr
;
#if GTEST_HAS_TYPED_TEST
test_
cas
e
=
UnitTestHelper
::
FindTest
Cas
e
(
"Test
Cas
eWithCommentTest/0"
);
ASSERT_TRUE
(
test_
cas
e
!=
nullptr
);
test_
suit
e
=
UnitTestHelper
::
FindTest
Suit
e
(
"Test
Suit
eWithCommentTest/0"
);
ASSERT_TRUE
(
test_
suit
e
!=
nullptr
);
EXPECT_STREQ
(
"Test
Cas
eWithCommentTest/0"
,
test_
cas
e
->
name
());
EXPECT_STREQ
(
GetTypeName
<
int
>
().
c_str
(),
test_
cas
e
->
type_param
());
EXPECT_TRUE
(
test_
cas
e
->
should_run
());
EXPECT_EQ
(
0
,
test_
cas
e
->
disabled_test_count
());
EXPECT_EQ
(
1
,
test_
cas
e
->
test_to_run_count
());
ASSERT_EQ
(
1
,
test_
cas
e
->
total_test_count
());
EXPECT_STREQ
(
"Test
Suit
eWithCommentTest/0"
,
test_
suit
e
->
name
());
EXPECT_STREQ
(
GetTypeName
<
int
>
().
c_str
(),
test_
suit
e
->
type_param
());
EXPECT_TRUE
(
test_
suit
e
->
should_run
());
EXPECT_EQ
(
0
,
test_
suit
e
->
disabled_test_count
());
EXPECT_EQ
(
1
,
test_
suit
e
->
test_to_run_count
());
ASSERT_EQ
(
1
,
test_
suit
e
->
total_test_count
());
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
cas
e
);
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
suit
e
);
EXPECT_STREQ
(
"Dummy"
,
tests
[
0
]
->
name
());
EXPECT_STREQ
(
"Test
Cas
eWithCommentTest/0"
,
tests
[
0
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"Test
Suit
eWithCommentTest/0"
,
tests
[
0
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
0
]
->
value_param
()));
EXPECT_STREQ
(
GetTypeName
<
int
>
().
c_str
(),
tests
[
0
]
->
type_param
());
EXPECT_TRUE
(
tests
[
0
]
->
should_run
());
...
...
@@ -206,27 +206,27 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
#endif // GTEST_HAS_TYPED_TEST
}
TEST
(
ApiTest
,
Test
Cas
eDisabledAccessorsWork
)
{
const
Test
Cas
e
*
test_
cas
e
=
UnitTestHelper
::
FindTest
Cas
e
(
"DISABLED_Test"
);
ASSERT_TRUE
(
test_
cas
e
!=
nullptr
);
TEST
(
ApiTest
,
Test
Suit
eDisabledAccessorsWork
)
{
const
Test
Suit
e
*
test_
suit
e
=
UnitTestHelper
::
FindTest
Suit
e
(
"DISABLED_Test"
);
ASSERT_TRUE
(
test_
suit
e
!=
nullptr
);
EXPECT_STREQ
(
"DISABLED_Test"
,
test_
cas
e
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
cas
e
->
type_param
()));
EXPECT_FALSE
(
test_
cas
e
->
should_run
());
EXPECT_EQ
(
1
,
test_
cas
e
->
disabled_test_count
());
EXPECT_EQ
(
0
,
test_
cas
e
->
test_to_run_count
());
ASSERT_EQ
(
1
,
test_
cas
e
->
total_test_count
());
EXPECT_STREQ
(
"DISABLED_Test"
,
test_
suit
e
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
suit
e
->
type_param
()));
EXPECT_FALSE
(
test_
suit
e
->
should_run
());
EXPECT_EQ
(
1
,
test_
suit
e
->
disabled_test_count
());
EXPECT_EQ
(
0
,
test_
suit
e
->
test_to_run_count
());
ASSERT_EQ
(
1
,
test_
suit
e
->
total_test_count
());
const
TestInfo
*
const
test_info
=
test_
cas
e
->
GetTestInfo
(
0
);
const
TestInfo
*
const
test_info
=
test_
suit
e
->
GetTestInfo
(
0
);
EXPECT_STREQ
(
"Dummy2"
,
test_info
->
name
());
EXPECT_STREQ
(
"DISABLED_Test"
,
test_info
->
test_
cas
e_name
());
EXPECT_STREQ
(
"DISABLED_Test"
,
test_info
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
test_info
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
test_info
->
type_param
()));
EXPECT_FALSE
(
test_info
->
should_run
());
}
// These two tests are here to provide support for testing
// test_
cas
e_to_run_count, disabled_test_count, and test_to_run_count.
// test_
suit
e_to_run_count, disabled_test_count, and test_to_run_count.
TEST
(
ApiTest
,
DISABLED_Dummy1
)
{}
TEST
(
DISABLED_Test
,
Dummy2
)
{}
...
...
@@ -235,62 +235,62 @@ class FinalSuccessChecker : public Environment {
void
TearDown
()
override
{
UnitTest
*
unit_test
=
UnitTest
::
GetInstance
();
EXPECT_EQ
(
1
+
kTypedTest
Cas
es
,
unit_test
->
successful_test_
cas
e_count
());
EXPECT_EQ
(
1
+
kTypedTest
Suit
es
,
unit_test
->
successful_test_
suit
e_count
());
EXPECT_EQ
(
3
+
kTypedTests
,
unit_test
->
successful_test_count
());
EXPECT_EQ
(
0
,
unit_test
->
failed_test_
cas
e_count
());
EXPECT_EQ
(
0
,
unit_test
->
failed_test_
suit
e_count
());
EXPECT_EQ
(
0
,
unit_test
->
failed_test_count
());
EXPECT_TRUE
(
unit_test
->
Passed
());
EXPECT_FALSE
(
unit_test
->
Failed
());
ASSERT_EQ
(
2
+
kTypedTest
Cas
es
,
unit_test
->
total_test_
cas
e_count
());
const
Test
Cas
e
**
const
test_
cas
es
=
UnitTestHelper
::
GetSortedTest
Cas
es
();
EXPECT_STREQ
(
"ApiTest"
,
test_
cas
es
[
0
]
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
cas
es
[
0
]
->
type_param
()));
EXPECT_TRUE
(
test_
cas
es
[
0
]
->
should_run
());
EXPECT_EQ
(
1
,
test_
cas
es
[
0
]
->
disabled_test_count
());
ASSERT_EQ
(
4
,
test_
cas
es
[
0
]
->
total_test_count
());
EXPECT_EQ
(
3
,
test_
cas
es
[
0
]
->
successful_test_count
());
EXPECT_EQ
(
0
,
test_
cas
es
[
0
]
->
failed_test_count
());
EXPECT_TRUE
(
test_
cas
es
[
0
]
->
Passed
());
EXPECT_FALSE
(
test_
cas
es
[
0
]
->
Failed
());
EXPECT_STREQ
(
"DISABLED_Test"
,
test_
cas
es
[
1
]
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
cas
es
[
1
]
->
type_param
()));
EXPECT_FALSE
(
test_
cas
es
[
1
]
->
should_run
());
EXPECT_EQ
(
1
,
test_
cas
es
[
1
]
->
disabled_test_count
());
ASSERT_EQ
(
1
,
test_
cas
es
[
1
]
->
total_test_count
());
EXPECT_EQ
(
0
,
test_
cas
es
[
1
]
->
successful_test_count
());
EXPECT_EQ
(
0
,
test_
cas
es
[
1
]
->
failed_test_count
());
ASSERT_EQ
(
2
+
kTypedTest
Suit
es
,
unit_test
->
total_test_
suit
e_count
());
const
Test
Suit
e
**
const
test_
suit
es
=
UnitTestHelper
::
GetSortedTest
Suit
es
();
EXPECT_STREQ
(
"ApiTest"
,
test_
suit
es
[
0
]
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
suit
es
[
0
]
->
type_param
()));
EXPECT_TRUE
(
test_
suit
es
[
0
]
->
should_run
());
EXPECT_EQ
(
1
,
test_
suit
es
[
0
]
->
disabled_test_count
());
ASSERT_EQ
(
4
,
test_
suit
es
[
0
]
->
total_test_count
());
EXPECT_EQ
(
3
,
test_
suit
es
[
0
]
->
successful_test_count
());
EXPECT_EQ
(
0
,
test_
suit
es
[
0
]
->
failed_test_count
());
EXPECT_TRUE
(
test_
suit
es
[
0
]
->
Passed
());
EXPECT_FALSE
(
test_
suit
es
[
0
]
->
Failed
());
EXPECT_STREQ
(
"DISABLED_Test"
,
test_
suit
es
[
1
]
->
name
());
EXPECT_TRUE
(
IsNull
(
test_
suit
es
[
1
]
->
type_param
()));
EXPECT_FALSE
(
test_
suit
es
[
1
]
->
should_run
());
EXPECT_EQ
(
1
,
test_
suit
es
[
1
]
->
disabled_test_count
());
ASSERT_EQ
(
1
,
test_
suit
es
[
1
]
->
total_test_count
());
EXPECT_EQ
(
0
,
test_
suit
es
[
1
]
->
successful_test_count
());
EXPECT_EQ
(
0
,
test_
suit
es
[
1
]
->
failed_test_count
());
#if GTEST_HAS_TYPED_TEST
EXPECT_STREQ
(
"Test
Cas
eWithCommentTest/0"
,
test_
cas
es
[
2
]
->
name
());
EXPECT_STREQ
(
GetTypeName
<
int
>
().
c_str
(),
test_
cas
es
[
2
]
->
type_param
());
EXPECT_TRUE
(
test_
cas
es
[
2
]
->
should_run
());
EXPECT_EQ
(
0
,
test_
cas
es
[
2
]
->
disabled_test_count
());
ASSERT_EQ
(
1
,
test_
cas
es
[
2
]
->
total_test_count
());
EXPECT_EQ
(
1
,
test_
cas
es
[
2
]
->
successful_test_count
());
EXPECT_EQ
(
0
,
test_
cas
es
[
2
]
->
failed_test_count
());
EXPECT_TRUE
(
test_
cas
es
[
2
]
->
Passed
());
EXPECT_FALSE
(
test_
cas
es
[
2
]
->
Failed
());
EXPECT_STREQ
(
"Test
Suit
eWithCommentTest/0"
,
test_
suit
es
[
2
]
->
name
());
EXPECT_STREQ
(
GetTypeName
<
int
>
().
c_str
(),
test_
suit
es
[
2
]
->
type_param
());
EXPECT_TRUE
(
test_
suit
es
[
2
]
->
should_run
());
EXPECT_EQ
(
0
,
test_
suit
es
[
2
]
->
disabled_test_count
());
ASSERT_EQ
(
1
,
test_
suit
es
[
2
]
->
total_test_count
());
EXPECT_EQ
(
1
,
test_
suit
es
[
2
]
->
successful_test_count
());
EXPECT_EQ
(
0
,
test_
suit
es
[
2
]
->
failed_test_count
());
EXPECT_TRUE
(
test_
suit
es
[
2
]
->
Passed
());
EXPECT_FALSE
(
test_
suit
es
[
2
]
->
Failed
());
#endif // GTEST_HAS_TYPED_TEST
const
Test
Cas
e
*
test_
cas
e
=
UnitTestHelper
::
FindTest
Cas
e
(
"ApiTest"
);
const
TestInfo
**
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
cas
e
);
const
Test
Suit
e
*
test_
suit
e
=
UnitTestHelper
::
FindTest
Suit
e
(
"ApiTest"
);
const
TestInfo
**
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
suit
e
);
EXPECT_STREQ
(
"DISABLED_Dummy1"
,
tests
[
0
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
0
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
0
]
->
test_
suit
e_name
());
EXPECT_FALSE
(
tests
[
0
]
->
should_run
());
EXPECT_STREQ
(
"Test
Cas
eDisabledAccessorsWork"
,
tests
[
1
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
1
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"Test
Suit
eDisabledAccessorsWork"
,
tests
[
1
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
1
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
1
]
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
tests
[
1
]
->
type_param
()));
EXPECT_TRUE
(
tests
[
1
]
->
should_run
());
EXPECT_TRUE
(
tests
[
1
]
->
result
()
->
Passed
());
EXPECT_EQ
(
0
,
tests
[
1
]
->
result
()
->
test_property_count
());
EXPECT_STREQ
(
"Test
Cas
eImmutableAccessorsWork"
,
tests
[
2
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
2
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"Test
Suit
eImmutableAccessorsWork"
,
tests
[
2
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
2
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
2
]
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
tests
[
2
]
->
type_param
()));
EXPECT_TRUE
(
tests
[
2
]
->
should_run
());
...
...
@@ -298,7 +298,7 @@ class FinalSuccessChecker : public Environment {
EXPECT_EQ
(
0
,
tests
[
2
]
->
result
()
->
test_property_count
());
EXPECT_STREQ
(
"UnitTestImmutableAccessorsWork"
,
tests
[
3
]
->
name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
3
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"ApiTest"
,
tests
[
3
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
3
]
->
value_param
()));
EXPECT_TRUE
(
IsNull
(
tests
[
3
]
->
type_param
()));
EXPECT_TRUE
(
tests
[
3
]
->
should_run
());
...
...
@@ -311,11 +311,11 @@ class FinalSuccessChecker : public Environment {
delete
[]
tests
;
#if GTEST_HAS_TYPED_TEST
test_
cas
e
=
UnitTestHelper
::
FindTest
Cas
e
(
"Test
Cas
eWithCommentTest/0"
);
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
cas
e
);
test_
suit
e
=
UnitTestHelper
::
FindTest
Suit
e
(
"Test
Suit
eWithCommentTest/0"
);
tests
=
UnitTestHelper
::
GetSortedTests
(
test_
suit
e
);
EXPECT_STREQ
(
"Dummy"
,
tests
[
0
]
->
name
());
EXPECT_STREQ
(
"Test
Cas
eWithCommentTest/0"
,
tests
[
0
]
->
test_
cas
e_name
());
EXPECT_STREQ
(
"Test
Suit
eWithCommentTest/0"
,
tests
[
0
]
->
test_
suit
e_name
());
EXPECT_TRUE
(
IsNull
(
tests
[
0
]
->
value_param
()));
EXPECT_STREQ
(
GetTypeName
<
int
>
().
c_str
(),
tests
[
0
]
->
type_param
());
EXPECT_TRUE
(
tests
[
0
]
->
should_run
());
...
...
@@ -324,7 +324,7 @@ class FinalSuccessChecker : public Environment {
delete
[]
tests
;
#endif // GTEST_HAS_TYPED_TEST
delete
[]
test_
cas
es
;
delete
[]
test_
suit
es
;
}
};
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment