Skip to content

Commit

Permalink
Merge pull request google#2170 from ngie-eign:issue-2146-ver2
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 244069956
  • Loading branch information
gennadiycivil committed Apr 18, 2019
2 parents 9f893b9 + 3829b84 commit a0d60be
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 79 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
[![Build Status](https://api.travis-ci.org/google/googletest.svg?branch=master)](https://travis-ci.org/google/googletest)
[![Build status](https://ci.appveyor.com/api/projects/status/4o38plt0xbo1ubc8/branch/master?svg=true)](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master)

**PR FREEZE COMING SOON**

We are working on a large refactoring that would make it hard to accept external PRs. *Really Soon Now* we will not be accepting new PRs until the refactoring has been completed.

**Future Plans**:
* 1.8.x Release - [the 1.8.x](https://github.com/google/googletest/releases/tag/release-1.8.1) is the last release that works with pre-C++11 compilers. The 1.8.x will not accept any requests for any new features and any bugfix requests will only be accepted if proven "critical"
* Post 1.8.x - work to improve/cleanup/pay technical debt. When this work is completed there will be a 1.9.x tagged release
Expand Down
2 changes: 1 addition & 1 deletion googlemock/docs/ForDummies.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If all this seems too abstract for you, don't worry - the most important thing t
Using Google Mock involves three basic steps:

1. Use some simple macros to describe the interface you want to mock, and they will expand to the implementation of your mock class;
1. Create some mock objects and specify their expectations and behavior using an intuitive syntax;
1. Create some mock objects and specify its expectations and behavior using an intuitive syntax;
1. Exercise code that uses the mock objects. Google Mock will catch any violation of the expectations as soon as it arises.

# Why Google Mock? #
Expand Down
23 changes: 13 additions & 10 deletions googlemock/test/gmock-matchers_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4310,8 +4310,11 @@ TEST(ResultOfTest, WorksForPolymorphicFunctorsIgnoringResultType) {
}

TEST(ResultOfTest, WorksForLambdas) {
Matcher<int> matcher =
ResultOf([](int str_len) { return std::string(str_len, 'x'); }, "xxx");
Matcher<int> matcher = ResultOf(
[](int str_len) {
return std::string(static_cast<size_t>(str_len), 'x');
},
"xxx");
EXPECT_TRUE(matcher.Matches(3));
EXPECT_FALSE(matcher.Matches(1));
}
Expand Down Expand Up @@ -5812,11 +5815,11 @@ class BacktrackingBPMTest : public ::testing::Test { };

// Tests the MaxBipartiteMatching algorithm with square matrices.
// The single int param is the # of nodes on each of the left and right sides.
class BipartiteTest : public ::testing::TestWithParam<int> { };
class BipartiteTest : public ::testing::TestWithParam<size_t> {};

// Verify all match graphs up to some moderate number of edges.
TEST_P(BipartiteTest, Exhaustive) {
int nodes = GetParam();
size_t nodes = GetParam();
MatchMatrix graph(nodes, nodes);
do {
ElementMatcherPairs matches =
Expand All @@ -5841,7 +5844,7 @@ TEST_P(BipartiteTest, Exhaustive) {
}

INSTANTIATE_TEST_SUITE_P(AllGraphs, BipartiteTest,
::testing::Range(0, 5));
::testing::Range(size_t{0}, size_t{5}));

// Parameterized by a pair interpreted as (LhsSize, RhsSize).
class BipartiteNonSquareTest
Expand All @@ -5857,7 +5860,7 @@ TEST_F(BipartiteNonSquareTest, SimpleBacktracking) {
// :.......:
// 0 1 2
MatchMatrix g(4, 3);
static const int kEdges[][2] = {{0, 2}, {1, 1}, {2, 1}, {3, 0}};
static const size_t kEdges[][2] = {{0, 2}, {1, 1}, {2, 1}, {3, 0}};
for (size_t i = 0; i < GTEST_ARRAY_SIZE_(kEdges); ++i) {
g.SetEdge(kEdges[i][0], kEdges[i][1], true);
}
Expand Down Expand Up @@ -5902,15 +5905,15 @@ class BipartiteRandomTest
TEST_P(BipartiteRandomTest, LargerNets) {
int nodes = GetParam().first;
int iters = GetParam().second;
MatchMatrix graph(nodes, nodes);
MatchMatrix graph(static_cast<size_t>(nodes), static_cast<size_t>(nodes));

testing::internal::Int32 seed = GTEST_FLAG(random_seed);
auto seed = static_cast<testing::internal::UInt32>(GTEST_FLAG(random_seed));
if (seed == 0) {
seed = static_cast<testing::internal::Int32>(time(nullptr));
seed = static_cast<testing::internal::UInt32>(time(nullptr));
}

for (; iters > 0; --iters, ++seed) {
srand(static_cast<int>(seed));
srand(static_cast<unsigned int>(seed));
graph.Randomize();
EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),
internal::FindMaxBipartiteMatching(graph).size())
Expand Down
2 changes: 1 addition & 1 deletion googletest/cmake/internal_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ macro(config_compiler_and_linker)
# http://stackoverflow.com/questions/3232669 explains the issue.
set(cxx_base_flags "${cxx_base_flags} -wd4702")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(cxx_base_flags "-Wall -Wshadow -Werror -Wno-error=sign-conversion")
set(cxx_base_flags "-Wall -Wshadow -Werror -Wconversion")
set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions")
set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls")
Expand Down
2 changes: 1 addition & 1 deletion googletest/include/gtest/internal/gtest-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ class TypeParameterizedTest {
// list.
MakeAndRegisterTestInfo(
(std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
"/" + type_names[index])
"/" + type_names[static_cast<size_t>(index)])
.c_str(),
StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
GetTypeName<Type>().c_str(),
Expand Down
3 changes: 3 additions & 0 deletions googletest/include/gtest/internal/gtest-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ class GTEST_API_ String {
// Formats an int value as "%X".
static std::string FormatHexInt(int value);

// Formats an int value as "%X".
static std::string FormatHexUInt32(UInt32 value);

// Formats a byte as "%02X".
static std::string FormatByte(unsigned char value);

Expand Down
7 changes: 4 additions & 3 deletions googletest/src/gtest-death-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {

if (!use_fork) {
static const bool stack_grows_down = StackGrowsDown();
const size_t stack_size = getpagesize();
const auto stack_size = static_cast<size_t>(getpagesize());
// MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, 0);
Expand All @@ -1370,8 +1370,9 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
void* const stack_top =
static_cast<char*>(stack) +
(stack_grows_down ? stack_size - kMaxStackAlignment : 0);
GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment &&
reinterpret_cast<intptr_t>(stack_top) % kMaxStackAlignment == 0);
GTEST_DEATH_TEST_CHECK_(
static_cast<size_t>(stack_size) > kMaxStackAlignment &&
reinterpret_cast<uintptr_t>(stack_top) % kMaxStackAlignment == 0);

child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);

Expand Down
2 changes: 1 addition & 1 deletion googletest/src/gtest-filepath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ FilePath FilePath::RemoveFileName() const {
const char* const last_sep = FindLastPathSeparator();
std::string dir;
if (last_sep) {
dir = std::string(c_str(), last_sep + 1 - c_str());
dir = std::string(c_str(), static_cast<size_t>(last_sep + 1 - c_str()));
} else {
dir = kCurrentDirectoryString;
}
Expand Down
18 changes: 11 additions & 7 deletions googletest/src/gtest-internal-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ void ForEach(const Container& c, Functor functor) {
// in range [0, v.size()).
template <typename E>
inline E GetElementOr(const std::vector<E>& v, int i, E default_value) {
return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i];
return (i < 0 || i >= static_cast<int>(v.size())) ? default_value
: v[static_cast<size_t>(i)];
}

// Performs an in-place shuffle of a range of the vector's elements.
Expand All @@ -320,8 +321,11 @@ void ShuffleRange(internal::Random* random, int begin, int end,
// http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
for (int range_width = end - begin; range_width >= 2; range_width--) {
const int last_in_range = begin + range_width - 1;
const int selected = begin + random->Generate(range_width);
std::swap((*v)[selected], (*v)[last_in_range]);
const int selected =
begin +
static_cast<int>(random->Generate(static_cast<UInt32>(range_width)));
std::swap((*v)[static_cast<size_t>(selected)],
(*v)[static_cast<size_t>(last_in_range)]);
}
}

Expand Down Expand Up @@ -586,7 +590,7 @@ class GTEST_API_ UnitTestImpl {
// total_test_suite_count() - 1. If i is not in that range, returns NULL.
const TestSuite* GetTestSuite(int i) const {
const int index = GetElementOr(test_suite_indices_, i, -1);
return index < 0 ? nullptr : test_suites_[i];
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(i)];
}

// Legacy API is deprecated but still available
Expand All @@ -598,7 +602,7 @@ class GTEST_API_ UnitTestImpl {
// total_test_suite_count() - 1. If i is not in that range, returns NULL.
TestSuite* GetMutableSuiteCase(int i) {
const int index = GetElementOr(test_suite_indices_, i, -1);
return index < 0 ? nullptr : test_suites_[index];
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(index)];
}

// Provides access to the event listener list.
Expand Down Expand Up @@ -1083,8 +1087,8 @@ class StreamingListener : public EmptyTestEventListener {
GTEST_CHECK_(sockfd_ != -1)
<< "Send() can be called only when there is a connection.";

const int len = static_cast<int>(message.length());
if (write(sockfd_, message.c_str(), len) != len) {
const auto len = static_cast<size_t>(message.length());
if (write(sockfd_, message.c_str(), len) != static_cast<ssize_t>(len)) {
GTEST_LOG_(WARNING)
<< "stream_result_to: failed to stream to "
<< host_name_ << ":" << port_num_;
Expand Down
4 changes: 2 additions & 2 deletions googletest/src/gtest-port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ T ReadProcFileField(const std::string& filename, int field) {
size_t GetThreadCount() {
const std::string filename =
(Message() << "/proc/" << getpid() << "/stat").GetString();
return ReadProcFileField<int>(filename, 19);
return ReadProcFileField<size_t>(filename, 19);
}

#elif GTEST_OS_MAC
Expand Down Expand Up @@ -175,7 +175,7 @@ size_t GetThreadCount() {
if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
return 0;
}
return KP_NLWP(info);
return static_cast<size_t>(KP_NLWP(info));
}
#elif GTEST_OS_OPENBSD

Expand Down
2 changes: 1 addition & 1 deletion googletest/src/gtest-test-part.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {
internal::posix::Abort();
}

return array_[index];
return array_[static_cast<size_t>(index)];
}

// Returns the number of TestPartResult objects in the array.
Expand Down
Loading

0 comments on commit a0d60be

Please sign in to comment.