Commit d93ce9d6 authored by drgler's avatar drgler
Browse files

Merge branch 'master' of github.com:Dani-Hub/googletest

parents 6404d45a 8304d061
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "prime_tables.h" #include "prime_tables.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace {
#if GTEST_HAS_COMBINE #if GTEST_HAS_COMBINE
// Suppose we want to introduce a new, improved implementation of PrimeTable // Suppose we want to introduce a new, improved implementation of PrimeTable
...@@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters, ...@@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {} TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}
#endif // GTEST_HAS_COMBINE #endif // GTEST_HAS_COMBINE
} // namespace
...@@ -44,9 +44,7 @@ using ::testing::TestEventListeners; ...@@ -44,9 +44,7 @@ using ::testing::TestEventListeners;
using ::testing::TestInfo; using ::testing::TestInfo;
using ::testing::TestPartResult; using ::testing::TestPartResult;
using ::testing::UnitTest; using ::testing::UnitTest;
namespace { namespace {
// Provides alternative output mode which produces minimal amount of // Provides alternative output mode which produces minimal amount of
// information about tests. // information about tests.
class TersePrinter : public EmptyTestEventListener { class TersePrinter : public EmptyTestEventListener {
...@@ -102,7 +100,6 @@ TEST(CustomOutputTest, Fails) { ...@@ -102,7 +100,6 @@ TEST(CustomOutputTest, Fails) {
EXPECT_EQ(1, 2) EXPECT_EQ(1, 2)
<< "This test fails in order to demonstrate alternative failure messages"; << "This test fails in order to demonstrate alternative failure messages";
} }
} // namespace } // namespace
int main(int argc, char **argv) { int main(int argc, char **argv) {
......
...@@ -732,7 +732,7 @@ class SubversionVCS(VersionControlSystem): ...@@ -732,7 +732,7 @@ class SubversionVCS(VersionControlSystem):
else: else:
self.rev_start = self.rev_end = None self.rev_start = self.rev_end = None
# Cache output from "svn list -r REVNO dirname". # 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 (output for start rev and end rev).
self.svnls_cache = {} self.svnls_cache = {}
# SVN base URL is required to fetch files deleted in an older revision. # 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(). # Result is cached to not guess it over and over again in GetBaseFile().
......
...@@ -1242,7 +1242,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id, ...@@ -1242,7 +1242,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,
reinterpret_cast<HANDLE>(write_handle_as_size_t); reinterpret_cast<HANDLE>(write_handle_as_size_t);
HANDLE dup_write_handle; 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 // process. To obtain one accessible within the child, we need to use
// DuplicateHandle. // DuplicateHandle.
if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
......
...@@ -496,7 +496,7 @@ class ThreadLocalRegistryImpl { ...@@ -496,7 +496,7 @@ class ThreadLocalRegistryImpl {
FALSE, FALSE,
thread_id); thread_id);
GTEST_CHECK_(thread != NULL); 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. // to work correctly under Win98.
DWORD watcher_thread_id; DWORD watcher_thread_id;
HANDLE watcher_thread = ::CreateThread( HANDLE watcher_thread = ::CreateThread(
......
...@@ -310,7 +310,8 @@ namespace internal { ...@@ -310,7 +310,8 @@ namespace internal {
// than kMaxRange. // than kMaxRange.
UInt32 Random::Generate(UInt32 range) { UInt32 Random::Generate(UInt32 range) {
// These constants are the same as are used in glibc's rand(3). // 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) GTEST_CHECK_(range > 0)
<< "Cannot generate a number in the range [0, 0)."; << "Cannot generate a number in the range [0, 0).";
...@@ -1168,7 +1169,7 @@ class Hunk { ...@@ -1168,7 +1169,7 @@ class Hunk {
// Print a unified diff header for one hunk. // Print a unified diff header for one hunk.
// The format is // The format is
// "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@" // "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
// where the left/right parts are ommitted if unnecessary. // where the left/right parts are omitted if unnecessary.
void PrintHeader(std::ostream* ss) const { void PrintHeader(std::ostream* ss) const {
*ss << "@@ "; *ss << "@@ ";
if (removes_) { if (removes_) {
...@@ -1781,7 +1782,7 @@ std::string CodePointToUtf8(UInt32 code_point) { ...@@ -1781,7 +1782,7 @@ std::string CodePointToUtf8(UInt32 code_point) {
return str; 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 // uses UTF-16 for wide string encoding. All supported systems
// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16. // with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
...@@ -2894,6 +2895,33 @@ WORD GetColorAttribute(GTestColor color) { ...@@ -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 #else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is // Returns the ANSI color code for the given color. COLOR_DEFAULT is
...@@ -2979,13 +3007,14 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { ...@@ -2979,13 +3007,14 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
CONSOLE_SCREEN_BUFFER_INFO buffer_info; CONSOLE_SCREEN_BUFFER_INFO buffer_info;
GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
const WORD old_color_attrs = buffer_info.wAttributes; 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 // We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already // SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console. // printed but has not yet reached the console.
fflush(stdout); fflush(stdout);
SetConsoleTextAttribute(stdout_handle, SetConsoleTextAttribute(stdout_handle, new_color);
GetColorAttribute(color) | FOREGROUND_INTENSITY);
vprintf(fmt, args); vprintf(fmt, args);
fflush(stdout); fflush(stdout);
...@@ -5188,7 +5217,7 @@ static const char kColorEncodedHelpMessage[] = ...@@ -5188,7 +5217,7 @@ static const char kColorEncodedHelpMessage[] =
" @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G" " @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G"
GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n" GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
" Generate an XML report in the given directory or with the given file\n" " Generate an XML report in the given directory or with the given file\n"
" name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n" " name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.\n"
#if GTEST_CAN_STREAM_RESULTS_ #if GTEST_CAN_STREAM_RESULTS_
" @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n" " @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n"
" Stream test results to the given server.\n" " Stream test results to the given server.\n"
......
# 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",
],
)
...@@ -1209,7 +1209,7 @@ class DestructorTracker { ...@@ -1209,7 +1209,7 @@ class DestructorTracker {
: index_(GetNewIndex()) {} : index_(GetNewIndex()) {}
~DestructorTracker() { ~DestructorTracker() {
// We never access DestructorCall::List() concurrently, so we don't need // We never access DestructorCall::List() concurrently, so we don't need
// to protect this acccess with a mutex. // to protect this access with a mutex.
DestructorCall::List()[index_]->ReportDestroyed(); DestructorCall::List()[index_]->ReportDestroyed();
} }
......
...@@ -198,6 +198,8 @@ class PathLike { ...@@ -198,6 +198,8 @@ class PathLike {
}; };
typedef iterator const_iterator; typedef iterator const_iterator;
PathLike() {}
iterator begin() const { return iterator(); } iterator begin() const { return iterator(); }
iterator end() const { return iterator(); } iterator end() const { return iterator(); }
......
...@@ -245,7 +245,7 @@ class Subprocess: ...@@ -245,7 +245,7 @@ class Subprocess:
p = subprocess.Popen(command, p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=stderr, stdout=subprocess.PIPE, stderr=stderr,
cwd=working_dir, universal_newlines=True, env=env) 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 object for the child's
# output. # output.
self.output = p.communicate()[0] self.output = p.communicate()[0]
self._return_code = p.returncode self._return_code = p.returncode
......
...@@ -1388,7 +1388,7 @@ class TestResultTest : public Test { ...@@ -1388,7 +1388,7 @@ class TestResultTest : public Test {
delete r2; delete r2;
} }
// Helper that compares two two TestPartResults. // Helper that compares two TestPartResults.
static void CompareTestPartResult(const TestPartResult& expected, static void CompareTestPartResult(const TestPartResult& expected,
const TestPartResult& actual) { const TestPartResult& actual) {
EXPECT_EQ(expected.type(), actual.type()); EXPECT_EQ(expected.type(), actual.type());
...@@ -3689,7 +3689,7 @@ TEST(AssertionTest, ASSERT_EQ) { ...@@ -3689,7 +3689,7 @@ TEST(AssertionTest, ASSERT_EQ) {
TEST(AssertionTest, ASSERT_EQ_NULL) { TEST(AssertionTest, ASSERT_EQ_NULL) {
// A success. // A success.
const char* p = NULL; 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 warning in this or the next
// assertion statement. This warning should not be suppressed with // assertion statement. This warning should not be suppressed with
// static_cast since the test verifies the ability to use bare NULL as the // static_cast since the test verifies the ability to use bare NULL as the
// expected parameter to the macro. // expected parameter to the macro.
......
...@@ -105,7 +105,7 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -105,7 +105,7 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
# TODO(wan@google.com): libtool causes the built test binary to be # TODO(wan@google.com): 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 possibillity, 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. # hack when Chandler Carruth's libtool replacement tool is ready.
output_file_name1 = test_name + ".xml" output_file_name1 = test_name + ".xml"
......
...@@ -237,7 +237,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): ...@@ -237,7 +237,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'--shut_down_xml'] '--shut_down_xml']
p = gtest_test_utils.Subprocess(command) p = gtest_test_utils.Subprocess(command)
if p.terminated_by_signal: if p.terminated_by_signal:
# p.signal is avalable only if p.terminated_by_signal is True. # p.signal is available only if p.terminated_by_signal is True.
self.assertFalse( self.assertFalse(
p.terminated_by_signal, p.terminated_by_signal,
'%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal)) '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
1. The AC_INIT macro will be contained within the first 1024 characters 1. The AC_INIT macro will be contained within the first 1024 characters
of configure.ac of configure.ac
2. The version string will be 3 integers separated by periods and will be 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 square brackets, "[" and "]" (e.g. [1.0.1]). The first
segment represents the major version, the second represents the minor segment represents the major version, the second represents the minor
version and the third represents the fix version. version and the third represents the fix version.
3. No ")" character exists between the opening "(" and closing ")" of 3. No ")" character exists between the opening "(" and closing ")" of
...@@ -68,7 +68,7 @@ config_file.close() ...@@ -68,7 +68,7 @@ config_file.close()
# Extract the version string from the AC_INIT macro # Extract the version string from the AC_INIT macro
# The following init_expression means: # The following init_expression means:
# Extract three integers separated by periods and surrounded by squre # Extract three integers separated by periods and surrounded by square
# brackets(e.g. "[1.0.1]") between "AC_INIT(" and ")". Do not be greedy # 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 # (*? is the non-greedy flag) since that would pull in everything between
# the first "(" and the last ")" in the file. # the first "(" and the last ")" in the file.
...@@ -88,7 +88,7 @@ file_data = """// ...@@ -88,7 +88,7 @@ file_data = """//
// is executed in a "Run Script" build phase when creating gtest.framework. This // 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 // 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 // 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 #define GTEST_VERSIONINFO_SHORT %s.%s
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment