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
687964c8
Unverified
Commit
687964c8
authored
Aug 17, 2018
by
Conor Burgess
Committed by
GitHub
Aug 17, 2018
Browse files
Merge branch 'master' into fix-argc
parents
f11a8f91
02a8ca87
Changes
222
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
489 additions
and
162 deletions
+489
-162
googletest/test/gtest_prod_test.cc
googletest/test/gtest_prod_test.cc
+2
-3
googletest/test/gtest_repeat_test.cc
googletest/test/gtest_repeat_test.cc
+2
-4
googletest/test/gtest_sole_header_test.cc
googletest/test/gtest_sole_header_test.cc
+1
-2
googletest/test/gtest_stress_test.cc
googletest/test/gtest_stress_test.cc
+1
-2
googletest/test/gtest_test_macro_stack_footprint_test.cc
googletest/test/gtest_test_macro_stack_footprint_test.cc
+89
-0
googletest/test/gtest_test_utils.py
googletest/test/gtest_test_utils.py
+6
-10
googletest/test/gtest_testbridge_test.py
googletest/test/gtest_testbridge_test.py
+63
-0
googletest/test/gtest_testbridge_test_.cc
googletest/test/gtest_testbridge_test_.cc
+43
-0
googletest/test/gtest_throw_on_failure_ex_test.cc
googletest/test/gtest_throw_on_failure_ex_test.cc
+1
-2
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+190
-104
googletest/test/gtest_xml_outfile1_test_.cc
googletest/test/gtest_xml_outfile1_test_.cc
+0
-1
googletest/test/gtest_xml_outfile2_test_.cc
googletest/test/gtest_xml_outfile2_test_.cc
+0
-1
googletest/test/gtest_xml_outfiles_test.py
googletest/test/gtest_xml_outfiles_test.py
+16
-4
googletest/test/gtest_xml_output_unittest.py
googletest/test/gtest_xml_output_unittest.py
+48
-9
googletest/test/gtest_xml_test_utils.py
googletest/test/gtest_xml_test_utils.py
+22
-13
googletest/test/production.cc
googletest/test/production.cc
+1
-2
googletest/test/production.h
googletest/test/production.h
+1
-2
googletest/xcode/Config/DebugProject.xcconfig
googletest/xcode/Config/DebugProject.xcconfig
+1
-1
googletest/xcode/Config/FrameworkTarget.xcconfig
googletest/xcode/Config/FrameworkTarget.xcconfig
+1
-1
googletest/xcode/Config/General.xcconfig
googletest/xcode/Config/General.xcconfig
+1
-1
No files found.
googletest/test/gtest_prod_test.cc
View file @
687964c8
...
@@ -26,10 +26,9 @@
...
@@ -26,10 +26,9 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// Author: wan@google.com (Zhanyong Wan)
// Unit test for gtest_prod.h.
//
// Unit test for gtest/gtest_prod.h.
#include "production.h"
#include "production.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
...
...
googletest/test/gtest_repeat_test.cc
View file @
687964c8
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Tests the --gtest_repeat=number flag.
// Tests the --gtest_repeat=number flag.
...
@@ -118,8 +117,7 @@ const int kNumberOfParamTests = 10;
...
@@ -118,8 +117,7 @@ const int kNumberOfParamTests = 10;
class
MyParamTest
:
public
testing
::
TestWithParam
<
int
>
{};
class
MyParamTest
:
public
testing
::
TestWithParam
<
int
>
{};
TEST_P
(
MyParamTest
,
ShouldPass
)
{
TEST_P
(
MyParamTest
,
ShouldPass
)
{
// TODO(vladl@google.com): Make parameter value checking robust
// FIXME: Make parameter value checking robust WRT order of tests.
// WRT order of tests.
GTEST_CHECK_INT_EQ_
(
g_param_test_count
%
kNumberOfParamTests
,
GetParam
());
GTEST_CHECK_INT_EQ_
(
g_param_test_count
%
kNumberOfParamTests
,
GetParam
());
g_param_test_count
++
;
g_param_test_count
++
;
}
}
...
...
googletest/test/gtest_sole_header_test.cc
View file @
687964c8
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: mheule@google.com (Markus Heule)
//
//
// This test verifies that it's possible to use Google Test by including
// This test verifies that it's possible to use Google Test by including
// the gtest.h header file alone.
// the gtest.h header file alone.
...
...
googletest/test/gtest_stress_test.cc
View file @
687964c8
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Tests that SCOPED_TRACE() and various Google Test assertions can be
// Tests that SCOPED_TRACE() and various Google Test assertions can be
// used in a large number of threads concurrently.
// used in a large number of threads concurrently.
...
...
googletest/test/gtest_test_macro_stack_footprint_test.cc
0 → 100644
View file @
687964c8
// Copyright 2013, 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.
//
// Each TEST() expands to some static registration logic. GCC puts all
// such static initialization logic for a translation unit in a common,
// internal function. Since Google's build system restricts how much
// stack space a function can use, there's a limit on how many TEST()s
// one can put in a single C++ test file. This test ensures that a large
// number of TEST()s can be defined in the same translation unit.
#include "gtest/gtest.h"
// This macro defines 10 dummy tests.
#define TEN_TESTS_(test_case_name) \
TEST(test_case_name, T0) {} \
TEST(test_case_name, T1) {} \
TEST(test_case_name, T2) {} \
TEST(test_case_name, T3) {} \
TEST(test_case_name, T4) {} \
TEST(test_case_name, T5) {} \
TEST(test_case_name, T6) {} \
TEST(test_case_name, T7) {} \
TEST(test_case_name, T8) {} \
TEST(test_case_name, T9) {}
// This macro defines 100 dummy tests.
#define HUNDRED_TESTS_(test_case_name_prefix) \
TEN_TESTS_(test_case_name_prefix ## 0) \
TEN_TESTS_(test_case_name_prefix ## 1) \
TEN_TESTS_(test_case_name_prefix ## 2) \
TEN_TESTS_(test_case_name_prefix ## 3) \
TEN_TESTS_(test_case_name_prefix ## 4) \
TEN_TESTS_(test_case_name_prefix ## 5) \
TEN_TESTS_(test_case_name_prefix ## 6) \
TEN_TESTS_(test_case_name_prefix ## 7) \
TEN_TESTS_(test_case_name_prefix ## 8) \
TEN_TESTS_(test_case_name_prefix ## 9)
// This macro defines 1000 dummy tests.
#define THOUSAND_TESTS_(test_case_name_prefix) \
HUNDRED_TESTS_(test_case_name_prefix ## 0) \
HUNDRED_TESTS_(test_case_name_prefix ## 1) \
HUNDRED_TESTS_(test_case_name_prefix ## 2) \
HUNDRED_TESTS_(test_case_name_prefix ## 3) \
HUNDRED_TESTS_(test_case_name_prefix ## 4) \
HUNDRED_TESTS_(test_case_name_prefix ## 5) \
HUNDRED_TESTS_(test_case_name_prefix ## 6) \
HUNDRED_TESTS_(test_case_name_prefix ## 7) \
HUNDRED_TESTS_(test_case_name_prefix ## 8) \
HUNDRED_TESTS_(test_case_name_prefix ## 9)
// Ensures that we can define 1000 TEST()s in the same translation
// unit.
THOUSAND_TESTS_
(
T
)
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
// We don't actually need to run the dummy tests - the purpose is to
// ensure that they compile.
return
0
;
}
googletest/test/gtest_test_utils.py
View file @
687964c8
...
@@ -27,24 +27,20 @@
...
@@ -27,24 +27,20 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Unit test utilities for Google C++ Testing Framework."""
"""Unit test utilities for Google C++ Testing
and Mocking
Framework."""
# Suppresses the 'Import not at the top of the file' lint complaint.
# Suppresses the 'Import not at the top of the file' lint complaint.
# pylint: disable-msg=C6204
# pylint: disable-msg=C6204
__author__
=
'wan@google.com (Zhanyong Wan)'
import
os
import
os
import
sys
import
sys
IS_LINUX
=
os
.
name
==
'posix'
and
os
.
uname
()[
0
]
==
'Linux'
IS_WINDOWS
=
os
.
name
==
'nt'
IS_WINDOWS
=
os
.
name
==
'nt'
IS_CYGWIN
=
os
.
name
==
'posix'
and
'CYGWIN'
in
os
.
uname
()[
0
]
IS_CYGWIN
=
os
.
name
==
'posix'
and
'CYGWIN'
in
os
.
uname
()[
0
]
import
atexit
import
atexit
import
shutil
import
shutil
import
tempfile
import
tempfile
import
unittest
import
unittest
as
_test_module
_test_module
=
unittest
try
:
try
:
import
subprocess
import
subprocess
...
@@ -74,7 +70,7 @@ def SetEnvVar(env_var, value):
...
@@ -74,7 +70,7 @@ def SetEnvVar(env_var, value):
# Here we expose a class from a particular module, depending on the
# Here we expose a class from a particular module, depending on the
# environment. The comment suppresses the 'Invalid variable name' lint
# environment. The comment suppresses the 'Invalid variable name' lint
# complaint.
# complaint.
TestCase
=
_test_module
.
TestCase
# pylint: disable
-msg
=C6409
TestCase
=
_test_module
.
TestCase
# pylint: disable=C6409
# Initially maps a flag to its default value. After
# Initially maps a flag to its default value. After
# _ParseAndStripGTestFlags() is called, maps a flag to its actual value.
# _ParseAndStripGTestFlags() is called, maps a flag to its actual value.
...
@@ -88,7 +84,7 @@ def _ParseAndStripGTestFlags(argv):
...
@@ -88,7 +84,7 @@ def _ParseAndStripGTestFlags(argv):
# Suppresses the lint complaint about a global variable since we need it
# Suppresses the lint complaint about a global variable since we need it
# here to maintain module-wide state.
# here to maintain module-wide state.
global
_gtest_flags_are_parsed
# pylint: disable
-msg
=W0603
global
_gtest_flags_are_parsed
# pylint: disable=W0603
if
_gtest_flags_are_parsed
:
if
_gtest_flags_are_parsed
:
return
return
...
@@ -227,7 +223,7 @@ class Subprocess:
...
@@ -227,7 +223,7 @@ class Subprocess:
combined in a string.
combined in a string.
"""
"""
# The subprocess module is the preferable way of running programs
# The subprocess module is the prefer
r
able way of running programs
# since it is available and behaves consistently on all platforms,
# since it is available and behaves consistently on all platforms,
# including Windows. But it is only available starting in python 2.4.
# including Windows. But it is only available starting in python 2.4.
# In earlier python versions, we revert to the popen2 module, which is
# In earlier python versions, we revert to the popen2 module, which is
...
@@ -310,7 +306,7 @@ def Main():
...
@@ -310,7 +306,7 @@ def Main():
_ParseAndStripGTestFlags
(
sys
.
argv
)
_ParseAndStripGTestFlags
(
sys
.
argv
)
# The tested binaries should not be writing XML output files unless the
# The tested binaries should not be writing XML output files unless the
# script explicitly instructs them to.
# script explicitly instructs them to.
#
TODO(vladl@google.com)
: Move this into Subprocess when we implement
#
FIXME
: Move this into Subprocess when we implement
# passing environment into it as a parameter.
# passing environment into it as a parameter.
if
GTEST_OUTPUT_VAR_NAME
in
os
.
environ
:
if
GTEST_OUTPUT_VAR_NAME
in
os
.
environ
:
del
os
.
environ
[
GTEST_OUTPUT_VAR_NAME
]
del
os
.
environ
[
GTEST_OUTPUT_VAR_NAME
]
...
...
googletest/test/gtest_testbridge_test.py
0 → 100755
View file @
687964c8
#!/usr/bin/env python
#
# Copyright 2018 Google LLC. 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 uses filter provided via testbridge."""
import
os
import
gtest_test_utils
binary_name
=
'gtest_testbridge_test_'
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
binary_name
)
TESTBRIDGE_NAME
=
'TESTBRIDGE_TEST_ONLY'
def
Assert
(
condition
):
if
not
condition
:
raise
AssertionError
class
GTestTestFilterTest
(
gtest_test_utils
.
TestCase
):
def
testTestExecutionIsFiltered
(
self
):
"""Tests that the test filter is picked up from the testbridge env var."""
subprocess_env
=
os
.
environ
.
copy
()
subprocess_env
[
TESTBRIDGE_NAME
]
=
'*.TestThatSucceeds'
p
=
gtest_test_utils
.
Subprocess
(
COMMAND
,
env
=
subprocess_env
)
self
.
assertEquals
(
0
,
p
.
exit_code
)
Assert
(
'filter = *.TestThatSucceeds'
in
p
.
output
)
Assert
(
'[ OK ] TestFilterTest.TestThatSucceeds'
in
p
.
output
)
Assert
(
'[ PASSED ] 1 test.'
in
p
.
output
)
if
__name__
==
'__main__'
:
gtest_test_utils
.
Main
()
googletest/test/gtest_testbridge_test_.cc
0 → 100644
View file @
687964c8
// Copyright 2018, Google LLC.
// 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.
// This program is meant to be run by gtest_test_filter_test.py. Do not run
// it directly.
#include "gtest/gtest.h"
// These tests are used to detect if filtering is working. Only
// 'TestThatSucceeds' should ever run.
TEST
(
TestFilterTest
,
TestThatSucceeds
)
{}
TEST
(
TestFilterTest
,
TestThatFails
)
{
ASSERT_TRUE
(
false
)
<<
"This test should never be run."
;
}
googletest/test/gtest_throw_on_failure_ex_test.cc
View file @
687964c8
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Tests Google Test's throw-on-failure mode with exceptions enabled.
// Tests Google Test's throw-on-failure mode with exceptions enabled.
...
...
googletest/test/gtest_unittest.cc
View file @
687964c8
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
//
// Tests for Google Test itself. This verifies that the basic constructs of
// Tests for Google Test itself. This verifies that the basic constructs of
// Google Test work.
// Google Test work.
...
@@ -35,8 +34,8 @@
...
@@ -35,8 +34,8 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
// Verifies that the command line flag variables can be accessed in
// Verifies that the command line flag variables can be accessed in
// code once "gtest
/gtest
.h" has been
// code once "gtest.h" has been
#included.
//
#included.
Do not move it after other gtest #includes.
// Do not move it after other gtest #includes.
TEST
(
CommandLineFlagsTest
,
CanBeAccessedInCodeOnceGTestHIsIncluded
)
{
TEST
(
CommandLineFlagsTest
,
CanBeAccessedInCodeOnceGTestHIsIncluded
)
{
bool
dummy
=
testing
::
GTEST_FLAG
(
also_run_disabled_tests
)
bool
dummy
=
testing
::
GTEST_FLAG
(
also_run_disabled_tests
)
||
testing
::
GTEST_FLAG
(
break_on_failure
)
||
testing
::
GTEST_FLAG
(
break_on_failure
)
...
@@ -64,6 +63,9 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
...
@@ -64,6 +63,9 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <map>
#include <map>
#include <vector>
#include <vector>
#include <ostream>
#include <ostream>
#if GTEST_LANG_CXX11
#include <unordered_set>
#endif // GTEST_LANG_CXX11
#include "gtest/gtest-spi.h"
#include "gtest/gtest-spi.h"
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
...
@@ -258,6 +260,8 @@ using testing::internal::IsContainer;
...
@@ -258,6 +260,8 @@ using testing::internal::IsContainer;
using
testing
::
internal
::
IsContainerTest
;
using
testing
::
internal
::
IsContainerTest
;
using
testing
::
internal
::
IsNotContainer
;
using
testing
::
internal
::
IsNotContainer
;
using
testing
::
internal
::
NativeArray
;
using
testing
::
internal
::
NativeArray
;
using
testing
::
internal
::
OsStackTraceGetter
;
using
testing
::
internal
::
OsStackTraceGetterInterface
;
using
testing
::
internal
::
ParseInt32Flag
;
using
testing
::
internal
::
ParseInt32Flag
;
using
testing
::
internal
::
RelationToSourceCopy
;
using
testing
::
internal
::
RelationToSourceCopy
;
using
testing
::
internal
::
RelationToSourceReference
;
using
testing
::
internal
::
RelationToSourceReference
;
...
@@ -274,6 +278,7 @@ using testing::internal::String;
...
@@ -274,6 +278,7 @@ using testing::internal::String;
using
testing
::
internal
::
TestEventListenersAccessor
;
using
testing
::
internal
::
TestEventListenersAccessor
;
using
testing
::
internal
::
TestResultAccessor
;
using
testing
::
internal
::
TestResultAccessor
;
using
testing
::
internal
::
UInt32
;
using
testing
::
internal
::
UInt32
;
using
testing
::
internal
::
UnitTestImpl
;
using
testing
::
internal
::
WideStringToUtf8
;
using
testing
::
internal
::
WideStringToUtf8
;
using
testing
::
internal
::
edit_distance
::
CalculateOptimalEdits
;
using
testing
::
internal
::
edit_distance
::
CalculateOptimalEdits
;
using
testing
::
internal
::
edit_distance
::
CreateUnifiedDiff
;
using
testing
::
internal
::
edit_distance
::
CreateUnifiedDiff
;
...
@@ -374,6 +379,31 @@ TEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) {
...
@@ -374,6 +379,31 @@ TEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) {
EXPECT_EQ
(
kTestTypeIdInGoogleTest
,
GetTestTypeId
());
EXPECT_EQ
(
kTestTypeIdInGoogleTest
,
GetTestTypeId
());
}
}
// Tests CanonicalizeForStdLibVersioning.
using
::
testing
::
internal
::
CanonicalizeForStdLibVersioning
;
TEST
(
CanonicalizeForStdLibVersioning
,
LeavesUnversionedNamesUnchanged
)
{
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::_"
));
EXPECT_EQ
(
"std::__foo"
,
CanonicalizeForStdLibVersioning
(
"std::__foo"
));
EXPECT_EQ
(
"gtl::__1::x"
,
CanonicalizeForStdLibVersioning
(
"gtl::__1::x"
));
EXPECT_EQ
(
"__1::x"
,
CanonicalizeForStdLibVersioning
(
"__1::x"
));
EXPECT_EQ
(
"::__1::x"
,
CanonicalizeForStdLibVersioning
(
"::__1::x"
));
}
TEST
(
CanonicalizeForStdLibVersioning
,
ElidesDoubleUnderNames
)
{
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::__1::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::__1::_"
));
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::__g::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::__g::_"
));
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::__google::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::__google::_"
));
}
// Tests FormatTimeInMillisAsSeconds().
// Tests FormatTimeInMillisAsSeconds().
TEST
(
FormatTimeInMillisAsSecondsTest
,
FormatsZero
)
{
TEST
(
FormatTimeInMillisAsSecondsTest
,
FormatsZero
)
{
...
@@ -413,10 +443,10 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
...
@@ -413,10 +443,10 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
virtual
void
SetUp
()
{
virtual
void
SetUp
()
{
saved_tz_
=
NULL
;
saved_tz_
=
NULL
;
GTEST_DISABLE_MSC_
WARNINGS
_PUSH_
(
4996
/* getenv, strdup: deprecated */
)
GTEST_DISABLE_MSC_
DEPRECATED
_PUSH_
(
/* getenv, strdup: deprecated */
)
if
(
getenv
(
"TZ"
))
if
(
getenv
(
"TZ"
))
saved_tz_
=
strdup
(
getenv
(
"TZ"
));
saved_tz_
=
strdup
(
getenv
(
"TZ"
));
GTEST_DISABLE_MSC_
WARNINGS
_POP_
()
GTEST_DISABLE_MSC_
DEPRECATED
_POP_
()
// Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We
// Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We
// cannot use the local time zone because the function's output depends
// cannot use the local time zone because the function's output depends
...
@@ -1354,8 +1384,7 @@ class TestResultTest : public Test {
...
@@ -1354,8 +1384,7 @@ class TestResultTest : public Test {
// In order to test TestResult, we need to modify its internal
// In order to test TestResult, we need to modify its internal
// state, in particular the TestPartResult vector it holds.
// state, in particular the TestPartResult vector it holds.
// test_part_results() returns a const reference to this vector.
// test_part_results() returns a const reference to this vector.
// We cast it to a non-const object s.t. it can be modified (yes,
// We cast it to a non-const object s.t. it can be modified
// this is a hack).
TPRVector
*
results1
=
const_cast
<
TPRVector
*>
(
TPRVector
*
results1
=
const_cast
<
TPRVector
*>
(
&
TestResultAccessor
::
test_part_results
(
*
r1
));
&
TestResultAccessor
::
test_part_results
(
*
r1
));
TPRVector
*
results2
=
const_cast
<
TPRVector
*>
(
TPRVector
*
results2
=
const_cast
<
TPRVector
*>
(
...
@@ -2088,7 +2117,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment {
...
@@ -2088,7 +2117,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment {
};
};
// This will test property recording outside of any test or test case.
// This will test property recording outside of any test or test case.
Environment
*
record_property_env
GTEST_ATTRIBUTE_UNUSED_
=
static
Environment
*
record_property_env
=
AddGlobalTestEnvironment
(
new
UnitTestRecordPropertyTestEnvironment
);
AddGlobalTestEnvironment
(
new
UnitTestRecordPropertyTestEnvironment
);
// This group of tests is for predicate assertions (ASSERT_PRED*, etc)
// This group of tests is for predicate assertions (ASSERT_PRED*, etc)
...
@@ -2421,9 +2450,8 @@ TEST(StringAssertionTest, ASSERT_STREQ) {
...
@@ -2421,9 +2450,8 @@ TEST(StringAssertionTest, ASSERT_STREQ) {
const
char
p2
[]
=
"good"
;
const
char
p2
[]
=
"good"
;
ASSERT_STREQ
(
p1
,
p2
);
ASSERT_STREQ
(
p1
,
p2
);
EXPECT_FATAL_FAILURE
(
EXPECT_FATAL_FAILURE
(
ASSERT_STREQ
(
"bad"
,
"good"
),
ASSERT_STREQ
(
"bad"
,
"good"
),
"
\"
bad
\"\n
\"
good
\"
"
);
"Expected equality of these values:
\n
\"
bad
\"\n
\"
good
\"
"
);
}
}
// Tests ASSERT_STREQ with NULL arguments.
// Tests ASSERT_STREQ with NULL arguments.
...
@@ -3361,7 +3389,7 @@ class NoFatalFailureTest : public Test {
...
@@ -3361,7 +3389,7 @@ class NoFatalFailureTest : public Test {
void
DoAssertNoFatalFailureOnFails
()
{
void
DoAssertNoFatalFailureOnFails
()
{
ASSERT_NO_FATAL_FAILURE
(
Fails
());
ASSERT_NO_FATAL_FAILURE
(
Fails
());
ADD_FAILURE
()
<<
"shold not reach here."
;
ADD_FAILURE
()
<<
"sho
u
ld not reach here."
;
}
}
void
DoExpectNoFatalFailureOnFails
()
{
void
DoExpectNoFatalFailureOnFails
()
{
...
@@ -3813,7 +3841,7 @@ void TestEq1(int x) {
...
@@ -3813,7 +3841,7 @@ void TestEq1(int x) {
// Tests calling a test subroutine that's not part of a fixture.
// Tests calling a test subroutine that's not part of a fixture.
TEST
(
AssertionTest
,
NonFixtureSubroutine
)
{
TEST
(
AssertionTest
,
NonFixtureSubroutine
)
{
EXPECT_FATAL_FAILURE
(
TestEq1
(
2
),
EXPECT_FATAL_FAILURE
(
TestEq1
(
2
),
"Which is: 2"
);
"
x
\n
Which is: 2"
);
}
}
// An uncopyable class.
// An uncopyable class.
...
@@ -3952,13 +3980,13 @@ TEST(AssertionTest, AnonymousEnum) {
...
@@ -3952,13 +3980,13 @@ TEST(AssertionTest, AnonymousEnum) {
// ICE's in C++Builder.
// ICE's in C++Builder.
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
kCaseA
,
kCaseB
),
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
kCaseA
,
kCaseB
),
"kCaseB"
);
"
kCaseB
\n
Which is:
"
);
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
kCaseA
,
kCaseC
),
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
kCaseA
,
kCaseC
),
"Which is: 42"
);
"
\n
Which is: 42"
);
# endif
# endif
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
kCaseA
,
kCaseC
),
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
kCaseA
,
kCaseC
),
"Which is: -1"
);
"
\n
Which is: -1"
);
}
}
#endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC)
#endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC)
...
@@ -4426,7 +4454,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) {
...
@@ -4426,7 +4454,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) {
// A failure.
// A failure.
int
n
=
0
;
int
n
=
0
;
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
NULL
,
&
n
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
NULL
,
&
n
),
"&n
\n
"
);
"
&n
\n
Which is:
"
);
}
}
#endif // GTEST_CAN_COMPARE_NULL
#endif // GTEST_CAN_COMPARE_NULL
...
@@ -4442,7 +4470,7 @@ TEST(ExpectTest, EXPECT_EQ_0) {
...
@@ -4442,7 +4470,7 @@ TEST(ExpectTest, EXPECT_EQ_0) {
// A failure.
// A failure.
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
0
,
5.6
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
0
,
5.6
),
"
Expected equality of these values:
\n
0
\n
5.6"
);
" 0
\n
5.6"
);
}
}
// Tests EXPECT_NE.
// Tests EXPECT_NE.
...
@@ -4542,7 +4570,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) {
...
@@ -4542,7 +4570,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) {
TEST
(
ExpectTest
,
ExpectPrecedence
)
{
TEST
(
ExpectTest
,
ExpectPrecedence
)
{
EXPECT_EQ
(
1
<
2
,
true
);
EXPECT_EQ
(
1
<
2
,
true
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
true
,
true
&&
false
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
true
,
true
&&
false
),
"true && false"
);
"
true &&
false
\n
Which is:
false"
);
}
}
...
@@ -4659,7 +4687,7 @@ TEST(MacroTest, ADD_FAILURE_AT) {
...
@@ -4659,7 +4687,7 @@ TEST(MacroTest, ADD_FAILURE_AT) {
// Unfortunately, we cannot verify that the failure message contains
// Unfortunately, we cannot verify that the failure message contains
// the right file path and line number the same way, as
// the right file path and line number the same way, as
// EXPECT_NONFATAL_FAILURE() doesn't get to see the file path and
// EXPECT_NONFATAL_FAILURE() doesn't get to see the file path and
// line number. Instead, we do that in gtest
_
output
_
test_.cc.
// line number. Instead, we do that in g
oogle
test
-
output
-
test_.cc.
}
}
// Tests FAIL.
// Tests FAIL.
...
@@ -4689,14 +4717,14 @@ TEST(EqAssertionTest, Bool) {
...
@@ -4689,14 +4717,14 @@ TEST(EqAssertionTest, Bool) {
EXPECT_FATAL_FAILURE
({
EXPECT_FATAL_FAILURE
({
bool
false_value
=
false
;
bool
false_value
=
false
;
ASSERT_EQ
(
false_value
,
true
);
ASSERT_EQ
(
false_value
,
true
);
},
"Which is: false"
);
},
"
false_value
\n
Which is: false
\n
true
"
);
}
}
// Tests using int values in {EXPECT|ASSERT}_EQ.
// Tests using int values in {EXPECT|ASSERT}_EQ.
TEST
(
EqAssertionTest
,
Int
)
{
TEST
(
EqAssertionTest
,
Int
)
{
ASSERT_EQ
(
32
,
32
);
ASSERT_EQ
(
32
,
32
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
32
,
33
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
32
,
33
),
"33"
);
"
32
\n
33"
);
}
}
// Tests using time_t values in {EXPECT|ASSERT}_EQ.
// Tests using time_t values in {EXPECT|ASSERT}_EQ.
...
@@ -4713,9 +4741,9 @@ TEST(EqAssertionTest, Char) {
...
@@ -4713,9 +4741,9 @@ TEST(EqAssertionTest, Char) {
ASSERT_EQ
(
'z'
,
'z'
);
ASSERT_EQ
(
'z'
,
'z'
);
const
char
ch
=
'b'
;
const
char
ch
=
'b'
;
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
'\0'
,
ch
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
'\0'
,
ch
),
"
ch
"
);
"
ch
\n
Which is: 'b'
"
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
'a'
,
ch
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
'a'
,
ch
),
"
ch
"
);
"
ch
\n
Which is: 'b'
"
);
}
}
// Tests using wchar_t values in {EXPECT|ASSERT}_EQ.
// Tests using wchar_t values in {EXPECT|ASSERT}_EQ.
...
@@ -4735,7 +4763,7 @@ TEST(EqAssertionTest, WideChar) {
...
@@ -4735,7 +4763,7 @@ TEST(EqAssertionTest, WideChar) {
"wchar"
);
"wchar"
);
wchar
=
0x8119
;
wchar
=
0x8119
;
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
static_cast
<
wchar_t
>
(
0x8120
),
wchar
),
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
static_cast
<
wchar_t
>
(
0x8120
),
wchar
),
"wchar"
);
"
wchar
\n
Which is: L'
"
);
}
}
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
...
@@ -4764,8 +4792,7 @@ TEST(EqAssertionTest, StdString) {
...
@@ -4764,8 +4792,7 @@ TEST(EqAssertionTest, StdString) {
static
::
std
::
string
str3
(
str1
);
static
::
std
::
string
str3
(
str1
);
str3
.
at
(
2
)
=
'\0'
;
str3
.
at
(
2
)
=
'\0'
;
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
str1
,
str3
),
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
str1
,
str3
),
" str3
\n
"
" str3
\n
Which is:
\"
A
\\
0 in the middle
\"
"
);
" Which is:
\"
A
\\
0 in the middle
\"
"
);
}
}
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
...
@@ -4885,9 +4912,9 @@ TEST(EqAssertionTest, CharPointer) {
...
@@ -4885,9 +4912,9 @@ TEST(EqAssertionTest, CharPointer) {
ASSERT_EQ
(
p1
,
p1
);
ASSERT_EQ
(
p1
,
p1
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p0
,
p2
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p0
,
p2
),
"
p2
"
);
"
p2
\n
Which is:
"
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p1
,
p2
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p1
,
p2
),
"
p2
"
);
"
p2
\n
Which is:
"
);
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
reinterpret_cast
<
char
*>
(
0x1234
),
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
reinterpret_cast
<
char
*>
(
0x1234
),
reinterpret_cast
<
char
*>
(
0xABC0
)),
reinterpret_cast
<
char
*>
(
0xABC0
)),
"ABC0"
);
"ABC0"
);
...
@@ -4907,9 +4934,9 @@ TEST(EqAssertionTest, WideCharPointer) {
...
@@ -4907,9 +4934,9 @@ TEST(EqAssertionTest, WideCharPointer) {
EXPECT_EQ
(
p0
,
p0
);
EXPECT_EQ
(
p0
,
p0
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p0
,
p2
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p0
,
p2
),
"
p2
"
);
"
p2
\n
Which is:
"
);
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p1
,
p2
),
EXPECT_NONFATAL_FAILURE
(
EXPECT_EQ
(
p1
,
p2
),
"
p2
"
);
"
p2
\n
Which is:
"
);
void
*
pv3
=
(
void
*
)
0x1234
;
// NOLINT
void
*
pv3
=
(
void
*
)
0x1234
;
// NOLINT
void
*
pv4
=
(
void
*
)
0xABC0
;
// NOLINT
void
*
pv4
=
(
void
*
)
0xABC0
;
// NOLINT
const
wchar_t
*
p3
=
reinterpret_cast
<
const
wchar_t
*>
(
pv3
);
const
wchar_t
*
p3
=
reinterpret_cast
<
const
wchar_t
*>
(
pv3
);
...
@@ -5454,7 +5481,8 @@ TEST_F(SetUpTestCaseTest, Test2) {
...
@@ -5454,7 +5481,8 @@ TEST_F(SetUpTestCaseTest, Test2) {
EXPECT_STREQ
(
"123"
,
shared_resource_
);
EXPECT_STREQ
(
"123"
,
shared_resource_
);
}
}
// The InitGoogleTestTest test case tests testing::InitGoogleTest().
// The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly.
// The Flags struct stores a copy of all Google Test flags.
// The Flags struct stores a copy of all Google Test flags.
struct
Flags
{
struct
Flags
{
...
@@ -5540,8 +5568,8 @@ struct Flags {
...
@@ -5540,8 +5568,8 @@ struct Flags {
return
flags
;
return
flags
;
}
}
// Creates a Flags struct where the gtest_random_seed flag has
// Creates a Flags struct where the gtest_random_seed flag has
the given
//
the given
value.
// value.
static
Flags
RandomSeed
(
Int32
random_seed
)
{
static
Flags
RandomSeed
(
Int32
random_seed
)
{
Flags
flags
;
Flags
flags
;
flags
.
random_seed
=
random_seed
;
flags
.
random_seed
=
random_seed
;
...
@@ -5556,8 +5584,8 @@ struct Flags {
...
@@ -5556,8 +5584,8 @@ struct Flags {
return
flags
;
return
flags
;
}
}
// Creates a Flags struct where the gtest_shuffle flag has
// Creates a Flags struct where the gtest_shuffle flag has
the given
//
the given
value.
// value.
static
Flags
Shuffle
(
bool
shuffle
)
{
static
Flags
Shuffle
(
bool
shuffle
)
{
Flags
flags
;
Flags
flags
;
flags
.
shuffle
=
shuffle
;
flags
.
shuffle
=
shuffle
;
...
@@ -5605,8 +5633,8 @@ struct Flags {
...
@@ -5605,8 +5633,8 @@ struct Flags {
bool
throw_on_failure
;
bool
throw_on_failure
;
};
};
// Fixture for testing
Init
GoogleTest().
// Fixture for testing
Parse
GoogleTest
FlagsOnly
().
class
InitGoogleTest
Test
:
public
Test
{
class
ParseFlags
Test
:
public
Test
{
protected:
protected:
// Clears the flags before each test.
// Clears the flags before each test.
virtual
void
SetUp
()
{
virtual
void
SetUp
()
{
...
@@ -5667,16 +5695,16 @@ class InitGoogleTestTest : public Test {
...
@@ -5667,16 +5695,16 @@ class InitGoogleTestTest : public Test {
const
bool
saved_help_flag
=
::
testing
::
internal
::
g_help_flag
;
const
bool
saved_help_flag
=
::
testing
::
internal
::
g_help_flag
;
::
testing
::
internal
::
g_help_flag
=
false
;
::
testing
::
internal
::
g_help_flag
=
false
;
#if GTEST_HAS_STREAM_REDIRECTION
#
if GTEST_HAS_STREAM_REDIRECTION
CaptureStdout
();
CaptureStdout
();
#endif
#
endif
// Parses the command line.
// Parses the command line.
internal
::
ParseGoogleTestFlagsOnly
(
&
argc1
,
const_cast
<
CharType
**>
(
argv1
));
internal
::
ParseGoogleTestFlagsOnly
(
&
argc1
,
const_cast
<
CharType
**>
(
argv1
));
#if GTEST_HAS_STREAM_REDIRECTION
#
if GTEST_HAS_STREAM_REDIRECTION
const
std
::
string
captured_stdout
=
GetCapturedStdout
();
const
std
::
string
captured_stdout
=
GetCapturedStdout
();
#endif
#
endif
// Verifies the flag values.
// Verifies the flag values.
CheckFlags
(
expected
);
CheckFlags
(
expected
);
...
@@ -5689,7 +5717,7 @@ class InitGoogleTestTest : public Test {
...
@@ -5689,7 +5717,7 @@ class InitGoogleTestTest : public Test {
// help message for the flags it recognizes.
// help message for the flags it recognizes.
EXPECT_EQ
(
should_print_help
,
::
testing
::
internal
::
g_help_flag
);
EXPECT_EQ
(
should_print_help
,
::
testing
::
internal
::
g_help_flag
);
#if GTEST_HAS_STREAM_REDIRECTION
#
if GTEST_HAS_STREAM_REDIRECTION
const
char
*
const
expected_help_fragment
=
const
char
*
const
expected_help_fragment
=
"This program contains tests written using"
;
"This program contains tests written using"
;
if
(
should_print_help
)
{
if
(
should_print_help
)
{
...
@@ -5698,7 +5726,7 @@ class InitGoogleTestTest : public Test {
...
@@ -5698,7 +5726,7 @@ class InitGoogleTestTest : public Test {
EXPECT_PRED_FORMAT2
(
IsNotSubstring
,
EXPECT_PRED_FORMAT2
(
IsNotSubstring
,
expected_help_fragment
,
captured_stdout
);
expected_help_fragment
,
captured_stdout
);
}
}
#endif // GTEST_HAS_STREAM_REDIRECTION
#
endif // GTEST_HAS_STREAM_REDIRECTION
::
testing
::
internal
::
g_help_flag
=
saved_help_flag
;
::
testing
::
internal
::
g_help_flag
=
saved_help_flag
;
}
}
...
@@ -5706,14 +5734,14 @@ class InitGoogleTestTest : public Test {
...
@@ -5706,14 +5734,14 @@ class InitGoogleTestTest : public Test {
// This macro wraps TestParsingFlags s.t. the user doesn't need
// This macro wraps TestParsingFlags s.t. the user doesn't need
// to specify the array sizes.
// to specify the array sizes.
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
#
define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
expected, should_print_help)
expected, should_print_help)
};
};
// Tests parsing an empty command line.
// Tests parsing an empty command line.
TEST_F
(
InitGoogleTest
Test
,
Empty
)
{
TEST_F
(
ParseFlags
Test
,
Empty
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
NULL
NULL
};
};
...
@@ -5726,7 +5754,7 @@ TEST_F(InitGoogleTestTest, Empty) {
...
@@ -5726,7 +5754,7 @@ TEST_F(InitGoogleTestTest, Empty) {
}
}
// Tests parsing a command line that has no flag.
// Tests parsing a command line that has no flag.
TEST_F
(
InitGoogleTest
Test
,
NoFlag
)
{
TEST_F
(
ParseFlags
Test
,
NoFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
NULL
NULL
...
@@ -5741,7 +5769,7 @@ TEST_F(InitGoogleTestTest, NoFlag) {
...
@@ -5741,7 +5769,7 @@ TEST_F(InitGoogleTestTest, NoFlag) {
}
}
// Tests parsing a bad --gtest_filter flag.
// Tests parsing a bad --gtest_filter flag.
TEST_F
(
InitGoogleTest
Test
,
FilterBad
)
{
TEST_F
(
ParseFlags
Test
,
FilterBad
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_filter"
,
"--gtest_filter"
,
...
@@ -5758,7 +5786,7 @@ TEST_F(InitGoogleTestTest, FilterBad) {
...
@@ -5758,7 +5786,7 @@ TEST_F(InitGoogleTestTest, FilterBad) {
}
}
// Tests parsing an empty --gtest_filter flag.
// Tests parsing an empty --gtest_filter flag.
TEST_F
(
InitGoogleTest
Test
,
FilterEmpty
)
{
TEST_F
(
ParseFlags
Test
,
FilterEmpty
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_filter="
,
"--gtest_filter="
,
...
@@ -5774,7 +5802,7 @@ TEST_F(InitGoogleTestTest, FilterEmpty) {
...
@@ -5774,7 +5802,7 @@ TEST_F(InitGoogleTestTest, FilterEmpty) {
}
}
// Tests parsing a non-empty --gtest_filter flag.
// Tests parsing a non-empty --gtest_filter flag.
TEST_F
(
InitGoogleTest
Test
,
FilterNonEmpty
)
{
TEST_F
(
ParseFlags
Test
,
FilterNonEmpty
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_filter=abc"
,
"--gtest_filter=abc"
,
...
@@ -5790,7 +5818,7 @@ TEST_F(InitGoogleTestTest, FilterNonEmpty) {
...
@@ -5790,7 +5818,7 @@ TEST_F(InitGoogleTestTest, FilterNonEmpty) {
}
}
// Tests parsing --gtest_break_on_failure.
// Tests parsing --gtest_break_on_failure.
TEST_F
(
InitGoogleTest
Test
,
BreakOnFailureWithoutValue
)
{
TEST_F
(
ParseFlags
Test
,
BreakOnFailureWithoutValue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_break_on_failure"
,
"--gtest_break_on_failure"
,
...
@@ -5806,7 +5834,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) {
...
@@ -5806,7 +5834,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) {
}
}
// Tests parsing --gtest_break_on_failure=0.
// Tests parsing --gtest_break_on_failure=0.
TEST_F
(
InitGoogleTest
Test
,
BreakOnFailureFalse_0
)
{
TEST_F
(
ParseFlags
Test
,
BreakOnFailureFalse_0
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_break_on_failure=0"
,
"--gtest_break_on_failure=0"
,
...
@@ -5822,7 +5850,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) {
...
@@ -5822,7 +5850,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) {
}
}
// Tests parsing --gtest_break_on_failure=f.
// Tests parsing --gtest_break_on_failure=f.
TEST_F
(
InitGoogleTest
Test
,
BreakOnFailureFalse_f
)
{
TEST_F
(
ParseFlags
Test
,
BreakOnFailureFalse_f
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_break_on_failure=f"
,
"--gtest_break_on_failure=f"
,
...
@@ -5838,7 +5866,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) {
...
@@ -5838,7 +5866,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) {
}
}
// Tests parsing --gtest_break_on_failure=F.
// Tests parsing --gtest_break_on_failure=F.
TEST_F
(
InitGoogleTest
Test
,
BreakOnFailureFalse_F
)
{
TEST_F
(
ParseFlags
Test
,
BreakOnFailureFalse_F
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_break_on_failure=F"
,
"--gtest_break_on_failure=F"
,
...
@@ -5855,7 +5883,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) {
...
@@ -5855,7 +5883,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) {
// Tests parsing a --gtest_break_on_failure flag that has a "true"
// Tests parsing a --gtest_break_on_failure flag that has a "true"
// definition.
// definition.
TEST_F
(
InitGoogleTest
Test
,
BreakOnFailureTrue
)
{
TEST_F
(
ParseFlags
Test
,
BreakOnFailureTrue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_break_on_failure=1"
,
"--gtest_break_on_failure=1"
,
...
@@ -5871,7 +5899,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureTrue) {
...
@@ -5871,7 +5899,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureTrue) {
}
}
// Tests parsing --gtest_catch_exceptions.
// Tests parsing --gtest_catch_exceptions.
TEST_F
(
InitGoogleTest
Test
,
CatchExceptions
)
{
TEST_F
(
ParseFlags
Test
,
CatchExceptions
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_catch_exceptions"
,
"--gtest_catch_exceptions"
,
...
@@ -5887,7 +5915,7 @@ TEST_F(InitGoogleTestTest, CatchExceptions) {
...
@@ -5887,7 +5915,7 @@ TEST_F(InitGoogleTestTest, CatchExceptions) {
}
}
// Tests parsing --gtest_death_test_use_fork.
// Tests parsing --gtest_death_test_use_fork.
TEST_F
(
InitGoogleTest
Test
,
DeathTestUseFork
)
{
TEST_F
(
ParseFlags
Test
,
DeathTestUseFork
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_death_test_use_fork"
,
"--gtest_death_test_use_fork"
,
...
@@ -5904,7 +5932,7 @@ TEST_F(InitGoogleTestTest, DeathTestUseFork) {
...
@@ -5904,7 +5932,7 @@ TEST_F(InitGoogleTestTest, DeathTestUseFork) {
// Tests having the same flag twice with different values. The
// Tests having the same flag twice with different values. The
// expected behavior is that the one coming last takes precedence.
// expected behavior is that the one coming last takes precedence.
TEST_F
(
InitGoogleTest
Test
,
DuplicatedFlags
)
{
TEST_F
(
ParseFlags
Test
,
DuplicatedFlags
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_filter=a"
,
"--gtest_filter=a"
,
...
@@ -5921,7 +5949,7 @@ TEST_F(InitGoogleTestTest, DuplicatedFlags) {
...
@@ -5921,7 +5949,7 @@ TEST_F(InitGoogleTestTest, DuplicatedFlags) {
}
}
// Tests having an unrecognized flag on the command line.
// Tests having an unrecognized flag on the command line.
TEST_F
(
InitGoogleTest
Test
,
UnrecognizedFlag
)
{
TEST_F
(
ParseFlags
Test
,
UnrecognizedFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_break_on_failure"
,
"--gtest_break_on_failure"
,
...
@@ -5943,7 +5971,7 @@ TEST_F(InitGoogleTestTest, UnrecognizedFlag) {
...
@@ -5943,7 +5971,7 @@ TEST_F(InitGoogleTestTest, UnrecognizedFlag) {
}
}
// Tests having a --gtest_list_tests flag
// Tests having a --gtest_list_tests flag
TEST_F
(
InitGoogleTest
Test
,
ListTestsFlag
)
{
TEST_F
(
ParseFlags
Test
,
ListTestsFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_list_tests"
,
"--gtest_list_tests"
,
...
@@ -5959,7 +5987,7 @@ TEST_F(InitGoogleTestTest, ListTestsFlag) {
...
@@ -5959,7 +5987,7 @@ TEST_F(InitGoogleTestTest, ListTestsFlag) {
}
}
// Tests having a --gtest_list_tests flag with a "true" value
// Tests having a --gtest_list_tests flag with a "true" value
TEST_F
(
InitGoogleTest
Test
,
ListTestsTrue
)
{
TEST_F
(
ParseFlags
Test
,
ListTestsTrue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_list_tests=1"
,
"--gtest_list_tests=1"
,
...
@@ -5975,7 +6003,7 @@ TEST_F(InitGoogleTestTest, ListTestsTrue) {
...
@@ -5975,7 +6003,7 @@ TEST_F(InitGoogleTestTest, ListTestsTrue) {
}
}
// Tests having a --gtest_list_tests flag with a "false" value
// Tests having a --gtest_list_tests flag with a "false" value
TEST_F
(
InitGoogleTest
Test
,
ListTestsFalse
)
{
TEST_F
(
ParseFlags
Test
,
ListTestsFalse
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_list_tests=0"
,
"--gtest_list_tests=0"
,
...
@@ -5991,7 +6019,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse) {
...
@@ -5991,7 +6019,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse) {
}
}
// Tests parsing --gtest_list_tests=f.
// Tests parsing --gtest_list_tests=f.
TEST_F
(
InitGoogleTest
Test
,
ListTestsFalse_f
)
{
TEST_F
(
ParseFlags
Test
,
ListTestsFalse_f
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_list_tests=f"
,
"--gtest_list_tests=f"
,
...
@@ -6007,7 +6035,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_f) {
...
@@ -6007,7 +6035,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_f) {
}
}
// Tests parsing --gtest_list_tests=F.
// Tests parsing --gtest_list_tests=F.
TEST_F
(
InitGoogleTest
Test
,
ListTestsFalse_F
)
{
TEST_F
(
ParseFlags
Test
,
ListTestsFalse_F
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_list_tests=F"
,
"--gtest_list_tests=F"
,
...
@@ -6023,7 +6051,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_F) {
...
@@ -6023,7 +6051,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_F) {
}
}
// Tests parsing --gtest_output (invalid).
// Tests parsing --gtest_output (invalid).
TEST_F
(
InitGoogleTest
Test
,
OutputEmpty
)
{
TEST_F
(
ParseFlags
Test
,
OutputEmpty
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_output"
,
"--gtest_output"
,
...
@@ -6040,7 +6068,7 @@ TEST_F(InitGoogleTestTest, OutputEmpty) {
...
@@ -6040,7 +6068,7 @@ TEST_F(InitGoogleTestTest, OutputEmpty) {
}
}
// Tests parsing --gtest_output=xml
// Tests parsing --gtest_output=xml
TEST_F
(
InitGoogleTest
Test
,
OutputXml
)
{
TEST_F
(
ParseFlags
Test
,
OutputXml
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_output=xml"
,
"--gtest_output=xml"
,
...
@@ -6056,7 +6084,7 @@ TEST_F(InitGoogleTestTest, OutputXml) {
...
@@ -6056,7 +6084,7 @@ TEST_F(InitGoogleTestTest, OutputXml) {
}
}
// Tests parsing --gtest_output=xml:file
// Tests parsing --gtest_output=xml:file
TEST_F
(
InitGoogleTest
Test
,
OutputXmlFile
)
{
TEST_F
(
ParseFlags
Test
,
OutputXmlFile
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_output=xml:file"
,
"--gtest_output=xml:file"
,
...
@@ -6072,7 +6100,7 @@ TEST_F(InitGoogleTestTest, OutputXmlFile) {
...
@@ -6072,7 +6100,7 @@ TEST_F(InitGoogleTestTest, OutputXmlFile) {
}
}
// Tests parsing --gtest_output=xml:directory/path/
// Tests parsing --gtest_output=xml:directory/path/
TEST_F
(
InitGoogleTest
Test
,
OutputXmlDirectory
)
{
TEST_F
(
ParseFlags
Test
,
OutputXmlDirectory
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_output=xml:directory/path/"
,
"--gtest_output=xml:directory/path/"
,
...
@@ -6089,7 +6117,7 @@ TEST_F(InitGoogleTestTest, OutputXmlDirectory) {
...
@@ -6089,7 +6117,7 @@ TEST_F(InitGoogleTestTest, OutputXmlDirectory) {
}
}
// Tests having a --gtest_print_time flag
// Tests having a --gtest_print_time flag
TEST_F
(
InitGoogleTest
Test
,
PrintTimeFlag
)
{
TEST_F
(
ParseFlags
Test
,
PrintTimeFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_print_time"
,
"--gtest_print_time"
,
...
@@ -6105,7 +6133,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFlag) {
...
@@ -6105,7 +6133,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFlag) {
}
}
// Tests having a --gtest_print_time flag with a "true" value
// Tests having a --gtest_print_time flag with a "true" value
TEST_F
(
InitGoogleTest
Test
,
PrintTimeTrue
)
{
TEST_F
(
ParseFlags
Test
,
PrintTimeTrue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_print_time=1"
,
"--gtest_print_time=1"
,
...
@@ -6121,7 +6149,7 @@ TEST_F(InitGoogleTestTest, PrintTimeTrue) {
...
@@ -6121,7 +6149,7 @@ TEST_F(InitGoogleTestTest, PrintTimeTrue) {
}
}
// Tests having a --gtest_print_time flag with a "false" value
// Tests having a --gtest_print_time flag with a "false" value
TEST_F
(
InitGoogleTest
Test
,
PrintTimeFalse
)
{
TEST_F
(
ParseFlags
Test
,
PrintTimeFalse
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_print_time=0"
,
"--gtest_print_time=0"
,
...
@@ -6137,7 +6165,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse) {
...
@@ -6137,7 +6165,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse) {
}
}
// Tests parsing --gtest_print_time=f.
// Tests parsing --gtest_print_time=f.
TEST_F
(
InitGoogleTest
Test
,
PrintTimeFalse_f
)
{
TEST_F
(
ParseFlags
Test
,
PrintTimeFalse_f
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_print_time=f"
,
"--gtest_print_time=f"
,
...
@@ -6153,7 +6181,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_f) {
...
@@ -6153,7 +6181,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_f) {
}
}
// Tests parsing --gtest_print_time=F.
// Tests parsing --gtest_print_time=F.
TEST_F
(
InitGoogleTest
Test
,
PrintTimeFalse_F
)
{
TEST_F
(
ParseFlags
Test
,
PrintTimeFalse_F
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_print_time=F"
,
"--gtest_print_time=F"
,
...
@@ -6169,7 +6197,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_F) {
...
@@ -6169,7 +6197,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_F) {
}
}
// Tests parsing --gtest_random_seed=number
// Tests parsing --gtest_random_seed=number
TEST_F
(
InitGoogleTest
Test
,
RandomSeed
)
{
TEST_F
(
ParseFlags
Test
,
RandomSeed
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_random_seed=1000"
,
"--gtest_random_seed=1000"
,
...
@@ -6185,7 +6213,7 @@ TEST_F(InitGoogleTestTest, RandomSeed) {
...
@@ -6185,7 +6213,7 @@ TEST_F(InitGoogleTestTest, RandomSeed) {
}
}
// Tests parsing --gtest_repeat=number
// Tests parsing --gtest_repeat=number
TEST_F
(
InitGoogleTest
Test
,
Repeat
)
{
TEST_F
(
ParseFlags
Test
,
Repeat
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_repeat=1000"
,
"--gtest_repeat=1000"
,
...
@@ -6201,7 +6229,7 @@ TEST_F(InitGoogleTestTest, Repeat) {
...
@@ -6201,7 +6229,7 @@ TEST_F(InitGoogleTestTest, Repeat) {
}
}
// Tests having a --gtest_also_run_disabled_tests flag
// Tests having a --gtest_also_run_disabled_tests flag
TEST_F
(
InitGoogleTest
Test
,
AlsoRunDisabledTestsFlag
)
{
TEST_F
(
ParseFlags
Test
,
AlsoRunDisabledTestsFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_also_run_disabled_tests"
,
"--gtest_also_run_disabled_tests"
,
...
@@ -6218,7 +6246,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) {
...
@@ -6218,7 +6246,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) {
}
}
// Tests having a --gtest_also_run_disabled_tests flag with a "true" value
// Tests having a --gtest_also_run_disabled_tests flag with a "true" value
TEST_F
(
InitGoogleTest
Test
,
AlsoRunDisabledTestsTrue
)
{
TEST_F
(
ParseFlags
Test
,
AlsoRunDisabledTestsTrue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_also_run_disabled_tests=1"
,
"--gtest_also_run_disabled_tests=1"
,
...
@@ -6235,7 +6263,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) {
...
@@ -6235,7 +6263,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) {
}
}
// Tests having a --gtest_also_run_disabled_tests flag with a "false" value
// Tests having a --gtest_also_run_disabled_tests flag with a "false" value
TEST_F
(
InitGoogleTest
Test
,
AlsoRunDisabledTestsFalse
)
{
TEST_F
(
ParseFlags
Test
,
AlsoRunDisabledTestsFalse
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_also_run_disabled_tests=0"
,
"--gtest_also_run_disabled_tests=0"
,
...
@@ -6252,7 +6280,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) {
...
@@ -6252,7 +6280,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) {
}
}
// Tests parsing --gtest_shuffle.
// Tests parsing --gtest_shuffle.
TEST_F
(
InitGoogleTest
Test
,
ShuffleWithoutValue
)
{
TEST_F
(
ParseFlags
Test
,
ShuffleWithoutValue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_shuffle"
,
"--gtest_shuffle"
,
...
@@ -6268,7 +6296,7 @@ TEST_F(InitGoogleTestTest, ShuffleWithoutValue) {
...
@@ -6268,7 +6296,7 @@ TEST_F(InitGoogleTestTest, ShuffleWithoutValue) {
}
}
// Tests parsing --gtest_shuffle=0.
// Tests parsing --gtest_shuffle=0.
TEST_F
(
InitGoogleTest
Test
,
ShuffleFalse_0
)
{
TEST_F
(
ParseFlags
Test
,
ShuffleFalse_0
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_shuffle=0"
,
"--gtest_shuffle=0"
,
...
@@ -6283,9 +6311,8 @@ TEST_F(InitGoogleTestTest, ShuffleFalse_0) {
...
@@ -6283,9 +6311,8 @@ TEST_F(InitGoogleTestTest, ShuffleFalse_0) {
GTEST_TEST_PARSING_FLAGS_
(
argv
,
argv2
,
Flags
::
Shuffle
(
false
),
false
);
GTEST_TEST_PARSING_FLAGS_
(
argv
,
argv2
,
Flags
::
Shuffle
(
false
),
false
);
}
}
// Tests parsing a --gtest_shuffle flag that has a "true"
// Tests parsing a --gtest_shuffle flag that has a "true" definition.
// definition.
TEST_F
(
ParseFlagsTest
,
ShuffleTrue
)
{
TEST_F
(
InitGoogleTestTest
,
ShuffleTrue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_shuffle=1"
,
"--gtest_shuffle=1"
,
...
@@ -6301,7 +6328,7 @@ TEST_F(InitGoogleTestTest, ShuffleTrue) {
...
@@ -6301,7 +6328,7 @@ TEST_F(InitGoogleTestTest, ShuffleTrue) {
}
}
// Tests parsing --gtest_stack_trace_depth=number.
// Tests parsing --gtest_stack_trace_depth=number.
TEST_F
(
InitGoogleTest
Test
,
StackTraceDepth
)
{
TEST_F
(
ParseFlags
Test
,
StackTraceDepth
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_stack_trace_depth=5"
,
"--gtest_stack_trace_depth=5"
,
...
@@ -6316,7 +6343,7 @@ TEST_F(InitGoogleTestTest, StackTraceDepth) {
...
@@ -6316,7 +6343,7 @@ TEST_F(InitGoogleTestTest, StackTraceDepth) {
GTEST_TEST_PARSING_FLAGS_
(
argv
,
argv2
,
Flags
::
StackTraceDepth
(
5
),
false
);
GTEST_TEST_PARSING_FLAGS_
(
argv
,
argv2
,
Flags
::
StackTraceDepth
(
5
),
false
);
}
}
TEST_F
(
InitGoogleTest
Test
,
StreamResultTo
)
{
TEST_F
(
ParseFlags
Test
,
StreamResultTo
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_stream_result_to=localhost:1234"
,
"--gtest_stream_result_to=localhost:1234"
,
...
@@ -6333,7 +6360,7 @@ TEST_F(InitGoogleTestTest, StreamResultTo) {
...
@@ -6333,7 +6360,7 @@ TEST_F(InitGoogleTestTest, StreamResultTo) {
}
}
// Tests parsing --gtest_throw_on_failure.
// Tests parsing --gtest_throw_on_failure.
TEST_F
(
InitGoogleTest
Test
,
ThrowOnFailureWithoutValue
)
{
TEST_F
(
ParseFlags
Test
,
ThrowOnFailureWithoutValue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_throw_on_failure"
,
"--gtest_throw_on_failure"
,
...
@@ -6349,7 +6376,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) {
...
@@ -6349,7 +6376,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) {
}
}
// Tests parsing --gtest_throw_on_failure=0.
// Tests parsing --gtest_throw_on_failure=0.
TEST_F
(
InitGoogleTest
Test
,
ThrowOnFailureFalse_0
)
{
TEST_F
(
ParseFlags
Test
,
ThrowOnFailureFalse_0
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_throw_on_failure=0"
,
"--gtest_throw_on_failure=0"
,
...
@@ -6366,7 +6393,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) {
...
@@ -6366,7 +6393,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) {
// Tests parsing a --gtest_throw_on_failure flag that has a "true"
// Tests parsing a --gtest_throw_on_failure flag that has a "true"
// definition.
// definition.
TEST_F
(
InitGoogleTest
Test
,
ThrowOnFailureTrue
)
{
TEST_F
(
ParseFlags
Test
,
ThrowOnFailureTrue
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"foo.exe"
,
"--gtest_throw_on_failure=1"
,
"--gtest_throw_on_failure=1"
,
...
@@ -6381,9 +6408,9 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureTrue) {
...
@@ -6381,9 +6408,9 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureTrue) {
GTEST_TEST_PARSING_FLAGS_
(
argv
,
argv2
,
Flags
::
ThrowOnFailure
(
true
),
false
);
GTEST_TEST_PARSING_FLAGS_
(
argv
,
argv2
,
Flags
::
ThrowOnFailure
(
true
),
false
);
}
}
#if GTEST_OS_WINDOWS
#
if GTEST_OS_WINDOWS
// Tests parsing wide strings.
// Tests parsing wide strings.
TEST_F
(
InitGoogleTest
Test
,
WideStrings
)
{
TEST_F
(
ParseFlags
Test
,
WideStrings
)
{
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
L"foo.exe"
,
L"foo.exe"
,
L"--gtest_filter=Foo*"
,
L"--gtest_filter=Foo*"
,
...
@@ -6409,10 +6436,10 @@ TEST_F(InitGoogleTestTest, WideStrings) {
...
@@ -6409,10 +6436,10 @@ TEST_F(InitGoogleTestTest, WideStrings) {
# endif // GTEST_OS_WINDOWS
# endif // GTEST_OS_WINDOWS
#if GTEST_USE_OWN_FLAGFILE_FLAG_
#if GTEST_USE_OWN_FLAGFILE_FLAG_
class
FlagfileTest
:
public
InitGoogleTest
Test
{
class
FlagfileTest
:
public
ParseFlags
Test
{
public:
public:
virtual
void
SetUp
()
{
virtual
void
SetUp
()
{
InitGoogleTest
Test
::
SetUp
();
ParseFlags
Test
::
SetUp
();
testdata_path_
.
Set
(
internal
::
FilePath
(
testdata_path_
.
Set
(
internal
::
FilePath
(
testing
::
TempDir
()
+
internal
::
GetCurrentExecutableName
().
string
()
+
testing
::
TempDir
()
+
internal
::
GetCurrentExecutableName
().
string
()
+
...
@@ -6423,7 +6450,7 @@ class FlagfileTest : public InitGoogleTestTest {
...
@@ -6423,7 +6450,7 @@ class FlagfileTest : public InitGoogleTestTest {
virtual
void
TearDown
()
{
virtual
void
TearDown
()
{
testing
::
internal
::
posix
::
RmDir
(
testdata_path_
.
c_str
());
testing
::
internal
::
posix
::
RmDir
(
testdata_path_
.
c_str
());
InitGoogleTest
Test
::
TearDown
();
ParseFlags
Test
::
TearDown
();
}
}
internal
::
FilePath
CreateFlagfile
(
const
char
*
contents
)
{
internal
::
FilePath
CreateFlagfile
(
const
char
*
contents
)
{
...
@@ -6562,6 +6589,7 @@ TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) {
...
@@ -6562,6 +6589,7 @@ TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) {
}
// namespace testing
}
// namespace testing
// These two lines test that we can define tests in a namespace that
// These two lines test that we can define tests in a namespace that
// has the name "testing" and is nested in another namespace.
// has the name "testing" and is nested in another namespace.
namespace
my_namespace
{
namespace
my_namespace
{
...
@@ -6892,14 +6920,6 @@ TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {
...
@@ -6892,14 +6920,6 @@ TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {
StaticAssertTypeEq
<
int
*
,
IntAlias
*>
();
StaticAssertTypeEq
<
int
*
,
IntAlias
*>
();
}
}
TEST
(
GetCurrentOsStackTraceExceptTopTest
,
ReturnsTheStackTrace
)
{
testing
::
UnitTest
*
const
unit_test
=
testing
::
UnitTest
::
GetInstance
();
// We don't have a stack walker in Google Test yet.
EXPECT_STREQ
(
""
,
GetCurrentOsStackTraceExceptTop
(
unit_test
,
0
).
c_str
());
EXPECT_STREQ
(
""
,
GetCurrentOsStackTraceExceptTop
(
unit_test
,
1
).
c_str
());
}
TEST
(
HasNonfatalFailureTest
,
ReturnsFalseWhenThereIsNoFailure
)
{
TEST
(
HasNonfatalFailureTest
,
ReturnsFalseWhenThereIsNoFailure
)
{
EXPECT_FALSE
(
HasNonfatalFailure
());
EXPECT_FALSE
(
HasNonfatalFailure
());
}
}
...
@@ -7351,7 +7371,7 @@ GTEST_TEST(AlternativeNameTest, Works) { // GTEST_TEST is the same as TEST.
...
@@ -7351,7 +7371,7 @@ GTEST_TEST(AlternativeNameTest, Works) { // GTEST_TEST is the same as TEST.
// Tests for internal utilities necessary for implementation of the universal
// Tests for internal utilities necessary for implementation of the universal
// printing.
// printing.
//
TODO(vladl@google.com)
: Find a better home for them.
//
FIXME
: Find a better home for them.
class
ConversionHelperBase
{};
class
ConversionHelperBase
{};
class
ConversionHelperDerived
:
public
ConversionHelperBase
{};
class
ConversionHelperDerived
:
public
ConversionHelperBase
{};
...
@@ -7535,6 +7555,50 @@ TEST(IsContainerTestTest, WorksForContainer) {
...
@@ -7535,6 +7555,50 @@ TEST(IsContainerTestTest, WorksForContainer) {
sizeof
(
IsContainerTest
<
std
::
map
<
int
,
double
>
>
(
0
)));
sizeof
(
IsContainerTest
<
std
::
map
<
int
,
double
>
>
(
0
)));
}
}
#if GTEST_LANG_CXX11
struct
ConstOnlyContainerWithPointerIterator
{
using
const_iterator
=
int
*
;
const_iterator
begin
()
const
;
const_iterator
end
()
const
;
};
struct
ConstOnlyContainerWithClassIterator
{
struct
const_iterator
{
const
int
&
operator
*
()
const
;
const_iterator
&
operator
++
(
/* pre-increment */
);
};
const_iterator
begin
()
const
;
const_iterator
end
()
const
;
};
TEST
(
IsContainerTestTest
,
ConstOnlyContainer
)
{
EXPECT_EQ
(
sizeof
(
IsContainer
),
sizeof
(
IsContainerTest
<
ConstOnlyContainerWithPointerIterator
>
(
0
)));
EXPECT_EQ
(
sizeof
(
IsContainer
),
sizeof
(
IsContainerTest
<
ConstOnlyContainerWithClassIterator
>
(
0
)));
}
#endif // GTEST_LANG_CXX11
// Tests IsHashTable.
struct
AHashTable
{
typedef
void
hasher
;
};
struct
NotReallyAHashTable
{
typedef
void
hasher
;
typedef
void
reverse_iterator
;
};
TEST
(
IsHashTable
,
Basic
)
{
EXPECT_TRUE
(
testing
::
internal
::
IsHashTable
<
AHashTable
>::
value
);
EXPECT_FALSE
(
testing
::
internal
::
IsHashTable
<
NotReallyAHashTable
>::
value
);
#if GTEST_LANG_CXX11
EXPECT_FALSE
(
testing
::
internal
::
IsHashTable
<
std
::
vector
<
int
>>::
value
);
EXPECT_TRUE
(
testing
::
internal
::
IsHashTable
<
std
::
unordered_set
<
int
>>::
value
);
#endif // GTEST_LANG_CXX11
#if GTEST_HAS_HASH_SET_
EXPECT_TRUE
(
testing
::
internal
::
IsHashTable
<
__gnu_cxx
::
hash_set
<
int
>>::
value
);
#endif // GTEST_HAS_HASH_SET_
}
// Tests ArrayEq().
// Tests ArrayEq().
TEST
(
ArrayEqTest
,
WorksForDegeneratedArrays
)
{
TEST
(
ArrayEqTest
,
WorksForDegeneratedArrays
)
{
...
@@ -7659,7 +7723,7 @@ TEST(NativeArrayTest, MethodsWork) {
...
@@ -7659,7 +7723,7 @@ TEST(NativeArrayTest, MethodsWork) {
EXPECT_EQ
(
0
,
*
it
);
EXPECT_EQ
(
0
,
*
it
);
++
it
;
++
it
;
EXPECT_EQ
(
1
,
*
it
);
EXPECT_EQ
(
1
,
*
it
);
++
it
;
it
++
;
EXPECT_EQ
(
2
,
*
it
);
EXPECT_EQ
(
2
,
*
it
);
++
it
;
++
it
;
EXPECT_EQ
(
na
.
end
(),
it
);
EXPECT_EQ
(
na
.
end
(),
it
);
...
@@ -7707,3 +7771,25 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
...
@@ -7707,3 +7771,25 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
EXPECT_FALSE
(
SkipPrefix
(
"world!"
,
&
p
));
EXPECT_FALSE
(
SkipPrefix
(
"world!"
,
&
p
));
EXPECT_EQ
(
str
,
p
);
EXPECT_EQ
(
str
,
p
);
}
}
// Tests ad_hoc_test_result().
class
AdHocTestResultTest
:
public
testing
::
Test
{
protected:
static
void
SetUpTestCase
()
{
FAIL
()
<<
"A failure happened inside SetUpTestCase()."
;
}
};
TEST_F
(
AdHocTestResultTest
,
AdHocTestResultForTestCaseShowsFailure
)
{
const
testing
::
TestResult
&
test_result
=
testing
::
UnitTest
::
GetInstance
()
->
current_test_case
()
->
ad_hoc_test_result
();
EXPECT_TRUE
(
test_result
.
Failed
());
}
TEST_F
(
AdHocTestResultTest
,
AdHocTestResultTestForUnitTestDoesNotShowFailure
)
{
const
testing
::
TestResult
&
test_result
=
testing
::
UnitTest
::
GetInstance
()
->
ad_hoc_test_result
();
EXPECT_FALSE
(
test_result
.
Failed
());
}
googletest/test/gtest_xml_outfile1_test_.cc
View file @
687964c8
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
//
// gtest_xml_outfile1_test_ writes some xml via TestProperty used by
// gtest_xml_outfile1_test_ writes some xml via TestProperty used by
// gtest_xml_outfiles_test.py
// gtest_xml_outfiles_test.py
...
...
googletest/test/gtest_xml_outfile2_test_.cc
View file @
687964c8
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
//
// gtest_xml_outfile2_test_ writes some xml via TestProperty used by
// gtest_xml_outfile2_test_ writes some xml via TestProperty used by
// gtest_xml_outfiles_test.py
// gtest_xml_outfiles_test.py
...
...
googletest/test/gtest_xml_outfiles_test.py
View file @
687964c8
...
@@ -43,7 +43,13 @@ GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
...
@@ -43,7 +43,13 @@ GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
EXPECTED_XML_1
=
"""<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_1
=
"""<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuite name="PropertyOne" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="PropertyOne" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="TestSomeProperties" status="run" time="*" classname="PropertyOne" SetUpProp="1" TestSomeProperty="1" TearDownProp="1" />
<testcase name="TestSomeProperties" status="run" time="*" classname="PropertyOne">
<properties>
<property name="SetUpProp" value="1"/>
<property name="TestSomeProperty" value="1"/>
<property name="TearDownProp" value="1"/>
</properties>
</testcase>
</testsuite>
</testsuite>
</testsuites>
</testsuites>
"""
"""
...
@@ -51,7 +57,13 @@ EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?>
...
@@ -51,7 +57,13 @@ EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_2
=
"""<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_2
=
"""<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuite name="PropertyTwo" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="PropertyTwo" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="TestSomeProperties" status="run" time="*" classname="PropertyTwo" SetUpProp="2" TestSomeProperty="2" TearDownProp="2" />
<testcase name="TestSomeProperties" status="run" time="*" classname="PropertyTwo">
<properties>
<property name="SetUpProp" value="2"/>
<property name="TestSomeProperty" value="2"/>
<property name="TearDownProp" value="2"/>
</properties>
</testcase>
</testsuite>
</testsuite>
</testsuites>
</testsuites>
"""
"""
...
@@ -99,11 +111,11 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
...
@@ -99,11 +111,11 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
self
.
assert_
(
p
.
exited
)
self
.
assert_
(
p
.
exited
)
self
.
assertEquals
(
0
,
p
.
exit_code
)
self
.
assertEquals
(
0
,
p
.
exit_code
)
#
TODO(wan@google.com)
: libtool causes the built test binary to be
#
FIXME
: libtool causes the built test binary to be
# named lt-gtest_xml_outfiles_test_ instead of
# named lt-gtest_xml_outfiles_test_ instead of
# gtest_xml_outfiles_test_. To account for this possibility, we
# gtest_xml_outfiles_test_. To account for this possibility, we
# allow both names in the following code. We should remove this
# allow both names in the following code. We should remove this
#
hack when Chandler Carruth's
libtool replacement tool is ready.
#
when
libtool replacement tool is ready.
output_file_name1
=
test_name
+
".xml"
output_file_name1
=
test_name
+
".xml"
output_file1
=
os
.
path
.
join
(
self
.
output_dir_
,
output_file_name1
)
output_file1
=
os
.
path
.
join
(
self
.
output_dir_
,
output_file_name1
)
output_file_name2
=
'lt-'
+
output_file_name1
output_file_name2
=
'lt-'
+
output_file_name1
...
...
googletest/test/gtest_xml_output_unittest.py
View file @
687964c8
...
@@ -47,17 +47,22 @@ GTEST_OUTPUT_FLAG = '--gtest_output'
...
@@ -47,17 +47,22 @@ GTEST_OUTPUT_FLAG = '--gtest_output'
GTEST_DEFAULT_OUTPUT_FILE
=
'test_detail.xml'
GTEST_DEFAULT_OUTPUT_FILE
=
'test_detail.xml'
GTEST_PROGRAM_NAME
=
'gtest_xml_output_unittest_'
GTEST_PROGRAM_NAME
=
'gtest_xml_output_unittest_'
# The flag indicating stacktraces are not supported
NO_STACKTRACE_SUPPORT_FLAG
=
'--no_stacktrace_support'
# The environment variables for test sharding.
# The environment variables for test sharding.
TOTAL_SHARDS_ENV_VAR
=
'GTEST_TOTAL_SHARDS'
TOTAL_SHARDS_ENV_VAR
=
'GTEST_TOTAL_SHARDS'
SHARD_INDEX_ENV_VAR
=
'GTEST_SHARD_INDEX'
SHARD_INDEX_ENV_VAR
=
'GTEST_SHARD_INDEX'
SHARD_STATUS_FILE_ENV_VAR
=
'GTEST_SHARD_STATUS_FILE'
SHARD_STATUS_FILE_ENV_VAR
=
'GTEST_SHARD_STATUS_FILE'
SUPPORTS_STACK_TRACES
=
False
SUPPORTS_STACK_TRACES
=
NO_STACKTRACE_SUPPORT_FLAG
not
in
sys
.
argv
if
SUPPORTS_STACK_TRACES
:
if
SUPPORTS_STACK_TRACES
:
STACK_TRACE_TEMPLATE
=
'
\n
Stack trace:
\n
*'
STACK_TRACE_TEMPLATE
=
'
\n
Stack trace:
\n
*'
else
:
else
:
STACK_TRACE_TEMPLATE
=
''
STACK_TRACE_TEMPLATE
=
''
# unittest.main() can't handle unknown flags
sys
.
argv
.
remove
(
NO_STACKTRACE_SUPPORT_FLAG
)
EXPECTED_NON_EMPTY_XML
=
"""<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_NON_EMPTY_XML
=
"""<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="23" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuites tests="23" failures="4" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
...
@@ -104,15 +109,45 @@ Invalid characters in brackets []%(stack)s]]></failure>
...
@@ -104,15 +109,45 @@ Invalid characters in brackets []%(stack)s]]></failure>
<testcase name="DISABLED_test_not_run" status="notrun" time="*" classname="DisabledTest"/>
<testcase name="DISABLED_test_not_run" status="notrun" time="*" classname="DisabledTest"/>
</testsuite>
</testsuite>
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye">
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTestCase="yes" TearDownTestCase="aye">
<testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest" key_1="1"/>
<testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest">
<testcase name="IntValuedProperty" status="run" time="*" classname="PropertyRecordingTest" key_int="1"/>
<properties>
<testcase name="ThreeProperties" status="run" time="*" classname="PropertyRecordingTest" key_1="1" key_2="2" key_3="3"/>
<property name="key_1" value="1"/>
<testcase name="TwoValuesForOneKeyUsesLastValue" status="run" time="*" classname="PropertyRecordingTest" key_1="2"/>
</properties>
</testcase>
<testcase name="IntValuedProperty" status="run" time="*" classname="PropertyRecordingTest">
<properties>
<property name="key_int" value="1"/>
</properties>
</testcase>
<testcase name="ThreeProperties" status="run" time="*" classname="PropertyRecordingTest">
<properties>
<property name="key_1" value="1"/>
<property name="key_2" value="2"/>
<property name="key_3" value="3"/>
</properties>
</testcase>
<testcase name="TwoValuesForOneKeyUsesLastValue" status="run" time="*" classname="PropertyRecordingTest">
<properties>
<property name="key_1" value="2"/>
</properties>
</testcase>
</testsuite>
</testsuite>
<testsuite name="NoFixtureTest" tests="3" failures="0" disabled="0" errors="0" time="*">
<testsuite name="NoFixtureTest" tests="3" failures="0" disabled="0" errors="0" time="*">
<testcase name="RecordProperty" status="run" time="*" classname="NoFixtureTest" key="1"/>
<testcase name="RecordProperty" status="run" time="*" classname="NoFixtureTest">
<testcase name="ExternalUtilityThatCallsRecordIntValuedProperty" status="run" time="*" classname="NoFixtureTest" key_for_utility_int="1"/>
<properties>
<testcase name="ExternalUtilityThatCallsRecordStringValuedProperty" status="run" time="*" classname="NoFixtureTest" key_for_utility_string="1"/>
<property name="key" value="1"/>
</properties>
</testcase>
<testcase name="ExternalUtilityThatCallsRecordIntValuedProperty" status="run" time="*" classname="NoFixtureTest">
<properties>
<property name="key_for_utility_int" value="1"/>
</properties>
</testcase>
<testcase name="ExternalUtilityThatCallsRecordStringValuedProperty" status="run" time="*" classname="NoFixtureTest">
<properties>
<property name="key_for_utility_string" value="1"/>
</properties>
</testcase>
</testsuite>
</testsuite>
<testsuite name="Single/ValueParamTest" tests="4" failures="0" disabled="0" errors="0" time="*">
<testsuite name="Single/ValueParamTest" tests="4" failures="0" disabled="0" errors="0" time="*">
<testcase name="HasValueParamAttribute/0" value_param="33" status="run" time="*" classname="Single/ValueParamTest" />
<testcase name="HasValueParamAttribute/0" value_param="33" status="run" time="*" classname="Single/ValueParamTest" />
...
@@ -149,7 +184,11 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
...
@@ -149,7 +184,11 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite>
</testsuite>
<testsuite name="NoFixtureTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="NoFixtureTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="RecordProperty" status="run" time="*" classname="NoFixtureTest" key="1"/>
<testcase name="RecordProperty" status="run" time="*" classname="NoFixtureTest">
<properties>
<property name="key" value="1"/>
</properties>
</testcase>
</testsuite>
</testsuite>
<testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="AnotherTestThatHasValueParamAttribute/1" value_param="42" status="run" time="*" classname="Single/ValueParamTest" />
<testcase name="AnotherTestThatHasValueParamAttribute/1" value_param="42" status="run" time="*" classname="Single/ValueParamTest" />
...
...
googletest/test/gtest_xml_test_utils.py
View file @
687964c8
...
@@ -101,19 +101,22 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
...
@@ -101,19 +101,22 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self
.
AssertEquivalentNodes
(
child
,
actual_children
[
child_id
])
self
.
AssertEquivalentNodes
(
child
,
actual_children
[
child_id
])
identifying_attribute
=
{
identifying_attribute
=
{
'testsuites'
:
'name'
,
'testsuites'
:
'name'
,
'testsuite'
:
'name'
,
'testsuite'
:
'name'
,
'testcase'
:
'name'
,
'testcase'
:
'name'
,
'failure'
:
'message'
,
'failure'
:
'message'
,
}
'property'
:
'name'
,
}
def
_GetChildren
(
self
,
element
):
def
_GetChildren
(
self
,
element
):
"""
"""
Fetches all of the child nodes of element, a DOM Element object.
Fetches all of the child nodes of element, a DOM Element object.
Returns them as the values of a dictionary keyed by the IDs of the
Returns them as the values of a dictionary keyed by the IDs of the
children. For <testsuites>, <testsuite> and <testcase> elements, the ID
children. For <testsuites>, <testsuite>, <testcase>, and <property>
is the value of their "name" attribute; for <failure> elements, it is
elements, the ID is the value of their "name" attribute; for <failure>
the value of the "message" attribute; CDATA sections and non-whitespace
elements, it is the value of the "message" attribute; for <properties>
elements, it is the value of their parent's "name" attribute plus the
literal string "properties"; CDATA sections and non-whitespace
text nodes are concatenated into a single CDATA section with ID
text nodes are concatenated into a single CDATA section with ID
"detail". An exception is raised if any element other than the above
"detail". An exception is raised if any element other than the above
four is encountered, if two child elements with the same identifying
four is encountered, if two child elements with the same identifying
...
@@ -123,11 +126,17 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
...
@@ -123,11 +126,17 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
children
=
{}
children
=
{}
for
child
in
element
.
childNodes
:
for
child
in
element
.
childNodes
:
if
child
.
nodeType
==
Node
.
ELEMENT_NODE
:
if
child
.
nodeType
==
Node
.
ELEMENT_NODE
:
self
.
assert_
(
child
.
tagName
in
self
.
identifying_attribute
,
if
child
.
tagName
==
'properties'
:
'Encountered unknown element <%s>'
%
child
.
tagName
)
self
.
assert_
(
child
.
parentNode
is
not
None
,
childID
=
child
.
getAttribute
(
self
.
identifying_attribute
[
child
.
tagName
])
'Encountered <properties> element without a parent'
)
self
.
assert_
(
childID
not
in
children
)
child_id
=
child
.
parentNode
.
getAttribute
(
'name'
)
+
'-properties'
children
[
childID
]
=
child
else
:
self
.
assert_
(
child
.
tagName
in
self
.
identifying_attribute
,
'Encountered unknown element <%s>'
%
child
.
tagName
)
child_id
=
child
.
getAttribute
(
self
.
identifying_attribute
[
child
.
tagName
])
self
.
assert_
(
child_id
not
in
children
)
children
[
child_id
]
=
child
elif
child
.
nodeType
in
[
Node
.
TEXT_NODE
,
Node
.
CDATA_SECTION_NODE
]:
elif
child
.
nodeType
in
[
Node
.
TEXT_NODE
,
Node
.
CDATA_SECTION_NODE
]:
if
'detail'
not
in
children
:
if
'detail'
not
in
children
:
if
(
child
.
nodeType
==
Node
.
CDATA_SECTION_NODE
or
if
(
child
.
nodeType
==
Node
.
CDATA_SECTION_NODE
or
...
...
googletest/test/production.cc
View file @
687964c8
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
//
// This is part of the unit test for gtest_prod.h.
// This is part of the unit test for gtest_prod.h.
...
...
googletest/test/production.h
View file @
687964c8
...
@@ -26,8 +26,7 @@
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
//
// This is part of the unit test for gtest_prod.h.
// This is part of the unit test for gtest_prod.h.
...
...
googletest/xcode/Config/DebugProject.xcconfig
View file @
687964c8
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
// examples. It is set in the "Based On:" dropdown in the "Project" info
// examples. It is set in the "Based On:" dropdown in the "Project" info
// dialog.
// dialog.
// This file is based on the Xcode Configuration files in:
// This file is based on the Xcode Configuration files in:
// http://
code.google.com/p
/google-toolbox-for-mac
/
// http
s
://
github.com/google
/google-toolbox-for-mac
//
//
#include "General.xcconfig"
#include "General.xcconfig"
...
...
googletest/xcode/Config/FrameworkTarget.xcconfig
View file @
687964c8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
// These are Framework target settings for the gtest framework and examples. It
// These are Framework target settings for the gtest framework and examples. It
// is set in the "Based On:" dropdown in the "Target" info dialog.
// is set in the "Based On:" dropdown in the "Target" info dialog.
// This file is based on the Xcode Configuration files in:
// This file is based on the Xcode Configuration files in:
// http://
code.google.com/p
/google-toolbox-for-mac
/
// http
s
://
github.com/google
/google-toolbox-for-mac
//
//
// Dynamic libs need to be position independent
// Dynamic libs need to be position independent
...
...
googletest/xcode/Config/General.xcconfig
View file @
687964c8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
// These are General configuration settings for the gtest framework and
// These are General configuration settings for the gtest framework and
// examples.
// examples.
// This file is based on the Xcode Configuration files in:
// This file is based on the Xcode Configuration files in:
// http://
code.google.com/p
/google-toolbox-for-mac
/
// http
s
://
github.com/google
/google-toolbox-for-mac
//
//
// Build for PPC and Intel, 32- and 64-bit
// Build for PPC and Intel, 32- and 64-bit
...
...
Prev
1
…
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