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
85f059f0
Unverified
Commit
85f059f0
authored
Aug 27, 2019
by
Chris Johnson
Committed by
GitHub
Aug 27, 2019
Browse files
Merge pull request #3 from google/master
Update master
parents
130e5aa8
fdd6a1dc
Changes
218
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1372 additions
and
795 deletions
+1372
-795
googletest/test/googletest-catch-exceptions-test.py
googletest/test/googletest-catch-exceptions-test.py
+75
-72
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
+65
-21
googletest/test/googletest-death-test_ex_test.cc
googletest/test/googletest-death-test_ex_test.cc
+1
-1
googletest/test/googletest-filepath-test.cc
googletest/test/googletest-filepath-test.cc
+0
-2
googletest/test/googletest-filter-unittest_.cc
googletest/test/googletest-filter-unittest_.cc
+2
-2
googletest/test/googletest-json-outfiles-test.py
googletest/test/googletest-json-outfiles-test.py
+60
-31
googletest/test/googletest-json-output-unittest.py
googletest/test/googletest-json-output-unittest.py
+502
-358
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
+303
-88
googletest/test/googletest-options-test.cc
googletest/test/googletest-options-test.cc
+0
-1
googletest/test/googletest-output-test-golden-lin.txt
googletest/test/googletest-output-test-golden-lin.txt
+137
-44
googletest/test/googletest-output-test.py
googletest/test/googletest-output-test.py
+0
-1
googletest/test/googletest-output-test_.cc
googletest/test/googletest-output-test_.cc
+96
-34
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
+72
-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
+7
-10
No files found.
googletest/test/googletest-catch-exceptions-test.py
View file @
85f059f0
...
...
@@ -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
)
...
...
@@ -117,10 +117,11 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
"""
def
testCatchesCxxExceptionsInFixtureConstructor
(
self
):
self
.
assert_
(
'C++ exception with description '
'"Standard C++ exception" thrown '
'in the test fixture
\'
s constructor'
in
EX_BINARY_OUTPUT
)
self
.
assertTrue
(
'C++ exception with description '
'"Standard C++ exception" thrown '
'in the test fixture
\'
s constructor'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert_
(
'unexpected'
not
in
EX_BINARY_OUTPUT
,
'This failure belongs in this test only if '
'"CxxExceptionInConstructorTest" (no quotes) '
...
...
@@ -130,88 +131,90 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
EX_BINARY_OUTPUT
):
def
testCatchesCxxExceptionsInFixtureDestructor
(
self
):
self
.
assert_
(
'C++ exception with description '
'"Standard C++ exception" thrown '
'in the test fixture
\'
s destructor'
in
EX_BINARY_OUTPUT
)
self
.
assert_
(
'CxxExceptionInDestructorTest::TearDownTestCase() '
'called as expected.'
in
EX_BINARY_OUTPUT
)
self
.
assertTrue
(
'C++ exception with description '
'"Standard C++ exception" thrown '
'in the test fixture
\'
s destructor'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assertTrue
(
'CxxExceptionInDestructorTest::TearDownTestSuite() '
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
def
testCatchesCxxExceptionsInSetUpTestCase
(
self
):
self
.
assert
_
(
'C++ exception with description "Standard C++ exception"'
' thrown in SetUpTestCase()
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInConstructorTest::TearDownTestCase() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTestCaseTest constructor '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTestCaseTest destructor '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTestCaseTest::SetUp() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTestCaseTest::TearDown() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTestCaseTest test body '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'C++ exception with description "Standard C++ exception"
'
' thrown in SetUpTestSuite()'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInConstructorTest::TearDownTestSuite()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTestSuiteTest constructor
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTestSuiteTest destructor
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTestSuiteTest::SetUp()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTestSuiteTest::TearDown()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTestSuiteTest test body
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
def
testCatchesCxxExceptionsInTearDownTestCase
(
self
):
self
.
assert
_
(
'C++ exception with description "Standard C++ exception"'
' thrown in TearDownTestCase()
'
in
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'C++ exception with description "Standard C++ exception"
'
' thrown in TearDownTestSuite()'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
def
testCatchesCxxExceptionsInSetUp
(
self
):
self
.
assert
_
(
'C++ exception with description "Standard C++ exception"'
' thrown in SetUp()
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTest::TearDownTestCase() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTest destructor '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInSetUpTest::TearDown() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'C++ exception with description "Standard C++ exception"
'
' thrown in SetUp()'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTest::TearDownTestSuite()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTest destructor
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInSetUpTest::TearDown()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert_
(
'unexpected'
not
in
EX_BINARY_OUTPUT
,
'This failure belongs in this test only if '
'"CxxExceptionInSetUpTest" (no quotes) '
'appears on the same line as words "called unexpectedly"'
)
def
testCatchesCxxExceptionsInTearDown
(
self
):
self
.
assert
_
(
'C++ exception with description "Standard C++ exception"'
' thrown in TearDown()
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInTearDownTest::TearDownTestCase() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInTearDownTest destructor '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'C++ exception with description "Standard C++ exception"
'
' thrown in TearDown()'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInTearDownTest::TearDownTestSuite()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInTearDownTest destructor
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
def
testCatchesCxxExceptionsInTestBody
(
self
):
self
.
assert
_
(
'C++ exception with description "Standard C++ exception"'
' thrown in the test body
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInTestBodyTest::TearDownTestCase() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInTestBodyTest destructor '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
_
(
'CxxExceptionInTestBodyTest::TearDown() '
'called as expected.
'
in
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'C++ exception with description "Standard C++ exception"
'
' thrown in the test body'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInTestBodyTest::TearDownTestSuite()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInTestBodyTest destructor
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
self
.
assert
True
(
'CxxExceptionInTestBodyTest::TearDown()
'
'called as expected.'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
def
testCatchesNonStdCxxExceptions
(
self
):
self
.
assert_
(
'Unknown C++ exception thrown in the test body'
in
EX_BINARY_OUTPUT
)
self
.
assertTrue
(
'Unknown C++ exception thrown in the test body'
in
EX_BINARY_OUTPUT
,
EX_BINARY_OUTPUT
)
def
testUnhandledCxxExceptionsAbortTheProgram
(
self
):
# Filters out SEH exception tests on Windows. Unhandled SEH exceptions
...
...
googletest/test/googletest-catch-exceptions-test_.cc
View file @
85f059f0
...
...
@@ -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 @
85f059f0
...
...
@@ -41,7 +41,9 @@ using testing::internal::AlwaysTrue;
#if GTEST_HAS_DEATH_TEST
# if GTEST_OS_WINDOWS
# include <fcntl.h> // For O_BINARY
# include <direct.h> // For chdir().
# include <io.h>
# else
# include <unistd.h>
# include <sys/wait.h> // For waitpid.
...
...
@@ -139,7 +141,7 @@ class TestForDeathTest : public testing::Test {
DieInside
(
"MemberFunction"
);
}
// True if
f
MemberFunction() should die.
// True if MemberFunction() should die.
bool
should_die_
;
const
FilePath
original_dir_
;
};
...
...
@@ -156,7 +158,7 @@ class MayDie {
}
private:
// True if
f
MemberFunction() should die.
// True if MemberFunction() should die.
bool
should_die_
;
};
...
...
@@ -202,6 +204,26 @@ int DieInDebugElse12(int* sideeffect) {
return
12
;
}
# if GTEST_OS_WINDOWS
// Death in dbg due to Windows CRT assertion failure, not opt.
int
DieInCRTDebugElse12
(
int
*
sideeffect
)
{
if
(
sideeffect
)
*
sideeffect
=
12
;
// Create an invalid fd by closing a valid one
int
fdpipe
[
2
];
EXPECT_EQ
(
_pipe
(
fdpipe
,
256
,
O_BINARY
),
0
);
EXPECT_EQ
(
_close
(
fdpipe
[
0
]),
0
);
EXPECT_EQ
(
_close
(
fdpipe
[
1
]),
0
);
// _dup() should crash in debug mode
EXPECT_EQ
(
_dup
(
fdpipe
[
0
]),
-
1
);
return
12
;
}
#endif // GTEST_OS_WINDOWS
# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
// Tests the ExitedWithCode predicate.
...
...
@@ -493,17 +515,6 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
const
testing
::
internal
::
RE
regex
(
regex_c_str
);
EXPECT_DEATH
(
GlobalFunction
(),
regex
);
# if GTEST_HAS_GLOBAL_STRING
const
::
string
regex_str
(
regex_c_str
);
EXPECT_DEATH
(
GlobalFunction
(),
regex_str
);
// This one is tricky; a temporary pointer into another temporary. Reference
// lifetime extension of the pointer is not sufficient.
EXPECT_DEATH
(
GlobalFunction
(),
::
string
(
regex_c_str
).
c_str
());
# endif // GTEST_HAS_GLOBAL_STRING
# if !GTEST_USES_PCRE
const
::
std
::
string
regex_std_str
(
regex_c_str
);
...
...
@@ -562,7 +573,7 @@ TEST_F(TestForDeathTest, ErrorMessageMismatch) {
},
"died but not with expected error"
);
}
// On exit, *aborted will be true if
f
the EXPECT_DEATH() statement
// On exit, *aborted will be true if the EXPECT_DEATH() statement
// aborted the function.
void
ExpectDeathTestHelper
(
bool
*
aborted
)
{
*
aborted
=
true
;
...
...
@@ -643,6 +654,40 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
# endif
}
# if GTEST_OS_WINDOWS
// Tests that EXPECT_DEBUG_DEATH works as expected when in debug mode
// the Windows CRT crashes the process with an assertion failure.
// 1. Asserts on death.
// 2. Has no side effect (doesn't pop up a window or wait for user input).
//
// And in opt mode, it:
// 1. Has side effects but does not assert.
TEST_F
(
TestForDeathTest
,
CRTDebugDeath
)
{
int
sideeffect
=
0
;
// Put the regex in a local variable to make sure we don't get an "unused"
// warning in opt mode.
const
char
*
regex
=
"dup.* : Assertion failed"
;
EXPECT_DEBUG_DEATH
(
DieInCRTDebugElse12
(
&
sideeffect
),
regex
)
<<
"Must accept a streamed message"
;
# ifdef NDEBUG
// Checks that the assignment occurs in opt mode (sideeffect).
EXPECT_EQ
(
12
,
sideeffect
);
# else
// Checks that the assignment does not occur in dbg mode (no sideeffect).
EXPECT_EQ
(
0
,
sideeffect
);
# endif
}
# endif // GTEST_OS_WINDOWS
// Tests that ASSERT_DEBUG_DEATH works as expected, that is, you can stream a
// message to it, and in debug mode it:
// 1. Asserts on death.
...
...
@@ -895,10 +940,12 @@ class MockDeathTestFactory : public DeathTestFactory {
int
AssumeRoleCalls
()
const
{
return
assume_role_calls_
;
}
int
WaitCalls
()
const
{
return
wait_calls_
;
}
size_t
PassedCalls
()
const
{
return
passed_args_
.
size
();
}
bool
PassedArgument
(
int
n
)
const
{
return
passed_args_
[
n
];
}
bool
PassedArgument
(
int
n
)
const
{
return
passed_args_
[
static_cast
<
size_t
>
(
n
)];
}
size_t
AbortCalls
()
const
{
return
abort_args_
.
size
();
}
DeathTest
::
AbortReason
AbortArgument
(
int
n
)
const
{
return
abort_args_
[
n
];
return
abort_args_
[
static_cast
<
size_t
>
(
n
)
];
}
bool
TestDeleted
()
const
{
return
test_deleted_
;
}
...
...
@@ -1017,12 +1064,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_
;
...
...
@@ -1281,9 +1328,6 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
# if GTEST_OS_WINDOWS
TEST
(
EnvironmentTest
,
HandleFitsIntoSizeT
)
{
// FIXME: Remove this test after this condition is verified
// in a static assertion in gtest-death-test.cc in the function
// GetStatusFileDescriptor.
ASSERT_TRUE
(
sizeof
(
HANDLE
)
<=
sizeof
(
size_t
));
}
# endif // GTEST_OS_WINDOWS
...
...
googletest/test/googletest-death-test_ex_test.cc
View file @
85f059f0
...
...
@@ -68,7 +68,7 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
"exceptional message"
);
// Verifies that the location is mentioned in the failure text.
EXPECT_NONFATAL_FAILURE
(
EXPECT_DEATH
(
throw
TestException
(),
""
),
"googletest-death-test_ex_test.cc"
);
__FILE__
);
}
# endif // GTEST_HAS_EXCEPTIONS
...
...
googletest/test/googletest-filepath-test.cc
View file @
85f059f0
...
...
@@ -50,8 +50,6 @@ namespace internal {
namespace
{
#if GTEST_OS_WINDOWS_MOBILE
// FIXME: Move these to the POSIX adapter section in
// gtest-port.h.
// Windows CE doesn't have the remove C function.
int
remove
(
const
char
*
path
)
{
...
...
googletest/test/googletest-filter-unittest_.cc
View file @
85f059f0
...
...
@@ -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-outfiles-test.py
View file @
85f059f0
...
...
@@ -40,24 +40,41 @@ GTEST_OUTPUT_1_TEST = 'gtest_xml_outfile1_test_'
GTEST_OUTPUT_2_TEST
=
'gtest_xml_outfile2_test_'
EXPECTED_1
=
{
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'testsuites'
:
[{
u
'name'
:
u
'PropertyOne'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'name'
:
u
'PropertyOne'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'TestSomeProperties'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'PropertyOne'
,
u
'SetUpProp'
:
u
'1'
,
u
'TestSomeProperty'
:
u
'1'
,
...
...
@@ -67,23 +84,40 @@ EXPECTED_1 = {
}
EXPECTED_2
=
{
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'testsuites'
:
[{
u
'name'
:
u
'PropertyTwo'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'name'
:
u
'PropertyTwo'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'TestSomeProperties'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'timestamp'
:
u
'*'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'PropertyTwo'
,
u
'SetUpProp'
:
u
'2'
,
...
...
@@ -136,11 +170,6 @@ class GTestJsonOutFilesTest(gtest_test_utils.TestCase):
self
.
assert_
(
p
.
exited
)
self
.
assertEquals
(
0
,
p
.
exit_code
)
# FIXME: libtool causes the built test binary to be
# named lt-gtest_xml_outfiles_test_ instead of
# gtest_xml_outfiles_test_. To account for this possibility, we
# allow both names in the following code. We should remove this
# when libtool replacement tool is ready.
output_file_name1
=
test_name
+
'.json'
output_file1
=
os
.
path
.
join
(
self
.
output_dir_
,
output_file_name1
)
output_file_name2
=
'lt-'
+
output_file_name1
...
...
googletest/test/googletest-json-output-unittest.py
View file @
85f059f0
...
...
@@ -57,386 +57,530 @@ else:
STACK_TRACE_TEMPLATE
=
''
EXPECTED_NON_EMPTY
=
{
u
'tests'
:
24
,
u
'failures'
:
4
,
u
'disabled'
:
2
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'time'
:
u
'*'
,
u
'ad_hoc_property'
:
u
'42'
,
u
'name'
:
u
'AllTests'
,
u
'testsuites'
:
[
{
u
'name'
:
u
'SuccessfulTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'tests'
:
24
,
u
'failures'
:
4
,
u
'disabled'
:
2
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'time'
:
u
'*'
,
u
'ad_hoc_property'
:
u
'42'
,
u
'name'
:
u
'AllTests'
,
u
'testsuites'
:
[{
u
'name'
:
u
'SuccessfulTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'Succeeds'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'Succeeds'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'SuccessfulTest'
}
]
},
{
u
'name'
:
u
'FailedTest'
,
u
'tests'
:
1
,
u
'failures'
:
1
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'SuccessfulTest'
}]
},
{
u
'name'
:
u
'FailedTest'
,
u
'tests'
:
1
,
u
'failures'
:
1
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'Fails'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'FailedTest'
,
u
'failures'
:
[{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Expected equality of these values:
\n
'
u
' 1
\n
2'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}]
}]
},
{
u
'name'
:
u
'DisabledTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
1
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'DISABLED_test_not_run'
,
u
'status'
:
u
'NOTRUN'
,
u
'result'
:
u
'SUPPRESSED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'Fails'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'FailedTest'
,
u
'failures'
:
[
{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Expected equality of these values:
\n
'
u
' 1
\n
2'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}
]
}
]
},
{
u
'name'
:
u
'DisabledTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
1
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'DisabledTest'
}]
},
{
u
'name'
:
u
'SkippedTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'Skipped'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'SKIPPED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'DISABLED_test_not_run'
,
u
'status'
:
u
'NOTRUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'DisabledTest'
}
]
},
{
u
'name'
:
u
'SkippedTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'SkippedTest'
}]
},
{
u
'name'
:
u
'MixedResultTest'
,
u
'tests'
:
3
,
u
'failures'
:
1
,
u
'disabled'
:
1
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'Succeeds'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'Skipped'
,
u
'status'
:
u
'SKIPPED'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'SkippedTest'
}
]
},
{
u
'name'
:
u
'MixedResultTest'
,
u
'tests'
:
3
,
u
'failures'
:
1
,
u
'disabled'
:
1
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'MixedResultTest'
},
{
u
'name'
:
u
'Fails'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'MixedResultTest'
,
u
'failures'
:
[{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Expected equality of these values:
\n
'
u
' 1
\n
2'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
},
{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Expected equality of these values:
\n
'
u
' 2
\n
3'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}]
},
{
u
'name'
:
u
'DISABLED_test'
,
u
'status'
:
u
'NOTRUN'
,
u
'result'
:
u
'SUPPRESSED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'Succeeds'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'MixedResultTest'
},
{
u
'name'
:
u
'Fails'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'MixedResultTest'
,
u
'failures'
:
[
{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Expected equality of these values:
\n
'
u
' 1
\n
2'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
},
{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Expected equality of these values:
\n
'
u
' 2
\n
3'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}
]
},
{
u
'name'
:
u
'DISABLED_test'
,
u
'status'
:
u
'NOTRUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'MixedResultTest'
}
]
},
{
u
'name'
:
u
'XmlQuotingTest'
,
u
'tests'
:
1
,
u
'failures'
:
1
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'MixedResultTest'
}]
},
{
u
'name'
:
u
'XmlQuotingTest'
,
u
'tests'
:
1
,
u
'failures'
:
1
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'OutputsCData'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'XmlQuotingTest'
,
u
'failures'
:
[{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Failed
\n
XML output: <?xml encoding="utf-8">'
u
'<top><![CDATA[cdata text]]></top>'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}]
}]
},
{
u
'name'
:
u
'InvalidCharactersTest'
,
u
'tests'
:
1
,
u
'failures'
:
1
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'InvalidCharactersInMessage'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'InvalidCharactersTest'
,
u
'failures'
:
[{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Failed
\n
Invalid characters in brackets'
u
' [
\x01\x02
]'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}]
}]
},
{
u
'name'
:
u
'PropertyRecordingTest'
,
u
'tests'
:
4
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'SetUpTestSuite'
:
u
'yes'
,
u
'TearDownTestSuite'
:
u
'aye'
,
u
'testsuite'
:
[{
u
'name'
:
u
'OneProperty'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'OutputsCData'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'XmlQuotingTest'
,
u
'failures'
:
[
{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Failed
\n
XML output: <?xml encoding="utf-8">'
u
'<top><![CDATA[cdata text]]></top>'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}
]
}
]
},
{
u
'name'
:
u
'InvalidCharactersTest'
,
u
'tests'
:
1
,
u
'failures'
:
1
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_1'
:
u
'1'
},
{
u
'name'
:
u
'IntValuedProperty'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'InvalidCharactersInMessage'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'InvalidCharactersTest'
,
u
'failures'
:
[
{
u
'failure'
:
u
'gtest_xml_output_unittest_.cc:*
\n
'
u
'Failed
\n
Invalid characters in brackets'
u
' [
\x01\x02
]'
+
STACK_TRACE_TEMPLATE
,
u
'type'
:
u
''
}
]
}
]
},
{
u
'name'
:
u
'PropertyRecordingTest'
,
u
'tests'
:
4
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_int'
:
u
'1'
},
{
u
'name'
:
u
'ThreeProperties'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'SetUpTestCase'
:
u
'yes'
,
u
'TearDownTestCase'
:
u
'aye'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'OneProperty'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_1'
:
u
'1'
},
{
u
'name'
:
u
'IntValuedProperty'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_int'
:
u
'1'
},
{
u
'name'
:
u
'ThreeProperties'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_1'
:
u
'1'
,
u
'key_2'
:
u
'2'
,
u
'key_3'
:
u
'3'
},
{
u
'name'
:
u
'TwoValuesForOneKeyUsesLastValue'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_1'
:
u
'2'
}
]
},
{
u
'name'
:
u
'NoFixtureTest'
,
u
'tests'
:
3
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_1'
:
u
'1'
,
u
'key_2'
:
u
'2'
,
u
'key_3'
:
u
'3'
},
{
u
'name'
:
u
'TwoValuesForOneKeyUsesLastValue'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'RecordProperty'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'NoFixtureTest'
,
u
'key'
:
u
'1'
},
{
u
'name'
:
u
'ExternalUtilityThatCallsRecordIntValuedProperty'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'NoFixtureTest'
,
u
'key_for_utility_int'
:
u
'1'
},
{
u
'name'
:
u
'ExternalUtilityThatCallsRecordStringValuedProperty'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'NoFixtureTest'
,
u
'key_for_utility_string'
:
u
'1'
}
]
},
{
u
'name'
:
u
'TypedTest/0'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'PropertyRecordingTest'
,
u
'key_1'
:
u
'2'
}]
},
{
u
'name'
:
u
'NoFixtureTest'
,
u
'tests'
:
3
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'RecordProperty'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'int'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'TypedTest/0'
}
]
},
{
u
'name'
:
u
'TypedTest/1'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'NoFixtureTest'
,
u
'key'
:
u
'1'
},
{
u
'name'
:
u
'ExternalUtilityThatCallsRecordIntValuedProperty'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'long'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'TypedTest/1'
}
]
},
{
u
'name'
:
u
'Single/TypeParameterizedTestCase/0'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'NoFixtureTest'
,
u
'key_for_utility_int'
:
u
'1'
},
{
u
'name'
:
u
'ExternalUtilityThatCallsRecordStringValuedProperty'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'NoFixtureTest'
,
u
'key_for_utility_string'
:
u
'1'
}]
},
{
u
'name'
:
u
'TypedTest/0'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'int'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'TypedTest/0'
}]
},
{
u
'name'
:
u
'TypedTest/1'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'long'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'TypedTest/1'
}]
},
{
u
'name'
:
u
'Single/TypeParameterizedTestSuite/0'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'int'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'Single/TypeParameterizedTestSuite/0'
}]
},
{
u
'name'
:
u
'Single/TypeParameterizedTestSuite/1'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'long'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'Single/TypeParameterizedTestSuite/1'
}]
},
{
u
'name'
:
u
'Single/ValueParamTest'
,
u
'tests'
:
4
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'HasValueParamAttribute/0'
,
u
'value_param'
:
u
'33'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
},
{
u
'name'
:
u
'HasValueParamAttribute/1'
,
u
'value_param'
:
u
'42'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'int'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/TypeParameterizedTestCase/0'
}
]
},
{
u
'name'
:
u
'Single/TypeParameterizedTestCase/1'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
},
{
u
'name'
:
u
'AnotherTestThatHasValueParamAttribute/0'
,
u
'value_param'
:
u
'33'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'HasTypeParamAttribute'
,
u
'type_param'
:
u
'long'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/TypeParameterizedTestCase/1'
}
]
},
{
u
'name'
:
u
'Single/ValueParamTest'
,
u
'tests'
:
4
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
},
{
u
'name'
:
u
'AnotherTestThatHasValueParamAttribute/1'
,
u
'value_param'
:
u
'42'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[
{
u
'name'
:
u
'HasValueParamAttribute/0'
,
u
'value_param'
:
u
'33'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
},
{
u
'name'
:
u
'HasValueParamAttribute/1'
,
u
'value_param'
:
u
'42'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
},
{
u
'name'
:
u
'AnotherTestThatHasValueParamAttribute/0'
,
u
'value_param'
:
u
'33'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
},
{
u
'name'
:
u
'AnotherTestThatHasValueParamAttribute/1'
,
u
'value_param'
:
u
'42'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
}
]
}
]
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'Single/ValueParamTest'
}]
}]
}
EXPECTED_FILTERED
=
{
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'ad_hoc_property'
:
u
'42'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'ad_hoc_property'
:
u
'42'
,
u
'testsuites'
:
[{
u
'name'
:
u
'SuccessfulTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'name'
:
u
'SuccessfulTest'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'Succeeds'
,
u
'status'
:
u
'RUN'
,
u
'result'
:
u
'COMPLETED'
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'classname'
:
u
'SuccessfulTest'
,
}]
}],
...
...
googletest/test/googletest-list-tests-unittest_.cc
View file @
85f059f0
...
...
@@ -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 @
85f059f0
...
...
@@ -35,12 +35,13 @@
#include <vector>
#include "gtest/gtest.h"
#include "gtest/internal/custom/gtest.h"
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
;
...
...
@@ -76,10 +77,11 @@ class EventRecordingListener : public TestEventListener {
void
OnEnvironmentsSetUpEnd
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnEnvironmentsSetUpEnd"
));
}
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestCaseStart
(
const
TestCase
&
/*test_case*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestCaseStart"
));
}
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestStart
(
const
TestInfo
&
/*test_info*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestStart"
));
...
...
@@ -93,9 +95,11 @@ class EventRecordingListener : public TestEventListener {
g_events
->
push_back
(
GetFullMethodName
(
"OnTestEnd"
));
}
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestCaseEnd
(
const
TestCase
&
/*test_case*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestCaseEnd"
));
}
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnEnvironmentsTearDownStart
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnEnvironmentsTearDownStart"
));
...
...
@@ -125,6 +129,78 @@ class EventRecordingListener : public TestEventListener {
std
::
string
name_
;
};
// This listener is using OnTestSuiteStart, OnTestSuiteEnd API
class
EventRecordingListener2
:
public
TestEventListener
{
public:
explicit
EventRecordingListener2
(
const
char
*
name
)
:
name_
(
name
)
{}
protected:
void
OnTestProgramStart
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestProgramStart"
));
}
void
OnTestIterationStart
(
const
UnitTest
&
/*unit_test*/
,
int
iteration
)
override
{
Message
message
;
message
<<
GetFullMethodName
(
"OnTestIterationStart"
)
<<
"("
<<
iteration
<<
")"
;
g_events
->
push_back
(
message
.
GetString
());
}
void
OnEnvironmentsSetUpStart
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnEnvironmentsSetUpStart"
));
}
void
OnEnvironmentsSetUpEnd
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnEnvironmentsSetUpEnd"
));
}
void
OnTestSuiteStart
(
const
TestSuite
&
/*test_suite*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestSuiteStart"
));
}
void
OnTestStart
(
const
TestInfo
&
/*test_info*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestStart"
));
}
void
OnTestPartResult
(
const
TestPartResult
&
/*test_part_result*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestPartResult"
));
}
void
OnTestEnd
(
const
TestInfo
&
/*test_info*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestEnd"
));
}
void
OnTestSuiteEnd
(
const
TestSuite
&
/*test_suite*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestSuiteEnd"
));
}
void
OnEnvironmentsTearDownStart
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnEnvironmentsTearDownStart"
));
}
void
OnEnvironmentsTearDownEnd
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnEnvironmentsTearDownEnd"
));
}
void
OnTestIterationEnd
(
const
UnitTest
&
/*unit_test*/
,
int
iteration
)
override
{
Message
message
;
message
<<
GetFullMethodName
(
"OnTestIterationEnd"
)
<<
"("
<<
iteration
<<
")"
;
g_events
->
push_back
(
message
.
GetString
());
}
void
OnTestProgramEnd
(
const
UnitTest
&
/*unit_test*/
)
override
{
g_events
->
push_back
(
GetFullMethodName
(
"OnTestProgramEnd"
));
}
private:
std
::
string
GetFullMethodName
(
const
char
*
name
)
{
return
name_
+
"."
+
name
;
}
std
::
string
name_
;
};
class
EnvironmentInvocationCatcher
:
public
Environment
{
protected:
void
SetUp
()
override
{
g_events
->
push_back
(
"Environment::SetUp"
);
}
...
...
@@ -134,12 +210,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"
);
}
...
...
@@ -165,6 +241,7 @@ TEST_F(ListenerTest, DoesBar) {
using
::
testing
::
internal
::
EnvironmentInvocationCatcher
;
using
::
testing
::
internal
::
EventRecordingListener
;
using
::
testing
::
internal
::
EventRecordingListener2
;
void
VerifyResults
(
const
std
::
vector
<
std
::
string
>&
data
,
const
char
*
const
*
expected_data
,
...
...
@@ -199,6 +276,8 @@ int main(int argc, char **argv) {
new
EventRecordingListener
(
"1st"
));
UnitTest
::
GetInstance
()
->
listeners
().
Append
(
new
EventRecordingListener
(
"2nd"
));
UnitTest
::
GetInstance
()
->
listeners
().
Append
(
new
EventRecordingListener2
(
"3rd"
));
AddGlobalTestEnvironment
(
new
EnvironmentInvocationCatcher
);
...
...
@@ -208,88 +287,224 @@ int main(int argc, char **argv) {
::
testing
::
GTEST_FLAG
(
repeat
)
=
2
;
int
ret_val
=
RUN_ALL_TESTS
();
const
char
*
const
expected_events
[]
=
{
"1st.OnTestProgramStart"
,
"2nd.OnTestProgramStart"
,
"1st.OnTestIterationStart(0)"
,
"2nd.OnTestIterationStart(0)"
,
"1st.OnEnvironmentsSetUpStart"
,
"2nd.OnEnvironmentsSetUpStart"
,
"Environment::SetUp"
,
"2nd.OnEnvironmentsSetUpEnd"
,
"1st.OnEnvironmentsSetUpEnd"
,
"1st.OnTestCaseStart"
,
"2nd.OnTestCaseStart"
,
"ListenerTest::SetUpTestCase"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTestCase"
,
"2nd.OnTestCaseEnd"
,
"1st.OnTestCaseEnd"
,
"1st.OnEnvironmentsTearDownStart"
,
"2nd.OnEnvironmentsTearDownStart"
,
"Environment::TearDown"
,
"2nd.OnEnvironmentsTearDownEnd"
,
"1st.OnEnvironmentsTearDownEnd"
,
"2nd.OnTestIterationEnd(0)"
,
"1st.OnTestIterationEnd(0)"
,
"1st.OnTestIterationStart(1)"
,
"2nd.OnTestIterationStart(1)"
,
"1st.OnEnvironmentsSetUpStart"
,
"2nd.OnEnvironmentsSetUpStart"
,
"Environment::SetUp"
,
"2nd.OnEnvironmentsSetUpEnd"
,
"1st.OnEnvironmentsSetUpEnd"
,
"1st.OnTestCaseStart"
,
"2nd.OnTestCaseStart"
,
"ListenerTest::SetUpTestCase"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTestCase"
,
"2nd.OnTestCaseEnd"
,
"1st.OnTestCaseEnd"
,
"1st.OnEnvironmentsTearDownStart"
,
"2nd.OnEnvironmentsTearDownStart"
,
"Environment::TearDown"
,
"2nd.OnEnvironmentsTearDownEnd"
,
"1st.OnEnvironmentsTearDownEnd"
,
"2nd.OnTestIterationEnd(1)"
,
"1st.OnTestIterationEnd(1)"
,
"2nd.OnTestProgramEnd"
,
"1st.OnTestProgramEnd"
};
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// The deprecated OnTestSuiteStart/OnTestCaseStart events are included
const
char
*
const
expected_events
[]
=
{
"1st.OnTestProgramStart"
,
"2nd.OnTestProgramStart"
,
"3rd.OnTestProgramStart"
,
"1st.OnTestIterationStart(0)"
,
"2nd.OnTestIterationStart(0)"
,
"3rd.OnTestIterationStart(0)"
,
"1st.OnEnvironmentsSetUpStart"
,
"2nd.OnEnvironmentsSetUpStart"
,
"3rd.OnEnvironmentsSetUpStart"
,
"Environment::SetUp"
,
"3rd.OnEnvironmentsSetUpEnd"
,
"2nd.OnEnvironmentsSetUpEnd"
,
"1st.OnEnvironmentsSetUpEnd"
,
"3rd.OnTestSuiteStart"
,
"1st.OnTestCaseStart"
,
"2nd.OnTestCaseStart"
,
"ListenerTest::SetUpTestSuite"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTestSuite"
,
"3rd.OnTestSuiteEnd"
,
"2nd.OnTestCaseEnd"
,
"1st.OnTestCaseEnd"
,
"1st.OnEnvironmentsTearDownStart"
,
"2nd.OnEnvironmentsTearDownStart"
,
"3rd.OnEnvironmentsTearDownStart"
,
"Environment::TearDown"
,
"3rd.OnEnvironmentsTearDownEnd"
,
"2nd.OnEnvironmentsTearDownEnd"
,
"1st.OnEnvironmentsTearDownEnd"
,
"3rd.OnTestIterationEnd(0)"
,
"2nd.OnTestIterationEnd(0)"
,
"1st.OnTestIterationEnd(0)"
,
"1st.OnTestIterationStart(1)"
,
"2nd.OnTestIterationStart(1)"
,
"3rd.OnTestIterationStart(1)"
,
"1st.OnEnvironmentsSetUpStart"
,
"2nd.OnEnvironmentsSetUpStart"
,
"3rd.OnEnvironmentsSetUpStart"
,
"Environment::SetUp"
,
"3rd.OnEnvironmentsSetUpEnd"
,
"2nd.OnEnvironmentsSetUpEnd"
,
"1st.OnEnvironmentsSetUpEnd"
,
"3rd.OnTestSuiteStart"
,
"1st.OnTestCaseStart"
,
"2nd.OnTestCaseStart"
,
"ListenerTest::SetUpTestSuite"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTestSuite"
,
"3rd.OnTestSuiteEnd"
,
"2nd.OnTestCaseEnd"
,
"1st.OnTestCaseEnd"
,
"1st.OnEnvironmentsTearDownStart"
,
"2nd.OnEnvironmentsTearDownStart"
,
"3rd.OnEnvironmentsTearDownStart"
,
"Environment::TearDown"
,
"3rd.OnEnvironmentsTearDownEnd"
,
"2nd.OnEnvironmentsTearDownEnd"
,
"1st.OnEnvironmentsTearDownEnd"
,
"3rd.OnTestIterationEnd(1)"
,
"2nd.OnTestIterationEnd(1)"
,
"1st.OnTestIterationEnd(1)"
,
"3rd.OnTestProgramEnd"
,
"2nd.OnTestProgramEnd"
,
"1st.OnTestProgramEnd"
};
#else
const
char
*
const
expected_events
[]
=
{
"1st.OnTestProgramStart"
,
"2nd.OnTestProgramStart"
,
"3rd.OnTestProgramStart"
,
"1st.OnTestIterationStart(0)"
,
"2nd.OnTestIterationStart(0)"
,
"3rd.OnTestIterationStart(0)"
,
"1st.OnEnvironmentsSetUpStart"
,
"2nd.OnEnvironmentsSetUpStart"
,
"3rd.OnEnvironmentsSetUpStart"
,
"Environment::SetUp"
,
"3rd.OnEnvironmentsSetUpEnd"
,
"2nd.OnEnvironmentsSetUpEnd"
,
"1st.OnEnvironmentsSetUpEnd"
,
"3rd.OnTestSuiteStart"
,
"ListenerTest::SetUpTestSuite"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTestSuite"
,
"3rd.OnTestSuiteEnd"
,
"1st.OnEnvironmentsTearDownStart"
,
"2nd.OnEnvironmentsTearDownStart"
,
"3rd.OnEnvironmentsTearDownStart"
,
"Environment::TearDown"
,
"3rd.OnEnvironmentsTearDownEnd"
,
"2nd.OnEnvironmentsTearDownEnd"
,
"1st.OnEnvironmentsTearDownEnd"
,
"3rd.OnTestIterationEnd(0)"
,
"2nd.OnTestIterationEnd(0)"
,
"1st.OnTestIterationEnd(0)"
,
"1st.OnTestIterationStart(1)"
,
"2nd.OnTestIterationStart(1)"
,
"3rd.OnTestIterationStart(1)"
,
"1st.OnEnvironmentsSetUpStart"
,
"2nd.OnEnvironmentsSetUpStart"
,
"3rd.OnEnvironmentsSetUpStart"
,
"Environment::SetUp"
,
"3rd.OnEnvironmentsSetUpEnd"
,
"2nd.OnEnvironmentsSetUpEnd"
,
"1st.OnEnvironmentsSetUpEnd"
,
"3rd.OnTestSuiteStart"
,
"ListenerTest::SetUpTestSuite"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"1st.OnTestStart"
,
"2nd.OnTestStart"
,
"3rd.OnTestStart"
,
"ListenerTest::SetUp"
,
"ListenerTest::* Test Body"
,
"1st.OnTestPartResult"
,
"2nd.OnTestPartResult"
,
"3rd.OnTestPartResult"
,
"ListenerTest::TearDown"
,
"3rd.OnTestEnd"
,
"2nd.OnTestEnd"
,
"1st.OnTestEnd"
,
"ListenerTest::TearDownTestSuite"
,
"3rd.OnTestSuiteEnd"
,
"1st.OnEnvironmentsTearDownStart"
,
"2nd.OnEnvironmentsTearDownStart"
,
"3rd.OnEnvironmentsTearDownStart"
,
"Environment::TearDown"
,
"3rd.OnEnvironmentsTearDownEnd"
,
"2nd.OnEnvironmentsTearDownEnd"
,
"1st.OnEnvironmentsTearDownEnd"
,
"3rd.OnTestIterationEnd(1)"
,
"2nd.OnTestIterationEnd(1)"
,
"1st.OnTestIterationEnd(1)"
,
"3rd.OnTestProgramEnd"
,
"2nd.OnTestProgramEnd"
,
"1st.OnTestProgramEnd"
};
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
VerifyResults
(
events
,
expected_events
,
sizeof
(
expected_events
)
/
sizeof
(
expected_events
[
0
]));
...
...
googletest/test/googletest-options-test.cc
View file @
85f059f0
...
...
@@ -111,7 +111,6 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
#elif GTEST_OS_FUCHSIA
const
bool
success
=
exe_str
==
"app"
;
#else
// FIXME: remove the hard-coded "lt-" prefix when libtool replacement is ready
const
bool
success
=
exe_str
==
"googletest-options-test"
||
exe_str
==
"gtest_all_test"
||
...
...
googletest/test/googletest-output-test-golden-lin.txt
View file @
85f059f0
...
...
@@ -12,7 +12,7 @@ Expected equality of these values:
3
Stack trace: (omitted)
[0;32m[==========] [mRunning
76
tests from
3
4 test
cas
es.
[0;32m[==========] [mRunning
85
tests from 4
0
test
suit
es.
[0;32m[----------] [mGlobal test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
...
...
@@ -380,66 +380,74 @@ Stack trace: (omitted)
[0;32m[ RUN ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
foo.cc:42: Failure
Failed
Expected failure in foo.cc
Expected
nonfatal
failure in foo.cc
Stack trace: (omitted)
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[0;32m[----------] [m4 tests from MixedUpTestCaseTest
[0;32m[ RUN ] [mMixedUpTestCaseTest.FirstTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTestCaseTest.FirstTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTestCaseTest.SecondTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTestCaseTest.SecondTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTestCaseTest.ThisShouldFail
[0;32m[----------] [m1 test from GtestFailAtTest
[0;32m[ RUN ] [mGtestFailAtTest.MessageContainsSpecifiedFileAndLineNumber
foo.cc:42: Failure
Failed
Expected fatal failure in foo.cc
Stack trace: (omitted)
[0;31m[ FAILED ] [mGtestFailAtTest.MessageContainsSpecifiedFileAndLineNumber
[0;32m[----------] [m4 tests from MixedUpTestSuiteTest
[0;32m[ RUN ] [mMixedUpTestSuiteTest.FirstTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTestSuiteTest.FirstTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTestSuiteTest.SecondTestFromNamespaceFoo
[0;32m[ OK ] [mMixedUpTestSuiteTest.SecondTestFromNamespaceFoo
[0;32m[ RUN ] [mMixedUpTestSuiteTest.ThisShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test
cas
e must use the same test fixture
class. However, in test
cas
e MixedUpTest
Cas
eTest,
All tests in the same test
suit
e must use the same test fixture
class. However, in test
suit
e 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
units and have the same name. You should probably rename one
of the classes to put the tests into different test
cas
es.
of the classes to put the tests into different test
suit
es.
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
cas
e must use the same test fixture
class. However, in test
cas
e MixedUpTest
Cas
eTest,
All tests in the same test
suit
e must use the same test fixture
class. However, in test
suit
e 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
units and have the same name. You should probably rename one
of the classes to put the tests into different test
cas
es.
of the classes to put the tests into different test
suit
es.
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
cas
e must use the same test fixture
class. However, in test
cas
e MixedUpTest
Cas
eWithSameTestNameTest,
All tests in the same test
suit
e must use the same test fixture
class. However, in test
suit
e 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
units and have the same name. You should probably rename one
of the classes to put the tests into different test
cas
es.
of the classes to put the tests into different test
suit
es.
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
[0;32m[ RUN ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test
cas
e must use the same test fixture
class, so mixing TEST_F and TEST in the same test
cas
e is
illegal. In test
cas
e TEST_F_before_TEST_in_same_test_case,
All tests in the same test
suit
e must use the same test fixture
class, so mixing TEST_F and TEST in the same test
suit
e is
illegal. In test
suit
e TEST_F_before_TEST_in_same_test_case,
test DefinedUsingTEST_F is defined using TEST_F but
test DefinedUsingTESTAndShouldFail is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test
...
...
@@ -453,9 +461,9 @@ Stack trace: (omitted)
[0;32m[ RUN ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test
cas
e must use the same test fixture
class, so mixing TEST_F and TEST in the same test
cas
e is
illegal. In test
cas
e TEST_before_TEST_F_in_same_test_case,
All tests in the same test
suit
e must use the same test fixture
class, so mixing TEST_F and TEST in the same test
suit
e is
illegal. In test
suit
e TEST_before_TEST_F_in_same_test_case,
test DefinedUsingTEST_FAndShouldFail is defined using TEST_F but
test DefinedUsingTEST is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test
...
...
@@ -870,6 +878,84 @@ Expected non-fatal failure.
Stack trace: (omitted)
[0;31m[ FAILED ] [mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[0;32m[----------] [m2 tests from DynamicFixture
DynamicFixture::SetUpTestSuite
[0;32m[ RUN ] [mDynamicFixture.DynamicTestPass
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[0;32m[ OK ] [mDynamicFixture.DynamicTestPass
[0;32m[ RUN ] [mDynamicFixture.DynamicTestFail
DynamicFixture()
DynamicFixture::SetUp
googletest-output-test_.cc:#: Failure
Value of: Pass
Actual: false
Expected: true
Stack trace: (omitted)
DynamicFixture::TearDown
~DynamicFixture()
[0;31m[ FAILED ] [mDynamicFixture.DynamicTestFail
DynamicFixture::TearDownTestSuite
[0;32m[----------] [m1 test from DynamicFixtureAnotherName
DynamicFixture::SetUpTestSuite
[0;32m[ RUN ] [mDynamicFixtureAnotherName.DynamicTestPass
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[0;32m[ OK ] [mDynamicFixtureAnotherName.DynamicTestPass
DynamicFixture::TearDownTestSuite
[0;32m[----------] [m2 tests from BadDynamicFixture1
DynamicFixture::SetUpTestSuite
[0;32m[ RUN ] [mBadDynamicFixture1.FixtureBase
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[0;32m[ OK ] [mBadDynamicFixture1.FixtureBase
[0;32m[ RUN ] [mBadDynamicFixture1.TestBase
DynamicFixture()
gtest.cc:#: Failure
Failed
All tests in the same test suite must use the same test fixture
class, so mixing TEST_F and TEST in the same test suite is
illegal. In test suite BadDynamicFixture1,
test FixtureBase is defined using TEST_F but
test TestBase is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test
case.
Stack trace: (omitted)
~DynamicFixture()
[0;31m[ FAILED ] [mBadDynamicFixture1.TestBase
DynamicFixture::TearDownTestSuite
[0;32m[----------] [m2 tests from BadDynamicFixture2
DynamicFixture::SetUpTestSuite
[0;32m[ RUN ] [mBadDynamicFixture2.FixtureBase
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[0;32m[ OK ] [mBadDynamicFixture2.FixtureBase
[0;32m[ RUN ] [mBadDynamicFixture2.Derived
DynamicFixture()
gtest.cc:#: Failure
Failed
All tests in the same test suite must use the same test fixture
class. However, in test suite BadDynamicFixture2,
you defined test FixtureBase and test Derived
using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation
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)
~DynamicFixture()
[0;31m[ FAILED ] [mBadDynamicFixture2.Derived
DynamicFixture::TearDownTestSuite
[0;32m[----------] [m1 test from PrintingFailingParams/FailingParamTest
[0;32m[ RUN ] [mPrintingFailingParams/FailingParamTest.Fails/0
googletest-output-test_.cc:#: Failure
...
...
@@ -880,6 +966,9 @@ Expected equality of these values:
Stack trace: (omitted)
[0;31m[ FAILED ] [mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[0;32m[----------] [m1 test from EmptyBasenameParamInst
[0;32m[ RUN ] [mEmptyBasenameParamInst.Passes/0
[0;32m[ OK ] [mEmptyBasenameParamInst.Passes/0
[0;32m[----------] [m2 tests from PrintingStrings/ParamTest
[0;32m[ RUN ] [mPrintingStrings/ParamTest.Success/a
[0;32m[ OK ] [mPrintingStrings/ParamTest.Success/a
...
...
@@ -906,9 +995,9 @@ Failed
Expected fatal failure.
Stack trace: (omitted)
[0;32m[==========] [m
76
tests from
3
4 test
cas
es ran.
[0;32m[ PASSED ] [m
26
tests.
[0;31m[ FAILED ] [m5
0
tests, listed below:
[0;32m[==========] [m
85
tests from 4
0
test
suit
es ran.
[0;32m[ PASSED ] [m
31
tests.
[0;31m[ FAILED ] [m5
4
tests, listed below:
[0;31m[ FAILED ] [mNonfatalFailureTest.EscapesStringOperands
[0;31m[ FAILED ] [mNonfatalFailureTest.DiffForLongStrings
[0;31m[ FAILED ] [mFatalFailureTest.FatalFailureInSubroutine
...
...
@@ -928,9 +1017,10 @@ Stack trace: (omitted)
[0;31m[ FAILED ] [mNonFatalFailureInSetUpTest.FailureInSetUp
[0;31m[ FAILED ] [mFatalFailureInSetUpTest.FailureInSetUp
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFail
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFailToo
[0;31m[ FAILED ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
[0;31m[ FAILED ] [mGtestFailAtTest.MessageContainsSpecifiedFileAndLineNumber
[0;31m[ FAILED ] [mMixedUpTestSuiteTest.ThisShouldFail
[0;31m[ FAILED ] [mMixedUpTestSuiteTest.ThisShouldFailToo
[0;31m[ FAILED ] [mMixedUpTestSuiteWithSameTestNameTest.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
...
...
@@ -957,14 +1047,17 @@ Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFailureWithThreadsTest.ExpectFatalFailure
[0;31m[ FAILED ] [mExpectFailureWithThreadsTest.ExpectNonFatalFailure
[0;31m[ FAILED ] [mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[0;31m[ FAILED ] [mDynamicFixture.DynamicTestFail
[0;31m[ FAILED ] [mBadDynamicFixture1.TestBase
[0;31m[ FAILED ] [mBadDynamicFixture2.Derived
[0;31m[ FAILED ] [mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[0;31m[ FAILED ] [mPrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
5
0
FAILED TESTS
5
4
FAILED TESTS
[0;33m YOU HAVE 1 DISABLED TEST
[mNote: Google Test filter = FatalFailureTest.*:LoggingTest.*
[==========] Running 4 tests from 2 test
cas
es.
[==========] Running 4 tests from 2 test
suit
es.
[----------] Global test environment set-up.
[----------] 3 tests from FatalFailureTest
[ RUN ] FatalFailureTest.FatalFailureInSubroutine
...
...
@@ -1017,7 +1110,7 @@ Stack trace: (omitted)
[----------] 1 test from LoggingTest (? ms total)
[----------] Global test environment tear-down
[==========] 4 tests from 2 test
cas
es ran. (? ms total)
[==========] 4 tests from 2 test
suit
es ran. (? ms total)
[ PASSED ] 0 tests.
[ FAILED ] 4 tests, listed below:
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine
...
...
@@ -1027,21 +1120,21 @@ Stack trace: (omitted)
4 FAILED TESTS
Note: Google Test filter = *DISABLED_*
[==========] Running 1 test from 1 test
cas
e.
[==========] Running 1 test from 1 test
suit
e.
[----------] Global test environment set-up.
[----------] 1 test from DisabledTestsWarningTest
[ RUN ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
[ OK ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
[----------] Global test environment tear-down
[==========] 1 test from 1 test
cas
e ran.
[==========] 1 test from 1 test
suit
e ran.
[ PASSED ] 1 test.
Note: Google Test filter = PassingTest.*
Note: This is test shard 2 of 2.
[==========] Running 1 test from 1 test
cas
e.
[==========] Running 1 test from 1 test
suit
e.
[----------] Global test environment set-up.
[----------] 1 test from PassingTest
[ RUN ] PassingTest.PassingTest2
[ OK ] PassingTest.PassingTest2
[----------] Global test environment tear-down
[==========] 1 test from 1 test
cas
e ran.
[==========] 1 test from 1 test
suit
e ran.
[ PASSED ] 1 test.
googletest/test/googletest-output-test.py
View file @
85f059f0
...
...
@@ -55,7 +55,6 @@ NO_STACKTRACE_SUPPORT_FLAG = '--no_stacktrace_support'
IS_LINUX
=
os
.
name
==
'posix'
and
os
.
uname
()[
0
]
==
'Linux'
IS_WINDOWS
=
os
.
name
==
'nt'
# FIXME: remove the _lin suffix.
GOLDEN_NAME
=
'googletest-output-test-golden-lin.txt'
PROGRAM_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'googletest-output-test_'
)
...
...
googletest/test/googletest-output-test_.cc
View file @
85f059f0
...
...
@@ -92,9 +92,17 @@ 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_CASE_P
(
PrintingFailingParams
,
FailingParamTest
,
testing
::
Values
(
2
));
INSTANTIATE_TEST_SUITE_P
(
PrintingFailingParams
,
FailingParamTest
,
testing
::
Values
(
2
));
// Tests that an empty value for the test suite basename yields just
// the test name without any prior /
class
EmptyBasenameParamInst
:
public
testing
::
TestWithParam
<
int
>
{};
TEST_P
(
EmptyBasenameParamInst
,
Passes
)
{
EXPECT_EQ
(
1
,
GetParam
());
}
INSTANTIATE_TEST_SUITE_P
(,
EmptyBasenameParamInst
,
testing
::
Values
(
1
));
static
const
char
kGoldenString
[]
=
"
\"
Line
\0
1
\"\n
Line 2"
;
...
...
@@ -461,7 +469,11 @@ TEST_F(FatalFailureInSetUpTest, FailureInSetUp) {
}
TEST
(
AddFailureAtTest
,
MessageContainsSpecifiedFileAndLineNumber
)
{
ADD_FAILURE_AT
(
"foo.cc"
,
42
)
<<
"Expected failure in foo.cc"
;
ADD_FAILURE_AT
(
"foo.cc"
,
42
)
<<
"Expected nonfatal failure in foo.cc"
;
}
TEST
(
GtestFailAtTest
,
MessageContainsSpecifiedFileAndLineNumber
)
{
GTEST_FAIL_AT
(
"foo.cc"
,
42
)
<<
"Expected fatal failure in foo.cc"
;
}
#if GTEST_IS_THREADSAFE
...
...
@@ -521,48 +533,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 +785,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 +797,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
());
...
...
@@ -804,14 +816,14 @@ class TypedTestNames {
public:
template
<
typename
T
>
static
std
::
string
GetName
(
int
i
)
{
if
(
testing
::
internal
::
IsS
ame
<
T
,
char
>::
value
)
if
(
std
::
is_s
ame
<
T
,
char
>::
value
)
return
std
::
string
(
"char"
)
+
::
testing
::
PrintToString
(
i
);
if
(
testing
::
internal
::
IsS
ame
<
T
,
int
>::
value
)
if
(
std
::
is_s
ame
<
T
,
int
>::
value
)
return
std
::
string
(
"int"
)
+
::
testing
::
PrintToString
(
i
);
}
};
TYPED_TEST_
CAS
E
(
TypedTestWithNames
,
TypesForTestWithNames
,
TypedTestNames
);
TYPED_TEST_
SUIT
E
(
TypedTestWithNames
,
TypesForTestWithNames
,
TypedTestNames
);
TYPED_TEST
(
TypedTestWithNames
,
Success
)
{}
...
...
@@ -826,7 +838,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,25 +848,25 @@ 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:
template
<
typename
T
>
static
std
::
string
GetName
(
int
i
)
{
if
(
testing
::
internal
::
IsS
ame
<
T
,
unsigned
char
>::
value
)
{
if
(
std
::
is_s
ame
<
T
,
unsigned
char
>::
value
)
{
return
std
::
string
(
"unsignedChar"
)
+
::
testing
::
PrintToString
(
i
);
}
if
(
testing
::
internal
::
IsS
ame
<
T
,
unsigned
int
>::
value
)
{
if
(
std
::
is_s
ame
<
T
,
unsigned
int
>::
value
)
{
return
std
::
string
(
"unsignedInt"
)
+
::
testing
::
PrintToString
(
i
);
}
}
};
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 +889,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 +906,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
...
...
@@ -1024,6 +1036,56 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailureOnAllThreads) {
"Some other non-fatal failure."
);
}
class
DynamicFixture
:
public
testing
::
Test
{
protected:
DynamicFixture
()
{
printf
(
"DynamicFixture()
\n
"
);
}
~
DynamicFixture
()
override
{
printf
(
"~DynamicFixture()
\n
"
);
}
void
SetUp
()
override
{
printf
(
"DynamicFixture::SetUp
\n
"
);
}
void
TearDown
()
override
{
printf
(
"DynamicFixture::TearDown
\n
"
);
}
static
void
SetUpTestSuite
()
{
printf
(
"DynamicFixture::SetUpTestSuite
\n
"
);
}
static
void
TearDownTestSuite
()
{
printf
(
"DynamicFixture::TearDownTestSuite
\n
"
);
}
};
template
<
bool
Pass
>
class
DynamicTest
:
public
DynamicFixture
{
public:
void
TestBody
()
override
{
EXPECT_TRUE
(
Pass
);
}
};
auto
dynamic_test
=
(
// Register two tests with the same fixture correctly.
testing
::
RegisterTest
(
"DynamicFixture"
,
"DynamicTestPass"
,
nullptr
,
nullptr
,
__FILE__
,
__LINE__
,
[]()
->
DynamicFixture
*
{
return
new
DynamicTest
<
true
>
;
}),
testing
::
RegisterTest
(
"DynamicFixture"
,
"DynamicTestFail"
,
nullptr
,
nullptr
,
__FILE__
,
__LINE__
,
[]()
->
DynamicFixture
*
{
return
new
DynamicTest
<
false
>
;
}),
// Register the same fixture with another name. That's fine.
testing
::
RegisterTest
(
"DynamicFixtureAnotherName"
,
"DynamicTestPass"
,
nullptr
,
nullptr
,
__FILE__
,
__LINE__
,
[]()
->
DynamicFixture
*
{
return
new
DynamicTest
<
true
>
;
}),
// Register two tests with the same fixture incorrectly.
testing
::
RegisterTest
(
"BadDynamicFixture1"
,
"FixtureBase"
,
nullptr
,
nullptr
,
__FILE__
,
__LINE__
,
[]()
->
DynamicFixture
*
{
return
new
DynamicTest
<
true
>
;
}),
testing
::
RegisterTest
(
"BadDynamicFixture1"
,
"TestBase"
,
nullptr
,
nullptr
,
__FILE__
,
__LINE__
,
[]()
->
testing
::
Test
*
{
return
new
DynamicTest
<
true
>
;
}),
// Register two tests with the same fixture incorrectly by ommiting the
// return type.
testing
::
RegisterTest
(
"BadDynamicFixture2"
,
"FixtureBase"
,
nullptr
,
nullptr
,
__FILE__
,
__LINE__
,
[]()
->
DynamicFixture
*
{
return
new
DynamicTest
<
true
>
;
}),
testing
::
RegisterTest
(
"BadDynamicFixture2"
,
"Derived"
,
nullptr
,
nullptr
,
__FILE__
,
__LINE__
,
[]()
{
return
new
DynamicTest
<
true
>
;
}));
// Two test environments for testing testing::AddGlobalTestEnvironment().
...
...
googletest/test/googletest-param-test-invalid-name1-test_.cc
View file @
85f059f0
...
...
@@ -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 @
85f059f0
...
...
@@ -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 @
85f059f0
...
...
@@ -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,38 +849,40 @@ 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
);
INSTANTIATE_TEST_SUITE_P
(
CustomParamNameFunctionP
,
CustomFunctionNamingTest
,
Values
(
std
::
string
(
"FunctionNameP"
)),
&
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
()));
}
}
EXPECT_EQ
(
1u
,
test_names
.
count
(
"CustomTestNames/FunctorName"
));
EXPECT_EQ
(
1u
,
test_names
.
count
(
"CustomTestNames/FunctionName"
));
EXPECT_EQ
(
1u
,
test_names
.
count
(
"CustomTestNames/FunctionNameP"
));
EXPECT_EQ
(
1u
,
test_names
.
count
(
"CustomTestNames/LambdaName"
));
}
...
...
@@ -902,10 +898,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 +923,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 +954,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
...
...
@@ -973,6 +964,8 @@ INSTANTIATE_TEST_CASE_P(StatefulNamingFunctor,
class
Unstreamable
{
public:
explicit
Unstreamable
(
int
value
)
:
value_
(
value
)
{}
// -Wunused-private-field: dummy accessor for `value_`.
const
int
&
dummy_value
()
const
{
return
value_
;
}
private:
int
value_
;
...
...
@@ -987,9 +980,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 +1021,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 +1034,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 @
85f059f0
...
...
@@ -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 @
85f059f0
...
...
@@ -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 @
85f059f0
...
...
@@ -286,7 +286,9 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
EXPECT_EQ
(
"unknown file"
,
FormatCompilerIndependentFileLocation
(
nullptr
,
-
1
));
}
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA || \
GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
GTEST_OS_NETBSD || GTEST_OS_OPENBSD
void
*
ThreadFunc
(
void
*
data
)
{
internal
::
Mutex
*
mutex
=
static_cast
<
internal
::
Mutex
*>
(
data
);
mutex
->
Lock
();
...
...
@@ -386,14 +388,9 @@ class RETest : public ::testing::Test {};
// Defines StringTypes as the list of all string types that class RE
// supports.
typedef
testing
::
Types
<
::
std
::
string
,
# if GTEST_HAS_GLOBAL_STRING
::
string
,
# endif // GTEST_HAS_GLOBAL_STRING
const
char
*>
StringTypes
;
typedef
testing
::
Types
<
::
std
::
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
)
{
...
...
@@ -1051,7 +1048,7 @@ class AtomicCounterWithMutex {
pthread_mutex_init
(
&
memory_barrier_mutex
,
nullptr
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_lock
(
&
memory_barrier_mutex
));
SleepMilliseconds
(
random_
.
Generate
(
30
));
SleepMilliseconds
(
static_cast
<
int
>
(
random_
.
Generate
(
30
))
)
;
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_unlock
(
&
memory_barrier_mutex
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_destroy
(
&
memory_barrier_mutex
));
...
...
@@ -1059,7 +1056,7 @@ class AtomicCounterWithMutex {
// On Windows, performing an interlocked access puts up a memory barrier.
volatile
LONG
dummy
=
0
;
::
InterlockedIncrement
(
&
dummy
);
SleepMilliseconds
(
random_
.
Generate
(
30
));
SleepMilliseconds
(
static_cast
<
int
>
(
random_
.
Generate
(
30
))
)
;
::
InterlockedIncrement
(
&
dummy
);
#else
# error "Memory barrier not implemented on this platform."
...
...
Prev
1
…
5
6
7
8
9
10
11
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