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
8304d061
Commit
8304d061
authored
Aug 21, 2017
by
Daniel Krügler
Committed by
GitHub
Aug 21, 2017
Browse files
Merge branch 'master' into master
parents
b11b2e40
675686a1
Changes
93
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
168 additions
and
23 deletions
+168
-23
googletest/samples/sample8_unittest.cc
googletest/samples/sample8_unittest.cc
+2
-1
googletest/samples/sample9_unittest.cc
googletest/samples/sample9_unittest.cc
+0
-3
googletest/scripts/upload.py
googletest/scripts/upload.py
+1
-1
googletest/src/gtest-death-test.cc
googletest/src/gtest-death-test.cc
+1
-1
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+1
-1
googletest/src/gtest.cc
googletest/src/gtest.cc
+36
-7
googletest/test/BUILD.bazel
googletest/test/BUILD.bazel
+118
-0
googletest/test/gtest-port_test.cc
googletest/test/gtest-port_test.cc
+1
-1
googletest/test/gtest_test_utils.py
googletest/test/gtest_test_utils.py
+1
-1
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+2
-2
googletest/test/gtest_xml_outfiles_test.py
googletest/test/gtest_xml_outfiles_test.py
+1
-1
googletest/test/gtest_xml_output_unittest.py
googletest/test/gtest_xml_output_unittest.py
+1
-1
googletest/xcode/Scripts/versiongenerate.py
googletest/xcode/Scripts/versiongenerate.py
+3
-3
No files found.
googletest/samples/sample8_unittest.cc
View file @
8304d061
...
...
@@ -37,7 +37,7 @@
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace
{
#if GTEST_HAS_COMBINE
// Suppose we want to introduce a new, improved implementation of PrimeTable
...
...
@@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
TEST
(
DummyTest
,
CombineIsNotSupportedOnThisPlatform
)
{}
#endif // GTEST_HAS_COMBINE
}
// namespace
googletest/samples/sample9_unittest.cc
View file @
8304d061
...
...
@@ -44,9 +44,7 @@ using ::testing::TestEventListeners;
using
::
testing
::
TestInfo
;
using
::
testing
::
TestPartResult
;
using
::
testing
::
UnitTest
;
namespace
{
// Provides alternative output mode which produces minimal amount of
// information about tests.
class
TersePrinter
:
public
EmptyTestEventListener
{
...
...
@@ -102,7 +100,6 @@ TEST(CustomOutputTest, Fails) {
EXPECT_EQ
(
1
,
2
)
<<
"This test fails in order to demonstrate alternative failure messages"
;
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
...
...
googletest/scripts/upload.py
View file @
8304d061
...
...
@@ -732,7 +732,7 @@ class SubversionVCS(VersionControlSystem):
else
:
self
.
rev_start
=
self
.
rev_end
=
None
# Cache output from "svn list -r REVNO dirname".
# Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
# Keys: dirname, Values: 2-tuple (ou
t
put for start rev and end rev).
self
.
svnls_cache
=
{}
# SVN base URL is required to fetch files deleted in an older revision.
# Result is cached to not guess it over and over again in GetBaseFile().
...
...
googletest/src/gtest-death-test.cc
View file @
8304d061
...
...
@@ -1242,7 +1242,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,
reinterpret_cast
<
HANDLE
>
(
write_handle_as_size_t
);
HANDLE
dup_write_handle
;
// The newly initialized handle is accessible only in
in
the parent
// The newly initialized handle is accessible only in the parent
// process. To obtain one accessible within the child, we need to use
// DuplicateHandle.
if
(
!::
DuplicateHandle
(
parent_process_handle
.
Get
(),
write_handle
,
...
...
googletest/src/gtest-port.cc
View file @
8304d061
...
...
@@ -496,7 +496,7 @@ class ThreadLocalRegistryImpl {
FALSE
,
thread_id
);
GTEST_CHECK_
(
thread
!=
NULL
);
// We need to
to
pass a valid thread ID pointer into CreateThread for it
// We need to pass a valid thread ID pointer into CreateThread for it
// to work correctly under Win98.
DWORD
watcher_thread_id
;
HANDLE
watcher_thread
=
::
CreateThread
(
...
...
googletest/src/gtest.cc
View file @
8304d061
...
...
@@ -310,7 +310,8 @@ namespace internal {
// than kMaxRange.
UInt32
Random
::
Generate
(
UInt32
range
)
{
// These constants are the same as are used in glibc's rand(3).
state_
=
(
1103515245U
*
state_
+
12345U
)
%
kMaxRange
;
// Use wider types than necessary to prevent unsigned overflow diagnostics.
state_
=
static_cast
<
UInt32
>
(
1103515245ULL
*
state_
+
12345U
)
%
kMaxRange
;
GTEST_CHECK_
(
range
>
0
)
<<
"Cannot generate a number in the range [0, 0)."
;
...
...
@@ -1168,7 +1169,7 @@ class Hunk {
// Print a unified diff header for one hunk.
// The format is
// "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
// where the left/right parts are om
m
itted if unnecessary.
// where the left/right parts are omitted if unnecessary.
void
PrintHeader
(
std
::
ostream
*
ss
)
const
{
*
ss
<<
"@@ "
;
if
(
removes_
)
{
...
...
@@ -1781,7 +1782,7 @@ std::string CodePointToUtf8(UInt32 code_point) {
return
str
;
}
// The following two functions only make sense if the
the
system
// The following two functions only make sense if the system
// uses UTF-16 for wide string encoding. All supported systems
// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
...
...
@@ -2894,6 +2895,33 @@ WORD GetColorAttribute(GTestColor color) {
}
}
int
GetBitOffset
(
WORD
color_mask
)
{
if
(
color_mask
==
0
)
return
0
;
int
bitOffset
=
0
;
while
((
color_mask
&
1
)
==
0
)
{
color_mask
>>=
1
;
++
bitOffset
;
}
return
bitOffset
;
}
WORD
GetNewColor
(
GTestColor
color
,
WORD
old_color_attrs
)
{
// Let's reuse the BG
static
const
WORD
background_mask
=
BACKGROUND_BLUE
|
BACKGROUND_GREEN
|
BACKGROUND_RED
|
BACKGROUND_INTENSITY
;
static
const
WORD
foreground_mask
=
FOREGROUND_BLUE
|
FOREGROUND_GREEN
|
FOREGROUND_RED
|
FOREGROUND_INTENSITY
;
const
WORD
existing_bg
=
old_color_attrs
&
background_mask
;
WORD
new_color
=
GetColorAttribute
(
color
)
|
existing_bg
|
FOREGROUND_INTENSITY
;
static
const
int
bg_bitOffset
=
GetBitOffset
(
background_mask
);
static
const
int
fg_bitOffset
=
GetBitOffset
(
foreground_mask
);
if
(((
new_color
&
background_mask
)
>>
bg_bitOffset
)
==
((
new_color
&
foreground_mask
)
>>
fg_bitOffset
))
{
new_color
^=
FOREGROUND_INTENSITY
;
//invert intensity
}
return
new_color
;
}
#else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
...
...
@@ -2979,13 +3007,14 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
CONSOLE_SCREEN_BUFFER_INFO
buffer_info
;
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
const
WORD
old_color_attrs
=
buffer_info
.
wAttributes
;
const
WORD
new_color
=
GetNewColor
(
color
,
old_color_attrs
);
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
fflush
(
stdout
);
SetConsoleTextAttribute
(
stdout_handle
,
GetColorAttribute
(
color
)
|
FOREGROUND_INTENSITY
);
SetConsoleTextAttribute
(
stdout_handle
,
new_color
);
vprintf
(
fmt
,
args
);
fflush
(
stdout
);
...
...
@@ -5188,7 +5217,7 @@ static const char kColorEncodedHelpMessage[] =
" @G--"
GTEST_FLAG_PREFIX_
"output=xml@Y[@G:@YDIRECTORY_PATH@G"
GTEST_PATH_SEP_
"@Y|@G:@YFILE_PATH]@D
\n
"
" Generate an XML report in the given directory or with the given file
\n
"
" name. @YFILE_PATH@D defaults to @Gtest_detail
s
.xml@D.
\n
"
" name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.
\n
"
#if GTEST_CAN_STREAM_RESULTS_
" @G--"
GTEST_FLAG_PREFIX_
"stream_result_to=@YHOST@G:@YPORT@D
\n
"
" Stream test results to the given server.
\n
"
...
...
googletest/test/BUILD.bazel
0 → 100644
View file @
8304d061
# Copyright 2017 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.
#
# Author: misterg@google.com (Gennadiy Civil)
#
# Bazel BUILD for The Google C++ Testing Framework (Google Test)
licenses
([
"notice"
])
""" gtest own tests """
#on windows exclude gtest-tuple.h and gtest-tuple_test.cc
cc_test
(
name
=
"gtest_all_test"
,
size
=
"small"
,
srcs
=
glob
(
include
=
[
"gtest-*.cc"
,
"*.h"
,
"googletest/include/gtest/**/*.h"
,
],
exclude
=
[
"gtest-unittest-api_test.cc"
,
"gtest-tuple_test.cc"
,
"googletest/src/gtest-all.cc"
,
"gtest_all_test.cc"
,
"gtest-death-test_ex_test.cc"
,
"gtest-listener_test.cc"
,
"gtest-unittest-api_test.cc"
,
"gtest-param-test_test.cc"
,
],
)
+
select
({
"//:win"
:
[],
"//conditions:default"
:
[
"gtest-tuple_test.cc"
,
],
}),
copts
=
select
({
"//:win"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=0"
],
"//conditions:default"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=1"
],
}),
includes
=
[
"googletest"
,
"googletest/include"
,
"googletest/include/internal"
,
"googletest/test"
,
],
linkopts
=
select
({
"//:win"
:
[],
"//conditions:default"
:
[
"-pthread"
,
],
}),
deps
=
[
"//:gtest_main"
],
)
#These googletest tests have their own main()
cc_test
(
name
=
"gtest-listener_test"
,
size
=
"small"
,
srcs
=
[
"gtest-listener_test.cc"
,
],
deps
=
[
"//:gtest"
,
],
)
cc_test
(
name
=
"gtest-unittest-api_test"
,
size
=
"small"
,
srcs
=
[
"gtest-unittest-api_test.cc"
,
],
deps
=
[
"//:gtest"
,
],
)
cc_test
(
name
=
"gtest-param-test_test"
,
size
=
"small"
,
srcs
=
[
"gtest-param-test2_test.cc"
,
"gtest-param-test_test.cc"
,
"gtest-param-test_test.h"
,
],
deps
=
[
"//:gtest"
,
],
)
googletest/test/gtest-port_test.cc
View file @
8304d061
...
...
@@ -1209,7 +1209,7 @@ class DestructorTracker {
:
index_
(
GetNewIndex
())
{}
~
DestructorTracker
()
{
// We never access DestructorCall::List() concurrently, so we don't need
// to protect this acc
c
ess with a mutex.
// to protect this access with a mutex.
DestructorCall
::
List
()[
index_
]
->
ReportDestroyed
();
}
...
...
googletest/test/gtest_test_utils.py
View file @
8304d061
...
...
@@ -245,7 +245,7 @@ class Subprocess:
p
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
stderr
,
cwd
=
working_dir
,
universal_newlines
=
True
,
env
=
env
)
# communicate returns a tuple with the file obect for the child's
# communicate returns a tuple with the file ob
j
ect for the child's
# output.
self
.
output
=
p
.
communicate
()[
0
]
self
.
_return_code
=
p
.
returncode
...
...
googletest/test/gtest_unittest.cc
View file @
8304d061
...
...
@@ -1388,7 +1388,7 @@ class TestResultTest : public Test {
delete
r2
;
}
// Helper that compares two
two
TestPartResults.
// Helper that compares two TestPartResults.
static
void
CompareTestPartResult
(
const
TestPartResult
&
expected
,
const
TestPartResult
&
actual
)
{
EXPECT_EQ
(
expected
.
type
(),
actual
.
type
());
...
...
@@ -3689,7 +3689,7 @@ TEST(AssertionTest, ASSERT_EQ) {
TEST
(
AssertionTest
,
ASSERT_EQ_NULL
)
{
// A success.
const
char
*
p
=
NULL
;
// Some older GCC versions may issue a spurious waring in this or the next
// Some older GCC versions may issue a spurious war
n
ing in this or the next
// assertion statement. This warning should not be suppressed with
// static_cast since the test verifies the ability to use bare NULL as the
// expected parameter to the macro.
...
...
googletest/test/gtest_xml_outfiles_test.py
View file @
8304d061
...
...
@@ -105,7 +105,7 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
# TODO(wan@google.com): libtool causes the built test binary to be
# named lt-gtest_xml_outfiles_test_ instead of
# gtest_xml_outfiles_test_. To account for this possibil
l
ity, we
# gtest_xml_outfiles_test_. To account for this possibility, we
# allow both names in the following code. We should remove this
# hack when Chandler Carruth's libtool replacement tool is ready.
output_file_name1
=
test_name
+
".xml"
...
...
googletest/test/gtest_xml_output_unittest.py
View file @
8304d061
...
...
@@ -237,7 +237,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'--shut_down_xml'
]
p
=
gtest_test_utils
.
Subprocess
(
command
)
if
p
.
terminated_by_signal
:
# p.signal is avalable only if p.terminated_by_signal is True.
# p.signal is ava
i
lable only if p.terminated_by_signal is True.
self
.
assertFalse
(
p
.
terminated_by_signal
,
'%s was killed by signal %d'
%
(
GTEST_PROGRAM_NAME
,
p
.
signal
))
...
...
googletest/xcode/Scripts/versiongenerate.py
View file @
8304d061
...
...
@@ -42,7 +42,7 @@
1. The AC_INIT macro will be contained within the first 1024 characters
of configure.ac
2. The version string will be 3 integers separated by periods and will be
surrounded by squre brackets, "[" and "]" (e.g. [1.0.1]). The first
surrounded by squ
a
re brackets, "[" and "]" (e.g. [1.0.1]). The first
segment represents the major version, the second represents the minor
version and the third represents the fix version.
3. No ")" character exists between the opening "(" and closing ")" of
...
...
@@ -68,7 +68,7 @@ config_file.close()
# Extract the version string from the AC_INIT macro
# The following init_expression means:
# Extract three integers separated by periods and surrounded by squre
# Extract three integers separated by periods and surrounded by squ
a
re
# brackets(e.g. "[1.0.1]") between "AC_INIT(" and ")". Do not be greedy
# (*? is the non-greedy flag) since that would pull in everything between
# the first "(" and the last ")" in the file.
...
...
@@ -88,7 +88,7 @@ file_data = """//
// is executed in a "Run Script" build phase when creating gtest.framework. This
// header file is not used during compilation of C-source. Rather, it simply
// defines some version strings for substitution in the Info.plist. Because of
// this, we are not
not
restricted to C-syntax nor are we using include guards.
// this, we are not restricted to C-syntax nor are we using include guards.
//
#define GTEST_VERSIONINFO_SHORT %s.%s
...
...
Prev
1
2
3
4
5
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