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
21e51855
Unverified
Commit
21e51855
authored
Aug 16, 2018
by
Gennadiy Civil
Committed by
GitHub
Aug 16, 2018
Browse files
Merge branch 'master' into josh/fix_scoped_class2
parents
3e2cb754
490554aa
Changes
240
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
935 additions
and
331 deletions
+935
-331
googletest/test/googletest-options-test.cc
googletest/test/googletest-options-test.cc
+9
-13
googletest/test/googletest-output-test-golden-lin.txt
googletest/test/googletest-output-test-golden-lin.txt
+337
-101
googletest/test/googletest-output-test.py
googletest/test/googletest-output-test.py
+29
-22
googletest/test/googletest-output-test_.cc
googletest/test/googletest-output-test_.cc
+18
-15
googletest/test/googletest-param-test-invalid-name1-test.py
googletest/test/googletest-param-test-invalid-name1-test.py
+63
-0
googletest/test/googletest-param-test-invalid-name1-test_.cc
googletest/test/googletest-param-test-invalid-name1-test_.cc
+50
-0
googletest/test/googletest-param-test-invalid-name2-test.py
googletest/test/googletest-param-test-invalid-name2-test.py
+62
-0
googletest/test/googletest-param-test-invalid-name2-test_.cc
googletest/test/googletest-param-test-invalid-name2-test_.cc
+55
-0
googletest/test/googletest-param-test-test.cc
googletest/test/googletest-param-test-test.cc
+83
-29
googletest/test/googletest-param-test-test.h
googletest/test/googletest-param-test-test.h
+1
-7
googletest/test/googletest-param-test2-test.cc
googletest/test/googletest-param-test2-test.cc
+9
-13
googletest/test/googletest-port-test.cc
googletest/test/googletest-port-test.cc
+8
-19
googletest/test/googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+135
-87
googletest/test/googletest-shuffle-test.py
googletest/test/googletest-shuffle-test.py
+3
-5
googletest/test/googletest-shuffle-test_.cc
googletest/test/googletest-shuffle-test_.cc
+1
-2
googletest/test/googletest-test-part-test.cc
googletest/test/googletest-test-part-test.cc
+1
-4
googletest/test/googletest-test2_test.cc
googletest/test/googletest-test2_test.cc
+61
-0
googletest/test/googletest-throw-on-failure-test.py
googletest/test/googletest-throw-on-failure-test.py
+7
-9
googletest/test/googletest-throw-on-failure-test_.cc
googletest/test/googletest-throw-on-failure-test_.cc
+2
-3
googletest/test/googletest-tuple-test.cc
googletest/test/googletest-tuple-test.cc
+1
-2
No files found.
googletest/test/gtest-options
_
test.cc
→
googletest/test/g
oogle
test-options
-
test.cc
View file @
21e51855
...
...
@@ -27,8 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: keith.ray@gmail.com (Keith Ray)
//
// Google Test UnitTestOptions tests
//
// This file tests classes and functions used internally by
...
...
@@ -46,14 +44,7 @@
# include <direct.h>
#endif // GTEST_OS_WINDOWS_MOBILE
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
namespace
internal
{
...
...
@@ -107,15 +98,16 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
const
std
::
string
exe_str
=
GetCurrentExecutableName
().
string
();
#if GTEST_OS_WINDOWS
const
bool
success
=
_strcmpi
(
"gtest-options
_
test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"g
oogle
test-options
-
test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest-options-ex_test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest_all_test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest_dll_test"
,
exe_str
.
c_str
())
==
0
;
#elif GTEST_OS_FUCHSIA
const
bool
success
=
exe_str
==
"app"
;
#else
// TODO(wan@google.com): remove the hard-coded "lt-" prefix when
// Chandler Carruth's libtool replacement is ready.
// FIXME: remove the hard-coded "lt-" prefix when libtool replacement is ready
const
bool
success
=
exe_str
==
"gtest-options
_
test"
||
exe_str
==
"g
oogle
test-options
-
test"
||
exe_str
==
"gtest_all_test"
||
exe_str
==
"lt-gtest_all_test"
||
exe_str
==
"gtest_dll_test"
;
...
...
@@ -124,6 +116,8 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
FAIL
()
<<
"GetCurrentExecutableName() returns "
<<
exe_str
;
}
#if !GTEST_OS_FUCHSIA
class
XmlOutputChangeDirTest
:
public
Test
{
protected:
virtual
void
SetUp
()
{
...
...
@@ -210,6 +204,8 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
#endif
}
#endif // !GTEST_OS_FUCHSIA
}
// namespace
}
// namespace internal
}
// namespace testing
googletest/test/gtest
_
output
_
test
_
golden
_
lin.txt
→
googletest/test/g
oogle
test
-
output
-
test
-
golden
-
lin.txt
View file @
21e51855
The non-test part of the code is expected to have 2 failures.
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Value of: false
Actual: false
Expected: true
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Expected equality of these values:
2
3
[0;32m[==========] [mRunning 66 tests from 29 test cases.
Stack trace: (omitted)
[0;32m[==========] [mRunning 68 tests from 30 test cases.
[0;32m[----------] [mGlobal test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
...
...
@@ -34,21 +38,25 @@ BarEnvironment::SetUp() called.
[0;32m[ OK ] [mPassingTest.PassingTest2
[0;32m[----------] [m2 tests from NonfatalFailureTest
[0;32m[ RUN ] [mNonfatalFailureTest.EscapesStringOperands
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
kGoldenString
Which is: "\"Line"
actual
Which is: "actual \"string\""
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Expected equality of these values:
golden
Which is: "\"Line"
actual
Which is: "actual \"string\""
Stack trace: (omitted)
[0;31m[ FAILED ] [mNonfatalFailureTest.EscapesStringOperands
[0;32m[ RUN ] [mNonfatalFailureTest.DiffForLongStrings
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
golden_str
Which is: "\"Line\0 1\"\nLine 2"
...
...
@@ -58,223 +66,323 @@ With diff:
-\"Line\0 1\"
Line 2
Stack trace: (omitted)
[0;31m[ FAILED ] [mNonfatalFailureTest.DiffForLongStrings
[0;32m[----------] [m3 tests from FatalFailureTest
[0;32m[ RUN ] [mFatalFailureTest.FatalFailureInSubroutine
(expecting a failure that x should be 1)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1
x
Which is: 2
Stack trace: (omitted)
[0;31m[ FAILED ] [mFatalFailureTest.FatalFailureInSubroutine
[0;32m[ RUN ] [mFatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1
x
Which is: 2
Stack trace: (omitted)
[0;31m[ FAILED ] [mFatalFailureTest.FatalFailureInNestedSubroutine
[0;32m[ RUN ] [mFatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Value of: false
Actual: false
Expected: true
Stack trace: (omitted)
[0;31m[ FAILED ] [mFatalFailureTest.NonfatalFailureInSubroutine
[0;32m[----------] [m1 test from LoggingTest
[0;32m[ RUN ] [mLoggingTest.InterleavingLoggingAndAssertions
(expecting 2 failures on (3) >= (a[i]))
i == 0
i == 1
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 9
Stack trace: (omitted)
i == 2
i == 3
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 6
Stack trace: (omitted)
[0;31m[ FAILED ] [mLoggingTest.InterleavingLoggingAndAssertions
[0;32m[----------] [m6 tests from SCOPED_TRACETest
[0;32m[----------] [m7 tests from SCOPED_TRACETest
[0;32m[ RUN ] [mSCOPED_TRACETest.AcceptedValues
googletest-output-test_.cc:#: Failure
Failed
Just checking that all these values work fine.
Google Test trace:
googletest-output-test_.cc:#: (null)
googletest-output-test_.cc:#: 1337
googletest-output-test_.cc:#: std::string
googletest-output-test_.cc:#: literal string
Stack trace: (omitted)
[0;31m[ FAILED ] [mSCOPED_TRACETest.AcceptedValues
[0;32m[ RUN ] [mSCOPED_TRACETest.ObeysScopes
(expected to fail)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
This failure is expected, and shouldn't have a trace.
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
This failure is expected, and should have a trace.
Google Test trace:
gtest_output_test_.cc:#: Expected trace
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: Expected trace
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
This failure is expected, and shouldn't have a trace.
Stack trace: (omitted)
[0;31m[ FAILED ] [mSCOPED_TRACETest.ObeysScopes
[0;32m[ RUN ] [mSCOPED_TRACETest.WorksInLoop
(expected to fail)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
2
n
Which is: 1
Google Test trace:
gtest_output_test_.cc:#: i = 1
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: i = 1
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Expected equality of these values:
1
n
Which is: 2
Google Test trace:
gtest_output_test_.cc:#: i = 2
googletest-output-test_.cc:#: i = 2
Stack trace: (omitted)
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksInLoop
[0;32m[ RUN ] [mSCOPED_TRACETest.WorksInSubroutine
(expected to fail)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
2
n
Which is: 1
Google Test trace:
gtest_output_test_.cc:#: n = 1
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: n = 1
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Expected equality of these values:
1
n
Which is: 2
Google Test trace:
gtest_output_test_.cc:#: n = 2
googletest-output-test_.cc:#: n = 2
Stack trace: (omitted)
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksInSubroutine
[0;32m[ RUN ] [mSCOPED_TRACETest.CanBeNested
(expected to fail)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1
n
Which is: 2
Google Test trace:
gtest_output_test_.cc:#: n = 2
gtest_output_test_.cc:#:
googletest-output-test_.cc:#: n = 2
googletest-output-test_.cc:#:
Stack trace: (omitted)
[0;31m[ FAILED ] [mSCOPED_TRACETest.CanBeNested
[0;32m[ RUN ] [mSCOPED_TRACETest.CanBeRepeated
(expected to fail)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
This failure is expected, and should contain trace point A.
Google Test trace:
gtest_output_test_.cc:#: A
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: A
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
This failure is expected, and should contain trace point A and B.
Google Test trace:
gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: B
googletest-output-test_.cc:#: A
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
This failure is expected, and should contain trace point A, B, and C.
Google Test trace:
gtest_output_test_.cc:#: C
gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: C
googletest-output-test_.cc:#: B
googletest-output-test_.cc:#: A
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
This failure is expected, and should contain trace point A, B, and D.
Google Test trace:
gtest_output_test_.cc:#: D
gtest_output_test_.cc:#: B
gtest_output_test_.cc:#: A
googletest-output-test_.cc:#: D
googletest-output-test_.cc:#: B
googletest-output-test_.cc:#: A
Stack trace: (omitted)
[0;31m[ FAILED ] [mSCOPED_TRACETest.CanBeRepeated
[0;32m[ RUN ] [mSCOPED_TRACETest.WorksConcurrently
(expecting 6 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected failure #1 (in thread B, only trace B alive).
Google Test trace:
gtest_output_test_.cc:#: Trace B
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: Trace B
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #2 (in thread A, trace A & B both alive).
Google Test trace:
gtest_output_test_.cc:#: Trace A
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: Trace A
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #3 (in thread B, trace A & B both alive).
Google Test trace:
gtest_output_test_.cc:#: Trace B
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: Trace B
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #4 (in thread B, only trace A alive).
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #5 (in thread A, only trace A alive).
Google Test trace:
gtest_output_test_.cc:#: Trace A
gtest_output_test_.cc:#: Failure
googletest-output-test_.cc:#: Trace A
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #6 (in thread A, no trace alive).
Stack trace: (omitted)
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksConcurrently
[0;32m[----------] [m1 test from ScopedTraceTest
[0;32m[ RUN ] [mScopedTraceTest.WithExplicitFileAndLine
googletest-output-test_.cc:#: Failure
Failed
Check that the trace is attached to a particular location.
Google Test trace:
explicit_file.cc:123: expected trace message
Stack trace: (omitted)
[0;31m[ FAILED ] [mScopedTraceTest.WithExplicitFileAndLine
[0;32m[----------] [m1 test from NonFatalFailureInFixtureConstructorTest
[0;32m[ RUN ] [mNonFatalFailureInFixtureConstructorTest.FailureInConstructor
(expecting 5 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected failure #1, in the test fixture c'tor.
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #2, in SetUp().
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #3, in the test body.
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #4, in TearDown.
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #5, in the test fixture d'tor.
Stack trace: (omitted)
[0;31m[ FAILED ] [mNonFatalFailureInFixtureConstructorTest.FailureInConstructor
[0;32m[----------] [m1 test from FatalFailureInFixtureConstructorTest
[0;32m[ RUN ] [mFatalFailureInFixtureConstructorTest.FailureInConstructor
(expecting 2 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected failure #1, in the test fixture c'tor.
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #2, in the test fixture d'tor.
Stack trace: (omitted)
[0;31m[ FAILED ] [mFatalFailureInFixtureConstructorTest.FailureInConstructor
[0;32m[----------] [m1 test from NonFatalFailureInSetUpTest
[0;32m[ RUN ] [mNonFatalFailureInSetUpTest.FailureInSetUp
(expecting 4 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected failure #1, in SetUp().
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #2, in the test function.
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #3, in TearDown().
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #4, in the test fixture d'tor.
Stack trace: (omitted)
[0;31m[ FAILED ] [mNonFatalFailureInSetUpTest.FailureInSetUp
[0;32m[----------] [m1 test from FatalFailureInSetUpTest
[0;32m[ RUN ] [mFatalFailureInSetUpTest.FailureInSetUp
(expecting 3 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected failure #1, in SetUp().
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #2, in TearDown().
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected failure #3, in the test fixture d'tor.
Stack trace: (omitted)
[0;31m[ FAILED ] [mFatalFailureInSetUpTest.FailureInSetUp
[0;32m[----------] [m1 test from AddFailureAtTest
[0;32m[ RUN ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
foo.cc:42: Failure
Failed
Expected failure in foo.cc
Stack trace: (omitted)
[0;31m[ FAILED ] [mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[0;32m[----------] [m4 tests from MixedUpTestCaseTest
[0;32m[ RUN ] [mMixedUpTestCaseTest.FirstTestFromNamespaceFoo
...
...
@@ -291,6 +399,8 @@ 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 cases.
Stack trace: (omitted)
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFail
[0;32m[ RUN ] [mMixedUpTestCaseTest.ThisShouldFailToo
gtest.cc:#: Failure
...
...
@@ -302,6 +412,8 @@ 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 cases.
Stack trace: (omitted)
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFailToo
[0;32m[----------] [m2 tests from MixedUpTestCaseWithSameTestNameTest
[0;32m[ RUN ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
...
...
@@ -316,6 +428,8 @@ 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 cases.
Stack trace: (omitted)
[0;31m[ FAILED ] [mMixedUpTestCaseWithSameTestNameTest.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
...
...
@@ -330,6 +444,8 @@ 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
case.
Stack trace: (omitted)
[0;31m[ FAILED ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
[0;32m[----------] [m2 tests from TEST_before_TEST_F_in_same_test_case
[0;32m[ RUN ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST
...
...
@@ -344,6 +460,8 @@ 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
case.
Stack trace: (omitted)
[0;31m[ FAILED ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
[0;32m[----------] [m8 tests from ExpectNonfatalFailureTest
[0;32m[ RUN ] [mExpectNonfatalFailureTest.CanReferenceGlobalVariables
...
...
@@ -357,19 +475,27 @@ case.
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure
[0;32m[ RUN ] [mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures
(expecting a failure)
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual: 2 failures
gtest
_
output
_
test_.cc:#: Non-fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Non-fatal failure:
Failed
Expected non-fatal failure 1.
Stack trace: (omitted)
gtest
_
output
_
test_.cc:#: Non-fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Non-fatal failure:
Failed
Expected non-fatal failure 2.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures
[0;32m[ RUN ] [mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure
...
...
@@ -377,9 +503,13 @@ Expected non-fatal failure 2.
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Fatal failure:
Failed
Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure
[0;32m[ RUN ] [mExpectNonfatalFailureTest.FailsWhenStatementReturns
...
...
@@ -387,12 +517,16 @@ Expected fatal failure.
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectNonfatalFailureTest.FailsWhenStatementReturns
[0;32m[ RUN ] [mExpectNonfatalFailureTest.FailsWhenStatementThrows
(expecting a failure)
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectNonfatalFailureTest.FailsWhenStatementThrows
[0;32m[----------] [m8 tests from ExpectFatalFailureTest
[0;32m[ RUN ] [mExpectFatalFailureTest.CanReferenceGlobalVariables
...
...
@@ -406,19 +540,27 @@ Expected: 1 non-fatal failure
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure
[0;32m[ RUN ] [mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures
(expecting a failure)
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual: 2 failures
gtest
_
output
_
test_.cc:#: Fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Fatal failure:
Failed
Expected fatal failure.
Stack trace: (omitted)
gtest_output_test_.cc:#: Fatal failure:
googletest-output-test_.cc:#: Fatal failure:
Failed
Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures
[0;32m[ RUN ] [mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure
...
...
@@ -426,9 +568,13 @@ Expected fatal failure.
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Non-fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Non-fatal failure:
Failed
Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure
[0;32m[ RUN ] [mExpectFatalFailureTest.FailsWhenStatementReturns
...
...
@@ -436,47 +582,57 @@ Expected non-fatal failure.
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFatalFailureTest.FailsWhenStatementReturns
[0;32m[ RUN ] [mExpectFatalFailureTest.FailsWhenStatementThrows
(expecting a failure)
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFatalFailureTest.FailsWhenStatementThrows
[0;32m[----------] [m2 tests from TypedTest/0, where TypeParam = int
[0;32m[ RUN ] [mTypedTest/0.Success
[0;32m[ OK ] [mTypedTest/0.Success
[0;32m[ RUN ] [mTypedTest/0.Failure
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1
TypeParam()
Which is: 0
Expected failure
Stack trace: (omitted)
[0;31m[ FAILED ] [mTypedTest/0.Failure, where TypeParam = int
[0;32m[----------] [m2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char
[0;32m[ RUN ] [mUnsigned/TypedTestP/0.Success
[0;32m[ OK ] [mUnsigned/TypedTestP/0.Success
[0;32m[ RUN ] [mUnsigned/TypedTestP/0.Failure
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1U
Which is: 1
TypeParam()
Which is: '\0'
Expected failure
Stack trace: (omitted)
[0;31m[ FAILED ] [mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
[0;32m[----------] [m2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int
[0;32m[ RUN ] [mUnsigned/TypedTestP/1.Success
[0;32m[ OK ] [mUnsigned/TypedTestP/1.Success
[0;32m[ RUN ] [mUnsigned/TypedTestP/1.Failure
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1U
Which is: 1
TypeParam()
Which is: 0
Expected failure
Stack trace: (omitted)
[0;31m[ FAILED ] [mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
[0;32m[----------] [m4 tests from ExpectFailureTest
[0;32m[ RUN ] [mExpectFailureTest.ExpectFatalFailure
...
...
@@ -484,24 +640,36 @@ Expected failure
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Success:
g
oogle
test
-
output
-
test_.cc:#: Success:
Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Non-fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Non-fatal failure:
Failed
Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 fatal failure containing "Some other fatal failure expected."
Actual:
gtest
_
output
_
test_.cc:#: Fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Fatal failure:
Failed
Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFailureTest.ExpectFatalFailure
[0;32m[ RUN ] [mExpectFailureTest.ExpectNonFatalFailure
...
...
@@ -509,24 +677,36 @@ Expected fatal failure.
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Success:
g
oogle
test
-
output
-
test_.cc:#: Success:
Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Fatal failure:
Failed
Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 non-fatal failure containing "Some other non-fatal failure."
Actual:
gtest
_
output
_
test_.cc:#: Non-fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Non-fatal failure:
Failed
Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFailureTest.ExpectNonFatalFailure
[0;32m[ RUN ] [mExpectFailureTest.ExpectFatalFailureOnAllThreads
...
...
@@ -534,24 +714,36 @@ Expected non-fatal failure.
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Success:
g
oogle
test
-
output
-
test_.cc:#: Success:
Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Non-fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Non-fatal failure:
Failed
Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 fatal failure containing "Some other fatal failure expected."
Actual:
gtest
_
output
_
test_.cc:#: Fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Fatal failure:
Failed
Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFailureTest.ExpectFatalFailureOnAllThreads
[0;32m[ RUN ] [mExpectFailureTest.ExpectNonFatalFailureOnAllThreads
...
...
@@ -559,98 +751,132 @@ Expected fatal failure.
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Success:
g
oogle
test
-
output
-
test_.cc:#: Success:
Succeeded
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual:
gtest
_
output
_
test_.cc:#: Fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Fatal failure:
Failed
Expected fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
(expecting 1 failure)
gtest.cc:#: Failure
Expected: 1 non-fatal failure containing "Some other non-fatal failure."
Actual:
gtest
_
output
_
test_.cc:#: Non-fatal failure:
g
oogle
test
-
output
-
test_.cc:#: Non-fatal failure:
Failed
Expected non-fatal failure.
Stack trace: (omitted)
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFailureTest.ExpectNonFatalFailureOnAllThreads
[0;32m[----------] [m2 tests from ExpectFailureWithThreadsTest
[0;32m[ RUN ] [mExpectFailureWithThreadsTest.ExpectFatalFailure
(expecting 2 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected fatal failure.
Stack trace: (omitted)
gtest.cc:#: Failure
Expected: 1 fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFailureWithThreadsTest.ExpectFatalFailure
[0;32m[ RUN ] [mExpectFailureWithThreadsTest.ExpectNonFatalFailure
(expecting 2 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected non-fatal failure.
Stack trace: (omitted)
gtest.cc:#: Failure
Expected: 1 non-fatal failure
Actual: 0 failures
Stack trace: (omitted)
[0;31m[ FAILED ] [mExpectFailureWithThreadsTest.ExpectNonFatalFailure
[0;32m[----------] [m1 test from ScopedFakeTestPartResultReporterTest
[0;32m[ RUN ] [mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
(expecting 2 failures)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected fatal failure.
gtest_output_test_.cc:#: Failure
Stack trace: (omitted)
googletest-output-test_.cc:#: Failure
Failed
Expected non-fatal failure.
Stack trace: (omitted)
[0;31m[ FAILED ] [mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[0;32m[----------] [m1 test from PrintingFailingParams/FailingParamTest
[0;32m[ RUN ] [mPrintingFailingParams/FailingParamTest.Fails/0
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1
GetParam()
Which is: 2
Stack trace: (omitted)
[0;31m[ FAILED ] [mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[0;32m[----------] [m2 tests from PrintingStrings/ParamTest
[0;32m[ RUN ] [mPrintingStrings/ParamTest.Success/a
[0;32m[ OK ] [mPrintingStrings/ParamTest.Success/a
[0;32m[ RUN ] [mPrintingStrings/ParamTest.Failure/a
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
"b"
GetParam()
Which is: "a"
Expected failure
Stack trace: (omitted)
[0;31m[ FAILED ] [mPrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
[0;32m[----------] [mGlobal test environment tear-down
BarEnvironment::TearDown() called.
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected non-fatal failure.
Stack trace: (omitted)
FooEnvironment::TearDown() called.
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Failed
Expected fatal failure.
[0;32m[==========] [m66 tests from 29 test cases ran.
Stack trace: (omitted)
[0;32m[==========] [m68 tests from 30 test cases ran.
[0;32m[ PASSED ] [m22 tests.
[0;31m[ FAILED ] [m4
4
tests, listed below:
[0;31m[ FAILED ] [m4
6
tests, listed below:
[0;31m[ FAILED ] [mNonfatalFailureTest.EscapesStringOperands
[0;31m[ FAILED ] [mNonfatalFailureTest.DiffForLongStrings
[0;31m[ FAILED ] [mFatalFailureTest.FatalFailureInSubroutine
[0;31m[ FAILED ] [mFatalFailureTest.FatalFailureInNestedSubroutine
[0;31m[ FAILED ] [mFatalFailureTest.NonfatalFailureInSubroutine
[0;31m[ FAILED ] [mLoggingTest.InterleavingLoggingAndAssertions
[0;31m[ FAILED ] [mSCOPED_TRACETest.AcceptedValues
[0;31m[ FAILED ] [mSCOPED_TRACETest.ObeysScopes
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksInLoop
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksInSubroutine
[0;31m[ FAILED ] [mSCOPED_TRACETest.CanBeNested
[0;31m[ FAILED ] [mSCOPED_TRACETest.CanBeRepeated
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksConcurrently
[0;31m[ FAILED ] [mScopedTraceTest.WithExplicitFileAndLine
[0;31m[ FAILED ] [mNonFatalFailureInFixtureConstructorTest.FailureInConstructor
[0;31m[ FAILED ] [mFatalFailureInFixtureConstructorTest.FailureInConstructor
[0;31m[ FAILED ] [mNonFatalFailureInSetUpTest.FailureInSetUp
...
...
@@ -684,7 +910,7 @@ Expected fatal failure.
[0;31m[ FAILED ] [mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[0;31m[ FAILED ] [mPrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
4
4
FAILED TESTS
4
6
FAILED TESTS
[0;33m YOU HAVE 1 DISABLED TEST
[mNote: Google Test filter = FatalFailureTest.*:LoggingTest.*
...
...
@@ -693,26 +919,32 @@ Expected fatal failure.
[----------] 3 tests from FatalFailureTest
[ RUN ] FatalFailureTest.FatalFailureInSubroutine
(expecting a failure that x should be 1)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1
x
Which is: 2
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine (? ms)
[ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected equality of these values:
1
x
Which is: 2
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms)
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false)
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Value of: false
Actual: false
Expected: true
Stack trace: (omitted)
[ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine (? ms)
[----------] 3 tests from FatalFailureTest (? ms total)
...
...
@@ -721,12 +953,16 @@ Expected: true
(expecting 2 failures on (3) >= (a[i]))
i == 0
i == 1
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 9
Stack trace: (omitted)
i == 2
i == 3
gtest
_
output
_
test_.cc:#: Failure
g
oogle
test
-
output
-
test_.cc:#: Failure
Expected: (3) >= (a[i]), actual: 3 vs 6
Stack trace: (omitted)
[ FAILED ] LoggingTest.InterleavingLoggingAndAssertions (? ms)
[----------] 1 test from LoggingTest (? ms total)
...
...
googletest/test/gtest
_
output
_
test.py
→
googletest/test/g
oogle
test
-
output
-
test.py
View file @
21e51855
...
...
@@ -29,17 +29,15 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests the text output of Google C++ Testing Framework.
"""Tests the text output of Google C++ Testing
and Mocking
Framework.
SYNOPSIS
g
test_output_test.py --build_dir=BUILD/DIR --gengolden
#
where BUILD/DIR contains the built gtest
_
output
_
test_ file.
g
test_output_test.py --gengolden
g
test_output_test.py
To update the golden file:
google
test_output_test.py --build_dir=BUILD/DIR --gengolden
where BUILD/DIR contains the built g
oogle
test
-
output
-
test_ file.
google
test_output_test.py --gengolden
google
test_output_test.py
"""
__author__
=
'wan@google.com (Zhanyong Wan)'
import
difflib
import
os
import
re
...
...
@@ -51,12 +49,16 @@ import gtest_test_utils
GENGOLDEN_FLAG
=
'--gengolden'
CATCH_EXCEPTIONS_ENV_VAR_NAME
=
'GTEST_CATCH_EXCEPTIONS'
# The flag indicating stacktraces are not supported
NO_STACKTRACE_SUPPORT_FLAG
=
'--no_stacktrace_support'
IS_LINUX
=
os
.
name
==
'posix'
and
os
.
uname
()[
0
]
==
'Linux'
IS_WINDOWS
=
os
.
name
==
'nt'
#
TODO(vladl@google.com)
: remove the _lin suffix.
GOLDEN_NAME
=
'gtest
_
output
_
test
_
golden
_
lin.txt'
#
FIXME
: remove the _lin suffix.
GOLDEN_NAME
=
'g
oogle
test
-
output
-
test
-
golden
-
lin.txt'
PROGRAM_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest
_
output
_
test_'
)
PROGRAM_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'g
oogle
test
-
output
-
test_'
)
# At least one command we exercise must not have the
# 'internal_skip_environment_and_ad_hoc_tests' argument.
...
...
@@ -99,7 +101,8 @@ def RemoveLocations(test_output):
'FILE_NAME:#: '.
"""
return
re
.
sub
(
r
'.*[/\\](.+)(\:\d+|\(\d+\))\: '
,
r
'\1:#: '
,
test_output
)
return
re
.
sub
(
r
'.*[/\\]((googletest-output-test_|gtest).cc)(\:\d+|\(\d+\))\: '
,
r
'\1:#: '
,
test_output
)
def
RemoveStackTraceDetails
(
output
):
...
...
@@ -189,7 +192,7 @@ def RemoveMatchingTests(test_output, pattern):
def
NormalizeOutput
(
output
):
"""Normalizes output (the output of gtest
_
output
_
test_.exe)."""
"""Normalizes output (the output of g
oogle
test
-
output
-
test_.exe)."""
output
=
ToUnixLineEnding
(
output
)
output
=
RemoveLocations
(
output
)
...
...
@@ -249,12 +252,12 @@ test_list = GetShellCommandOutput(COMMAND_LIST_TESTS)
SUPPORTS_DEATH_TESTS
=
'DeathTest'
in
test_list
SUPPORTS_TYPED_TESTS
=
'TypedTest'
in
test_list
SUPPORTS_THREADS
=
'ExpectFailureWithThreadsTest'
in
test_list
SUPPORTS_STACK_TRACES
=
False
SUPPORTS_STACK_TRACES
=
NO_STACKTRACE_SUPPORT_FLAG
not
in
sys
.
argv
CAN_GENERATE_GOLDEN_FILE
=
(
SUPPORTS_DEATH_TESTS
and
SUPPORTS_TYPED_TESTS
and
SUPPORTS_THREADS
and
not
IS_WINDOW
S
)
SUPPORTS_STACK_TRACE
S
)
class
GTestOutputTest
(
gtest_test_utils
.
TestCase
):
def
RemoveUnsupportedTests
(
self
,
test_output
):
...
...
@@ -279,7 +282,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
def
testOutput
(
self
):
output
=
GetOutputOfAllCommands
()
golden_file
=
open
(
GOLDEN_PATH
,
'r'
)
golden_file
=
open
(
GOLDEN_PATH
,
'r
b
'
)
# A mis-configured source control system can cause \r appear in EOL
# sequences when we read the golden file irrespective of an operating
# system used. Therefore, we need to strip those \r's from newlines
...
...
@@ -310,18 +313,22 @@ class GTestOutputTest(gtest_test_utils.TestCase):
if
os
.
getenv
(
'DEBUG_GTEST_OUTPUT_TEST'
):
open
(
os
.
path
.
join
(
gtest_test_utils
.
GetSourceDir
(),
'_gtest
_
output
_
test_normalized_actual.txt'
),
'wb'
).
write
(
'_g
oogle
test
-
output
-
test_normalized_actual.txt'
),
'wb'
).
write
(
normalized_actual
)
open
(
os
.
path
.
join
(
gtest_test_utils
.
GetSourceDir
(),
'_gtest
_
output
_
test_normalized_golden.txt'
),
'wb'
).
write
(
'_g
oogle
test
-
output
-
test_normalized_golden.txt'
),
'wb'
).
write
(
normalized_golden
)
self
.
assertEqual
(
normalized_golden
,
normalized_actual
)
if
__name__
==
'__main__'
:
if
sys
.
argv
[
1
:]
==
[
GENGOLDEN_FLAG
]:
if
NO_STACKTRACE_SUPPORT_FLAG
in
sys
.
argv
:
# unittest.main() can't handle unknown flags
sys
.
argv
.
remove
(
NO_STACKTRACE_SUPPORT_FLAG
)
if
GENGOLDEN_FLAG
in
sys
.
argv
:
if
CAN_GENERATE_GOLDEN_FILE
:
output
=
GetOutputOfAllCommands
()
golden_file
=
open
(
GOLDEN_PATH
,
'wb'
)
...
...
@@ -330,9 +337,9 @@ if __name__ == '__main__':
else
:
message
=
(
"""Unable to write a golden file when compiled in an environment
that does not support all the required features (death tests,
typed tests,
and multiple threads). Please generate the golden file using a binary built
with those features enabled
."""
)
that does not support all the required features (death tests,
typed tests, stack traces, and multiple threads).
Please build this test and generate the golden file using Blaze on Linux
."""
)
sys
.
stderr
.
write
(
message
)
sys
.
exit
(
1
)
...
...
googletest/test/gtest
_
output
_
test_.cc
→
googletest/test/g
oogle
test
-
output
-
test_.cc
View file @
21e51855
...
...
@@ -29,23 +29,13 @@
//
// The purpose of this file is to generate Google Test output under
// various conditions. The output will then be verified by
// gtest
_
output
_
test.py to ensure that Google Test generates the
// g
oogle
test
-
output
-
test.py to ensure that Google Test generates the
// desired messages. Therefore, most tests in this file are MEANT TO
// FAIL.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#include <stdlib.h>
...
...
@@ -176,6 +166,16 @@ void SubWithTrace(int n) {
SubWithoutTrace
(
n
);
}
TEST
(
SCOPED_TRACETest
,
AcceptedValues
)
{
SCOPED_TRACE
(
"literal string"
);
SCOPED_TRACE
(
std
::
string
(
"std::string"
));
SCOPED_TRACE
(
1337
);
// streamable type
const
char
*
null_value
=
NULL
;
SCOPED_TRACE
(
null_value
);
ADD_FAILURE
()
<<
"Just checking that all these values work fine."
;
}
// Tests that SCOPED_TRACE() obeys lexical scopes.
TEST
(
SCOPED_TRACETest
,
ObeysScopes
)
{
printf
(
"(expected to fail)
\n
"
);
...
...
@@ -323,6 +323,13 @@ TEST(SCOPED_TRACETest, WorksConcurrently) {
}
#endif // GTEST_IS_THREADSAFE
// Tests basic functionality of the ScopedTrace utility (most of its features
// are already tested in SCOPED_TRACETest).
TEST
(
ScopedTraceTest
,
WithExplicitFileAndLine
)
{
testing
::
ScopedTrace
trace
(
"explicit_file.cc"
,
123
,
"expected trace message"
);
ADD_FAILURE
()
<<
"Check that the trace is attached to a particular location."
;
}
TEST
(
DisabledTestsWarningTest
,
DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
)
{
// This test body is intentionally empty. Its sole purpose is for
...
...
@@ -757,8 +764,6 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) {
// This #ifdef block tests the output of value-parameterized tests.
#if GTEST_HAS_PARAM_TEST
std
::
string
ParamNameFunc
(
const
testing
::
TestParamInfo
<
std
::
string
>&
info
)
{
return
info
.
param
;
}
...
...
@@ -779,8 +784,6 @@ INSTANTIATE_TEST_CASE_P(PrintingStrings,
testing
::
Values
(
std
::
string
(
"a"
)),
ParamNameFunc
);
#endif // GTEST_HAS_PARAM_TEST
// This #ifdef block tests the output of typed tests.
#if GTEST_HAS_TYPED_TEST
...
...
googletest/test/googletest-param-test-invalid-name1-test.py
0 → 100644
View file @
21e51855
#!/usr/bin/env python
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Verifies that Google Test warns the user when not initialized properly."""
import
gtest_test_utils
binary_name
=
'googletest-param-test-invalid-name1-test_'
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
binary_name
)
def
Assert
(
condition
):
if
not
condition
:
raise
AssertionError
def
TestExitCodeAndOutput
(
command
):
"""Runs the given command and verifies its exit code and output."""
err
=
(
'Parameterized test name
\'
"InvalidWithQuotes"
\'
is invalid'
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
Assert
(
p
.
terminated_by_signal
)
# Verify the output message contains appropriate output
Assert
(
err
in
p
.
output
)
class
GTestParamTestInvalidName1Test
(
gtest_test_utils
.
TestCase
):
def
testExitCodeAndOutput
(
self
):
TestExitCodeAndOutput
(
COMMAND
)
if
__name__
==
'__main__'
:
gtest_test_utils
.
Main
()
googletest/test/googletest-param-test-invalid-name1-test_.cc
0 → 100644
View file @
21e51855
// Copyright 2015, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/gtest.h"
namespace
{
class
DummyTest
:
public
::
testing
::
TestWithParam
<
const
char
*>
{};
TEST_P
(
DummyTest
,
Dummy
)
{
}
INSTANTIATE_TEST_CASE_P
(
InvalidTestName
,
DummyTest
,
::
testing
::
Values
(
"InvalidWithQuotes"
),
::
testing
::
PrintToStringParamName
());
}
// namespace
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
googletest/test/googletest-param-test-invalid-name2-test.py
0 → 100644
View file @
21e51855
#!/usr/bin/env python
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Verifies that Google Test warns the user when not initialized properly."""
import
gtest_test_utils
binary_name
=
'googletest-param-test-invalid-name2-test_'
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
binary_name
)
def
Assert
(
condition
):
if
not
condition
:
raise
AssertionError
def
TestExitCodeAndOutput
(
command
):
"""Runs the given command and verifies its exit code and output."""
err
=
(
'Duplicate parameterized test name
\'
a
\'
'
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
Assert
(
p
.
terminated_by_signal
)
# Check for appropriate output
Assert
(
err
in
p
.
output
)
class
GTestParamTestInvalidName2Test
(
gtest_test_utils
.
TestCase
):
def
testExitCodeAndOutput
(
self
):
TestExitCodeAndOutput
(
COMMAND
)
if
__name__
==
'__main__'
:
gtest_test_utils
.
Main
()
googletest/test/googletest-param-test-invalid-name2-test_.cc
0 → 100644
View file @
21e51855
// Copyright 2015, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/gtest.h"
namespace
{
class
DummyTest
:
public
::
testing
::
TestWithParam
<
const
char
*>
{};
std
::
string
StringParamTestSuffix
(
const
testing
::
TestParamInfo
<
const
char
*>&
info
)
{
return
std
::
string
(
info
.
param
);
}
TEST_P
(
DummyTest
,
Dummy
)
{
}
INSTANTIATE_TEST_CASE_P
(
DuplicateTestNames
,
DummyTest
,
::
testing
::
Values
(
"a"
,
"b"
,
"a"
,
"c"
),
StringParamTestSuffix
);
}
// namespace
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
googletest/test/gtest-param-test
_
test.cc
→
googletest/test/g
oogle
test-param-test
-
test.cc
View file @
21e51855
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// Tests for Google Test itself. This file verifies that the parameter
// generators objects produce correct parameter sequences and that
...
...
@@ -35,8 +34,6 @@
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
# include <algorithm>
# include <iostream>
# include <list>
...
...
@@ -44,12 +41,8 @@
# include <string>
# include <vector>
// To include gtest-internal-inl.h.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h" // for UnitTestOptions
# undef GTEST_IMPLEMENTATION_
# include "test/gtest-param-test_test.h"
# include "test/googletest-param-test-test.h"
using
::
std
::
vector
;
using
::
std
::
sort
;
...
...
@@ -74,7 +67,7 @@ using ::testing::internal::UnitTestOptions;
// Prints a value to a string.
//
//
TODO(wan@google.com)
: remove PrintValue() when we move matchers and
//
FIXME
: remove PrintValue() when we move matchers and
// EXPECT_THAT() from Google Mock to Google Test. At that time, we
// can write EXPECT_THAT(x, Eq(y)) to compare two tuples x and y, as
// EXPECT_THAT() and the matchers know how to print tuples.
...
...
@@ -542,6 +535,51 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
VerifyGenerator
(
gen
,
expected_values
);
}
#if GTEST_LANG_CXX11
class
NonDefaultConstructAssignString
{
public:
NonDefaultConstructAssignString
(
const
std
::
string
&
s
)
:
str_
(
s
)
{}
const
std
::
string
&
str
()
const
{
return
str_
;
}
private:
std
::
string
str_
;
// Not default constructible
NonDefaultConstructAssignString
();
// Not assignable
void
operator
=
(
const
NonDefaultConstructAssignString
&
);
};
TEST
(
CombineTest
,
NonDefaultConstructAssign
)
{
const
ParamGenerator
<
tuple
<
int
,
NonDefaultConstructAssignString
>
>
gen
=
Combine
(
Values
(
0
,
1
),
Values
(
NonDefaultConstructAssignString
(
"A"
),
NonDefaultConstructAssignString
(
"B"
)));
ParamGenerator
<
tuple
<
int
,
NonDefaultConstructAssignString
>
>::
iterator
it
=
gen
.
begin
();
EXPECT_EQ
(
0
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"A"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_EQ
(
0
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"B"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_EQ
(
1
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"A"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_EQ
(
1
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"B"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_TRUE
(
it
==
gen
.
end
());
}
#endif // GTEST_LANG_CXX11
# endif // GTEST_HAS_COMBINE
// Tests that an generator produces correct sequence after being
...
...
@@ -809,6 +847,34 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
INSTANTIATE_TEST_CASE_P
(
ZeroToFiveSequence
,
NamingTest
,
Range
(
0
,
5
));
// Tests that macros in test names are expanded correctly.
class
MacroNamingTest
:
public
TestWithParam
<
int
>
{};
#define PREFIX_WITH_FOO(test_name) Foo##test_name
#define PREFIX_WITH_MACRO(test_name) Macro##test_name
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_case_name
());
EXPECT_STREQ
(
"FooSomeTestName"
,
test_info
->
name
());
}
INSTANTIATE_TEST_CASE_P
(
FortyTwo
,
MacroNamingTest
,
Values
(
42
));
// Tests the same thing for non-parametrized tests.
class
MacroNamingTestNonParametrized
:
public
::
testing
::
Test
{};
TEST_F
(
PREFIX_WITH_MACRO
(
NamingTestNonParametrized
),
PREFIX_WITH_FOO
(
SomeTestName
))
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_STREQ
(
"MacroNamingTestNonParametrized"
,
test_info
->
test_case_name
());
EXPECT_STREQ
(
"FooSomeTestName"
,
test_info
->
name
());
}
// Tests that user supplied custom parameter names are working correctly.
// Runs the test with a builtin helper method which uses PrintToString,
// as well as a custom function and custom functor to ensure all possible
...
...
@@ -817,8 +883,8 @@ class CustomFunctorNamingTest : public TestWithParam<std::string> {};
TEST_P
(
CustomFunctorNamingTest
,
CustomTestNames
)
{}
struct
CustomParamNameFunctor
{
std
::
string
operator
()(
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
o
)
{
return
inf
o
.
param
;
std
::
string
operator
()(
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
}
};
...
...
@@ -835,8 +901,8 @@ INSTANTIATE_TEST_CASE_P(AllAllowedCharacters,
CustomParamNameFunctor
());
inline
std
::
string
CustomParamNameFunction
(
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
o
)
{
return
inf
o
.
param
;
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
}
class
CustomFunctionNamingTest
:
public
TestWithParam
<
std
::
string
>
{};
...
...
@@ -854,11 +920,10 @@ INSTANTIATE_TEST_CASE_P(CustomParamNameFunction,
class
CustomLambdaNamingTest
:
public
TestWithParam
<
std
::
string
>
{};
TEST_P
(
CustomLambdaNamingTest
,
CustomTestNames
)
{}
INSTANTIATE_TEST_CASE_P
(
CustomParamNameLambda
,
CustomLambdaNamingTest
,
INSTANTIATE_TEST_CASE_P
(
CustomParamNameLambda
,
CustomLambdaNamingTest
,
Values
(
std
::
string
(
"LambdaName"
)),
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
tp
inf
o
)
{
return
tp
inf
o
.
param
;
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
});
#endif // GTEST_LANG_CXX11
...
...
@@ -1025,31 +1090,20 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
INSTANTIATE_TEST_CASE_P
(
RangeZeroToFive
,
ParameterizedDerivedTest
,
Range
(
0
,
5
));
#endif // GTEST_HAS_PARAM_TEST
TEST
(
CompileTest
,
CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined
)
{
#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST
FAIL
()
<<
"GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not
\n
"
#endif
}
int
main
(
int
argc
,
char
**
argv
)
{
#if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case.
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
// Used in GeneratorEvaluationTest test case. Tests that the updated value
// will be picked up for instantiating tests in GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
1
);
#endif // GTEST_HAS_PARAM_TEST
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
#if GTEST_HAS_PARAM_TEST
// Used in GeneratorEvaluationTest test case. Tests that value updated
// here will NOT be used for instantiating tests in
// GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
2
);
#endif // GTEST_HAS_PARAM_TEST
return
RUN_ALL_TESTS
();
}
googletest/test/gtest-param-test
_
test.h
→
googletest/test/g
oogle
test-param-test
-
test.h
View file @
21e51855
...
...
@@ -27,9 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: vladl@google.com (Vlad Losev)
//
// The Google C++ Testing Framework (Google Test)
// The Google C++ Testing and Mocking Framework (Google Test)
//
// This header file provides classes and functions used internally
// for testing Google Test itself.
...
...
@@ -39,8 +37,6 @@
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test
// in separate translation units.
class
ExternalInstantiationTest
:
public
::
testing
::
TestWithParam
<
int
>
{
...
...
@@ -52,6 +48,4 @@ class InstantiationInMultipleTranslaionUnitsTest
:
public
::
testing
::
TestWithParam
<
int
>
{
};
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
googletest/test/gtest-param-test2
_
test.cc
→
googletest/test/g
oogle
test-param-test2
-
test.cc
View file @
21e51855
...
...
@@ -26,40 +26,36 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// Tests for Google Test itself. This verifies that the basic constructs of
// Google Test work.
#include "gtest/gtest.h"
#include "test/gtest-param-test_test.h"
#if GTEST_HAS_PARAM_TEST
#include "test/googletest-param-test-test.h"
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
// Tests that generators defined in a different translation unit
// are functional. The test using extern_gen is defined
// in gtest-param-test
_
test.cc.
// in g
oogle
test-param-test
-
test.cc.
ParamGenerator
<
int
>
extern_gen
=
Values
(
33
);
// Tests that a parameterized test case can be defined in one translation unit
// and instantiated in another. The test is defined in
gtest-param-test_test.cc
// and ExternalInstantiationTest fixture class is
defined in
// gtest-param-test_test.h.
// 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_CASE_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
// in gtest-param-test_test.cc and InstantiationInMultipleTranslaionUnitsTest
// fixture is defined in gtest-param-test_test.h
// in googletest-param-test-test.cc and
// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
// gtest-param-test_test.h
INSTANTIATE_TEST_CASE_P
(
Sequence2
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
#endif // GTEST_HAS_PARAM_TEST
googletest/test/gtest-port
_
test.cc
→
googletest/test/g
oogle
test-port
-
test.cc
View file @
21e51855
...
...
@@ -27,14 +27,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: vladl@google.com (Vlad Losev), wan@google.com (Zhanyong Wan)
//
// This file tests the internal cross-platform support utilities.
#include <stdio.h>
#include "gtest/internal/gtest-port.h"
#include <stdio.h>
#if GTEST_OS_MAC
# include <time.h>
#endif // GTEST_OS_MAC
...
...
@@ -45,15 +42,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
using
std
::
make_pair
;
using
std
::
pair
;
...
...
@@ -75,7 +64,7 @@ TEST(IsXDigitTest, WorksForNarrowAscii) {
}
TEST
(
IsXDigitTest
,
ReturnsFalseForNarrowNonAscii
)
{
EXPECT_FALSE
(
IsXDigit
(
'\x80'
));
EXPECT_FALSE
(
IsXDigit
(
static_cast
<
char
>
(
'\x80'
))
)
;
EXPECT_FALSE
(
IsXDigit
(
static_cast
<
char
>
(
'0'
|
'\x80'
)));
}
...
...
@@ -235,7 +224,7 @@ TEST(ScopedPtrTest, DefinesElementType) {
StaticAssertTypeEq
<
int
,
::
testing
::
internal
::
scoped_ptr
<
int
>::
element_type
>
();
}
//
TODO(vladl@google.com)
: Implement THE REST of scoped_ptr tests.
//
FIXME
: Implement THE REST of scoped_ptr tests.
TEST
(
GtestCheckSyntaxTest
,
BehavesLikeASingleStatement
)
{
if
(
AlwaysFalse
())
...
...
@@ -304,7 +293,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
EXPECT_EQ
(
"unknown file"
,
FormatCompilerIndependentFileLocation
(
NULL
,
-
1
));
}
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX
|| GTEST_OS_FUCHSIA
void
*
ThreadFunc
(
void
*
data
)
{
internal
::
Mutex
*
mutex
=
static_cast
<
internal
::
Mutex
*>
(
data
);
mutex
->
Lock
();
...
...
@@ -348,17 +337,17 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) {
TEST
(
GetThreadCountTest
,
ReturnsZeroWhenUnableToCountThreads
)
{
EXPECT_EQ
(
0U
,
GetThreadCount
());
}
#endif // GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX
#endif // GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX
|| GTEST_OS_FUCHSIA
TEST
(
GtestCheckDeathTest
,
DiesWithCorrectOutputOnFailure
)
{
const
bool
a_false_condition
=
false
;
const
char
regex
[]
=
#ifdef _MSC_VER
"gtest-port
_
test
\\
.cc
\\
(
\\
d+
\\
):"
"g
oogle
test-port
-
test
\\
.cc
\\
(
\\
d+
\\
):"
#elif GTEST_USES_POSIX_RE
"gtest-port
_
test
\\
.cc:[0-9]+"
"g
oogle
test-port
-
test
\\
.cc:[0-9]+"
#else
"gtest-port
_
test
\\
.cc:
\\
d+"
"g
oogle
test-port
-
test
\\
.cc:
\\
d+"
#endif // _MSC_VER
".*a_false_condition.*Extra info.*"
;
...
...
googletest/test/gtest-printers
_
test.cc
→
googletest/test/g
oogle
test-printers
-
test.cc
View file @
21e51855
...
...
@@ -26,15 +26,12 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Test - The Google C++ Testing Framework
// Google Test - The Google C++ Testing and Mocking Framework
//
// This file tests the universal value printer.
#include "gtest/gtest-printers.h"
#include <ctype.h>
#include <limits.h>
#include <string.h>
...
...
@@ -48,20 +45,16 @@
#include <utility>
#include <vector>
#include "gtest/gtest-printers.h"
#include "gtest/gtest.h"
// hash_map and hash_set are available under Visual C++, or on Linux.
#if GTEST_HAS_UNORDERED_MAP_
# include <unordered_map> // NOLINT
#elif GTEST_HAS_HASH_MAP_
# include <hash_map> // NOLINT
#endif // GTEST_HAS_HASH_MAP_
# include <unordered_map> // NOLINT
#endif // GTEST_HAS_UNORDERED_MAP_
#if GTEST_HAS_UNORDERED_SET_
# include <unordered_set> // NOLINT
#elif GTEST_HAS_HASH_SET_
# include <hash_set> // NOLINT
#endif // GTEST_HAS_HASH_SET_
# include <unordered_set> // NOLINT
#endif // GTEST_HAS_UNORDERED_SET_
#if GTEST_HAS_STD_FORWARD_LIST_
# include <forward_list> // NOLINT
...
...
@@ -192,25 +185,21 @@ inline ::std::ostream& operator<<(::std::ostream& os,
return
os
<<
"StreamableTemplateInFoo: "
<<
x
.
value
();
}
// A user-defined streamable but recursivly-defined container type in
// A user-defined streamable but recursivly-defined container type in
// a user namespace, it mimics therefore std::filesystem::path or
// boost::filesystem::path.
class
PathLike
{
public:
struct
iterator
{
struct
iterator
{
typedef
PathLike
value_type
;
};
typedef
iterator
const_iterator
;
PathLike
()
{}
iterator
begin
()
const
{
return
iterator
();
}
iterator
end
()
const
{
return
iterator
();
}
friend
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
os
,
const
PathLike
&
)
{
friend
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
os
,
const
PathLike
&
)
{
return
os
<<
"Streamable-PathLike"
;
}
};
...
...
@@ -241,50 +230,6 @@ using ::testing::internal::UniversalPrinter;
using
::
testing
::
internal
::
UniversalTersePrint
;
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
using
::
testing
::
internal
::
UniversalTersePrintTupleFieldsToStrings
;
#endif
using
::
testing
::
internal
::
string
;
// The hash_* classes are not part of the C++ standard. STLport
// defines them in namespace std. MSVC defines them in ::stdext. GCC
// defines them in ::.
#if GTEST_HAS_UNORDERED_MAP_
#define GTEST_HAS_HASH_MAP_ 1
template
<
class
Key
,
class
T
>
using
hash_map
=
::
std
::
unordered_map
<
Key
,
T
>
;
template
<
class
Key
,
class
T
>
using
hash_multimap
=
::
std
::
unordered_multimap
<
Key
,
T
>
;
#elif GTEST_HAS_HASH_MAP_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using
::
std
::
hash_map
;
using
::
std
::
hash_multimap
;
#elif _MSC_VER
using
::
stdext
::
hash_map
;
using
::
stdext
::
hash_multimap
;
#endif
#endif
#if GTEST_HAS_UNORDERED_SET_
#define GTEST_HAS_HASH_SET_ 1
template
<
class
Key
>
using
hash_set
=
::
std
::
unordered_set
<
Key
>
;
template
<
class
Key
>
using
hash_multiset
=
::
std
::
unordered_multiset
<
Key
>
;
#elif GTEST_HAS_HASH_SET_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using
::
std
::
hash_set
;
using
::
std
::
hash_multiset
;
#elif _MSC_VER
using
::
stdext
::
hash_set
;
using
::
stdext
::
hash_multiset
;
#endif
#endif
// Prints a value to a string using the universal value printer. This
...
...
@@ -625,7 +570,7 @@ struct Foo {
TEST
(
PrintPointerTest
,
MemberVariablePointer
)
{
EXPECT_TRUE
(
HasPrefix
(
Print
(
&
Foo
::
value
),
Print
(
sizeof
(
&
Foo
::
value
))
+
"-byte object "
));
int
(
Foo
::*
p
)
=
NULL
;
// NOLINT
int
Foo
::*
p
=
NULL
;
// NOLINT
EXPECT_TRUE
(
HasPrefix
(
Print
(
p
),
Print
(
sizeof
(
p
))
+
"-byte object "
));
}
...
...
@@ -840,22 +785,22 @@ TEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {
EXPECT_EQ
(
"AllowsGenericStreamingAndImplicitConversionTemplate"
,
Print
(
a
));
}
#if GTEST_HAS_
STRING_PIECE_
#if GTEST_HAS_
ABSL
// Tests printing
StringPiece
.
// Tests printing
::absl::string_view
.
TEST
(
PrintString
P
ie
ce
Test
,
SimpleString
P
ie
ce
)
{
const
StringPiece
sp
=
"Hello"
;
TEST
(
PrintString
V
ie
w
Test
,
SimpleString
V
ie
w
)
{
const
::
absl
::
string_view
sp
=
"Hello"
;
EXPECT_EQ
(
"
\"
Hello
\"
"
,
Print
(
sp
));
}
TEST
(
PrintString
P
ie
ce
Test
,
UnprintableCharacters
)
{
TEST
(
PrintString
V
ie
w
Test
,
UnprintableCharacters
)
{
const
char
str
[]
=
"NUL (
\0
) and
\r\t
"
;
const
StringPiece
sp
(
str
,
sizeof
(
str
)
-
1
);
const
::
absl
::
string_view
sp
(
str
,
sizeof
(
str
)
-
1
);
EXPECT_EQ
(
"
\"
NUL (
\\
0) and
\\
r
\\
t
\"
"
,
Print
(
sp
));
}
#endif // GTEST_HAS_
STRING_PIECE_
#endif // GTEST_HAS_
ABSL
// Tests printing STL containers.
...
...
@@ -871,16 +816,16 @@ TEST(PrintStlContainerTest, NonEmptyDeque) {
EXPECT_EQ
(
"{ 1, 3 }"
,
Print
(
non_empty
));
}
#if GTEST_HAS_
HASH
_MAP_
#if GTEST_HAS_
UNORDERED
_MAP_
TEST
(
PrintStlContainerTest
,
OneElementHashMap
)
{
hash
_map
<
int
,
char
>
map1
;
::
std
::
unordered
_map
<
int
,
char
>
map1
;
map1
[
1
]
=
'a'
;
EXPECT_EQ
(
"{ (1, 'a' (97, 0x61)) }"
,
Print
(
map1
));
}
TEST
(
PrintStlContainerTest
,
HashMultiMap
)
{
hash
_multimap
<
int
,
bool
>
map1
;
::
std
::
unordered
_multimap
<
int
,
bool
>
map1
;
map1
.
insert
(
make_pair
(
5
,
true
));
map1
.
insert
(
make_pair
(
5
,
false
));
...
...
@@ -891,12 +836,12 @@ TEST(PrintStlContainerTest, HashMultiMap) {
<<
" where Print(map1) returns
\"
"
<<
result
<<
"
\"
."
;
}
#endif // GTEST_HAS_
HASH
_MAP_
#endif // GTEST_HAS_
UNORDERED
_MAP_
#if GTEST_HAS_
HASH
_SET_
#if GTEST_HAS_
UNORDERED
_SET_
TEST
(
PrintStlContainerTest
,
HashSet
)
{
hash
_set
<
int
>
set1
;
::
std
::
unordered
_set
<
int
>
set1
;
set1
.
insert
(
1
);
EXPECT_EQ
(
"{ 1 }"
,
Print
(
set1
));
}
...
...
@@ -904,7 +849,7 @@ TEST(PrintStlContainerTest, HashSet) {
TEST
(
PrintStlContainerTest
,
HashMultiSet
)
{
const
int
kSize
=
5
;
int
a
[
kSize
]
=
{
1
,
1
,
2
,
5
,
1
};
hash
_multiset
<
int
>
set1
(
a
,
a
+
kSize
);
::
std
::
unordered
_multiset
<
int
>
set1
(
a
,
a
+
kSize
);
// Elements of hash_multiset can be printed in any order.
const
std
::
string
result
=
Print
(
set1
);
...
...
@@ -930,7 +875,7 @@ TEST(PrintStlContainerTest, HashMultiSet) {
EXPECT_TRUE
(
std
::
equal
(
a
,
a
+
kSize
,
numbers
.
begin
()));
}
#endif // GTEST_HAS_
HASH
_SET_
#endif //
GTEST_HAS_
UNORDERED
_SET_
TEST
(
PrintStlContainerTest
,
List
)
{
const
std
::
string
a
[]
=
{
"hello"
,
"world"
};
...
...
@@ -973,8 +918,6 @@ TEST(PrintStlContainerTest, MultiSet) {
}
#if GTEST_HAS_STD_FORWARD_LIST_
// <slist> is available on Linux in the google3 mode, but not on
// Windows or Mac OS X.
TEST
(
PrintStlContainerTest
,
SinglyLinkedList
)
{
int
a
[]
=
{
9
,
2
,
8
};
...
...
@@ -1092,7 +1035,7 @@ TEST(PrintTr1TupleTest, VariousSizes) {
::
std
::
tr1
::
tuple
<
bool
,
char
,
short
,
testing
::
internal
::
Int32
,
// NOLINT
testing
::
internal
::
Int64
,
float
,
double
,
const
char
*
,
void
*
,
std
::
string
>
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
// NOLINT
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
EXPECT_EQ
(
"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, "
+
PrintPointer
(
str
)
+
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
...
...
@@ -1152,7 +1095,7 @@ TEST(PrintStdTupleTest, VariousSizes) {
::
std
::
tuple
<
bool
,
char
,
short
,
testing
::
internal
::
Int32
,
// NOLINT
testing
::
internal
::
Int64
,
float
,
double
,
const
char
*
,
void
*
,
std
::
string
>
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
// NOLINT
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
EXPECT_EQ
(
"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, "
+
PrintPointer
(
str
)
+
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
...
...
@@ -1168,6 +1111,12 @@ TEST(PrintStdTupleTest, NestedTuple) {
#endif // GTEST_LANG_CXX11
#if GTEST_LANG_CXX11
TEST
(
PrintNullptrT
,
Basic
)
{
EXPECT_EQ
(
"(nullptr)"
,
Print
(
nullptr
));
}
#endif // GTEST_LANG_CXX11
// Tests printing user-defined unprintable types.
// Unprintable types in the global namespace.
...
...
@@ -1297,7 +1246,7 @@ TEST(PrintReferenceTest, HandlesMemberFunctionPointer) {
// Tests that the universal printer prints a member variable pointer
// passed by reference.
TEST
(
PrintReferenceTest
,
HandlesMemberVariablePointer
)
{
int
(
Foo
::*
p
)
=
&
Foo
::
value
;
// NOLINT
int
Foo
::*
p
=
&
Foo
::
value
;
// NOLINT
EXPECT_TRUE
(
HasPrefix
(
PrintByRef
(
p
),
"@"
+
PrintPointer
(
&
p
)
+
" "
+
Print
(
sizeof
(
p
))
+
"-byte object "
));
...
...
@@ -1330,7 +1279,7 @@ TEST(FormatForComparisonFailureMessageTest, FormatsNonCharArrayAsPointer) {
}
// Tests formatting a char pointer when it's compared with another pointer.
// In this case we want to print it as a raw pointer, as the comparis
i
on is by
// In this case we want to print it as a raw pointer, as the comparison is by
// pointer.
// char pointer vs pointer
...
...
@@ -1555,6 +1504,78 @@ TEST(PrintToStringTest, WorksForCharArrayWithEmbeddedNul) {
EXPECT_PRINT_TO_STRING_
(
mutable_str_with_nul
,
"
\"
hello
\\
0 world
\"
"
);
}
TEST
(
PrintToStringTest
,
ContainsNonLatin
)
{
// Sanity test with valid UTF-8. Prints both in hex and as text.
std
::
string
non_ascii_str
=
::
std
::
string
(
"오전 4:30"
);
EXPECT_PRINT_TO_STRING_
(
non_ascii_str
,
"
\"\\
xEC
\\
x98
\\
xA4
\\
xEC
\\
xA0
\\
x84 4:30
\"\n
"
" As Text:
\"
오전 4:30
\"
"
);
non_ascii_str
=
::
std
::
string
(
"From ä — ẑ"
);
EXPECT_PRINT_TO_STRING_
(
non_ascii_str
,
"
\"
From
\\
xC3
\\
xA4
\\
xE2
\\
x80
\\
x94
\\
xE1
\\
xBA
\\
x91
\"
"
"
\n
As Text:
\"
From ä — ẑ
\"
"
);
}
TEST
(
IsValidUTF8Test
,
IllFormedUTF8
)
{
// The following test strings are ill-formed UTF-8 and are printed
// as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is
// expected to fail, thus output does not contain "As Text:".
static
const
char
*
const
kTestdata
[][
2
]
=
{
// 2-byte lead byte followed by a single-byte character.
{
"
\xC3\x74
"
,
"
\"\\
xC3t
\"
"
},
// Valid 2-byte character followed by an orphan trail byte.
{
"
\xC3\x84\xA4
"
,
"
\"\\
xC3
\\
x84
\\
xA4
\"
"
},
// Lead byte without trail byte.
{
"abc
\xC3
"
,
"
\"
abc
\\
xC3
\"
"
},
// 3-byte lead byte, single-byte character, orphan trail byte.
{
"x
\xE2\x70\x94
"
,
"
\"
x
\\
xE2p
\\
x94
\"
"
},
// Truncated 3-byte character.
{
"
\xE2\x80
"
,
"
\"\\
xE2
\\
x80
\"
"
},
// Truncated 3-byte character followed by valid 2-byte char.
{
"
\xE2\x80\xC3\x84
"
,
"
\"\\
xE2
\\
x80
\\
xC3
\\
x84
\"
"
},
// Truncated 3-byte character followed by a single-byte character.
{
"
\xE2\x80\x7A
"
,
"
\"\\
xE2
\\
x80z
\"
"
},
// 3-byte lead byte followed by valid 3-byte character.
{
"
\xE2\xE2\x80\x94
"
,
"
\"\\
xE2
\\
xE2
\\
x80
\\
x94
\"
"
},
// 4-byte lead byte followed by valid 3-byte character.
{
"
\xF0\xE2\x80\x94
"
,
"
\"\\
xF0
\\
xE2
\\
x80
\\
x94
\"
"
},
// Truncated 4-byte character.
{
"
\xF0\xE2\x80
"
,
"
\"\\
xF0
\\
xE2
\\
x80
\"
"
},
// Invalid UTF-8 byte sequences embedded in other chars.
{
"abc
\xE2\x80\x94\xC3\x74
xyc"
,
"
\"
abc
\\
xE2
\\
x80
\\
x94
\\
xC3txyc
\"
"
},
{
"abc
\xC3\x84\xE2\x80\xC3\x84
xyz"
,
"
\"
abc
\\
xC3
\\
x84
\\
xE2
\\
x80
\\
xC3
\\
x84xyz
\"
"
},
// Non-shortest UTF-8 byte sequences are also ill-formed.
// The classics: xC0, xC1 lead byte.
{
"
\xC0\x80
"
,
"
\"\\
xC0
\\
x80
\"
"
},
{
"
\xC1\x81
"
,
"
\"\\
xC1
\\
x81
\"
"
},
// Non-shortest sequences.
{
"
\xE0\x80\x80
"
,
"
\"\\
xE0
\\
x80
\\
x80
\"
"
},
{
"
\xf0\x80\x80\x80
"
,
"
\"\\
xF0
\\
x80
\\
x80
\\
x80
\"
"
},
// Last valid code point before surrogate range, should be printed as text,
// too.
{
"
\xED\x9F\xBF
"
,
"
\"\\
xED
\\
x9F
\\
xBF
\"\n
As Text:
\"
\"
"
},
// Start of surrogate lead. Surrogates are not printed as text.
{
"
\xED\xA0\x80
"
,
"
\"\\
xED
\\
xA0
\\
x80
\"
"
},
// Last non-private surrogate lead.
{
"
\xED\xAD\xBF
"
,
"
\"\\
xED
\\
xAD
\\
xBF
\"
"
},
// First private-use surrogate lead.
{
"
\xED\xAE\x80
"
,
"
\"\\
xED
\\
xAE
\\
x80
\"
"
},
// Last private-use surrogate lead.
{
"
\xED\xAF\xBF
"
,
"
\"\\
xED
\\
xAF
\\
xBF
\"
"
},
// Mid-point of surrogate trail.
{
"
\xED\xB3\xBF
"
,
"
\"\\
xED
\\
xB3
\\
xBF
\"
"
},
// First valid code point after surrogate range, should be printed as text,
// too.
{
"
\xEE\x80\x80
"
,
"
\"\\
xEE
\\
x80
\\
x80
\"\n
As Text:
\"
\"
"
}
};
for
(
int
i
=
0
;
i
<
int
(
sizeof
(
kTestdata
)
/
sizeof
(
kTestdata
[
0
]));
++
i
)
{
EXPECT_PRINT_TO_STRING_
(
kTestdata
[
i
][
0
],
kTestdata
[
i
][
1
]);
}
}
#undef EXPECT_PRINT_TO_STRING_
TEST
(
UniversalTersePrintTest
,
WorksForNonReference
)
{
...
...
@@ -1696,5 +1717,32 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
#endif // GTEST_HAS_STD_TUPLE_
#if GTEST_HAS_ABSL
TEST
(
PrintOptionalTest
,
Basic
)
{
absl
::
optional
<
int
>
value
;
EXPECT_EQ
(
"(nullopt)"
,
PrintToString
(
value
));
value
=
{
7
};
EXPECT_EQ
(
"(7)"
,
PrintToString
(
value
));
EXPECT_EQ
(
"(1.1)"
,
PrintToString
(
absl
::
optional
<
double
>
{
1.1
}));
EXPECT_EQ
(
"(
\"
A
\"
)"
,
PrintToString
(
absl
::
optional
<
std
::
string
>
{
"A"
}));
}
struct
NonPrintable
{
unsigned
char
contents
=
17
;
};
TEST
(
PrintOneofTest
,
Basic
)
{
using
Type
=
absl
::
variant
<
int
,
StreamableInGlobal
,
NonPrintable
>
;
EXPECT_EQ
(
"('int' with value 7)"
,
PrintToString
(
Type
(
7
)));
EXPECT_EQ
(
"('StreamableInGlobal' with value StreamableInGlobal)"
,
PrintToString
(
Type
(
StreamableInGlobal
{})));
EXPECT_EQ
(
"('testing::gtest_printers_test::NonPrintable' with value 1-byte object "
"<11>)"
,
PrintToString
(
Type
(
NonPrintable
{})));
}
#endif // GTEST_HAS_ABSL
}
// namespace gtest_printers_test
}
// namespace testing
googletest/test/gtest
_
shuffle
_
test.py
→
googletest/test/g
oogle
test
-
shuffle
-
test.py
View file @
21e51855
...
...
@@ -30,13 +30,11 @@
"""Verifies that test shuffling works."""
__author__
=
'wan@google.com (Zhanyong Wan)'
import
os
import
gtest_test_utils
# Command to run the gtest
_
shuffle
_
test_ program.
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest
_
shuffle
_
test_'
)
# Command to run the g
oogle
test
-
shuffle
-
test_ program.
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'g
oogle
test
-
shuffle
-
test_'
)
# The environment variables for test sharding.
TOTAL_SHARDS_ENV_VAR
=
'GTEST_TOTAL_SHARDS'
...
...
@@ -89,7 +87,7 @@ def GetTestsForAllIterations(extra_env, args):
Args:
extra_env: a map from environment variables to their values
args: command line flags to pass to gtest
_
shuffle
_
test_
args: command line flags to pass to g
oogle
test
-
shuffle
-
test_
Returns:
A list where the i-th element is the list of tests run in the i-th
...
...
googletest/test/gtest
_
shuffle
_
test_.cc
→
googletest/test/g
oogle
test
-
shuffle
-
test_.cc
View file @
21e51855
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Verifies that test shuffling works.
...
...
googletest/test/gtest-test-part
_
test.cc
→
googletest/test/g
oogle
test-test-part
-
test.cc
View file @
21e51855
...
...
@@ -26,9 +26,6 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
//
#include "gtest/gtest-test-part.h"
...
...
@@ -203,6 +200,6 @@ TEST_F(TestPartResultArrayDeathTest, DiesWhenIndexIsOutOfBound) {
EXPECT_DEATH_IF_SUPPORTED
(
results
.
GetTestPartResult
(
1
),
""
);
}
//
TODO(mheule@google.com)
: Add a test for the class HasNewFatalFailureHelper.
//
FIXME
: Add a test for the class HasNewFatalFailureHelper.
}
// namespace
googletest/test/googletest-test2_test.cc
0 → 100644
View file @
21e51855
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Tests for Google Test itself. This verifies that the basic constructs of
// Google Test work.
#include "gtest/gtest.h"
#include "googletest-param-test-test.h"
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
// Tests that generators defined in a different translation unit
// are functional. The test using extern_gen_2 is defined
// in googletest-param-test-test.cc.
ParamGenerator
<
int
>
extern_gen_2
=
Values
(
33
);
// Tests that a parameterized test case can be defined in one translation unit
// 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_CASE_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
// gtest-param-test_test.h
INSTANTIATE_TEST_CASE_P
(
Sequence2
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
googletest/test/gtest
_
throw
_
on
_
failure
_
test.py
→
googletest/test/g
oogle
test
-
throw
-
on
-
failure
-
test.py
View file @
21e51855
...
...
@@ -31,12 +31,10 @@
"""Tests Google Test's throw-on-failure mode with exceptions disabled.
This script invokes gtest
_
throw
_
on
_
failure
_
test_ (a program written with
This script invokes g
oogle
test
-
throw
-
on
-
failure
-
test_ (a program written with
Google Test) with different environments and command line flags.
"""
__author__
=
'wan@google.com (Zhanyong Wan)'
import
os
import
gtest_test_utils
...
...
@@ -46,10 +44,10 @@ import gtest_test_utils
# The command line flag for enabling/disabling the throw-on-failure mode.
THROW_ON_FAILURE
=
'gtest_throw_on_failure'
# Path to the gtest
_
throw
_
on
_
failure
_
test_ program, compiled with
# Path to the g
oogle
test
-
throw
-
on
-
failure
-
test_ program, compiled with
# exceptions disabled.
EXE_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest
_
throw
_
on
_
failure
_
test_'
)
'g
oogle
test
-
throw
-
on
-
failure
-
test_'
)
# Utilities.
...
...
@@ -70,18 +68,18 @@ def SetEnvVar(env_var, value):
def
Run
(
command
):
"""Runs a command; returns True/False if its exit code is/isn't 0."""
print
(
'Running "%s". . .'
%
' '
.
join
(
command
)
)
print
'Running "%s". . .'
%
' '
.
join
(
command
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
return
p
.
exited
and
p
.
exit_code
==
0
# The tests.
TODO(wan@google.com)
: refactor the class to share common
# logic with code in gtest
_
break
_
on
_
failure
_
unittest.py.
# The tests.
FIXME
: refactor the class to share common
# logic with code in g
oogle
test
-
break
-
on
-
failure
-
unittest.py.
class
ThrowOnFailureTest
(
gtest_test_utils
.
TestCase
):
"""Tests the throw-on-failure mode."""
def
RunAndVerify
(
self
,
env_var_value
,
flag_value
,
should_fail
):
"""Runs gtest
_
throw
_
on
_
failure
_
test_ and verifies that it does
"""Runs g
oogle
test
-
throw
-
on
-
failure
-
test_ and verifies that it does
(or does not) exit with a non-zero code.
Args:
...
...
googletest/test/gtest
_
throw
_
on
_
failure
_
test_.cc
→
googletest/test/g
oogle
test
-
throw
-
on
-
failure
-
test_.cc
View file @
21e51855
...
...
@@ -26,13 +26,12 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Tests Google Test's throw-on-failure mode with exceptions disabled.
//
// This program must be compiled with exceptions disabled. It will be
// invoked by gtest
_
throw
_
on
_
failure
_
test.py, and is expected to exit
// invoked by g
oogle
test
-
throw
-
on
-
failure
-
test.py, and is expected to exit
// with non-zero in the throw-on-failure mode or 0 otherwise.
#include "gtest/gtest.h"
...
...
googletest/test/gtest-tuple
_
test.cc
→
googletest/test/g
oogle
test-tuple
-
test.cc
View file @
21e51855
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/internal/gtest-tuple.h"
#include <utility>
...
...
Prev
1
…
6
7
8
9
10
11
12
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