summaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorEnji Cooper <yaneurabeya@gmail.com>2019-03-08 19:09:00 (GMT)
committerEnji Cooper <yaneurabeya@gmail.com>2019-04-06 04:30:19 (GMT)
commit3829b84e9927a2a77a7634a8e7b010cc57095e1b (patch)
tree14762102e4f3bb5c34ff91711ce181a95574b812 /googlemock
parent5ba69d5cb93779fba14bf438dfdaf589e2b92071 (diff)
downloadgoogletest-3829b84e9927a2a77a7634a8e7b010cc57095e1b.zip
googletest-3829b84e9927a2a77a7634a8e7b010cc57095e1b.tar.gz
googletest-3829b84e9927a2a77a7634a8e7b010cc57095e1b.tar.bz2
clang: fix `-Wsign-conversion` errors
Cast some values as their unsigned equivalents or `size_t` to match the parameter type used for the template object under test. Also, provide UInt32 equivalent delegate methods for some callers (with int-equivalents for backwards compatibility). This closes #2146. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/test/gmock-matchers_test.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index 8bdad63..5a5a786 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -4311,7 +4311,8 @@ TEST(ResultOfTest, WorksForPolymorphicFunctorsIgnoringResultType) {
TEST(ResultOfTest, WorksForLambdas) {
Matcher<int> matcher =
- ResultOf([](int str_len) { return std::string(str_len, 'x'); }, "xxx");
+ 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));
}
@@ -5812,11 +5813,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 =
@@ -5841,7 +5842,8 @@ TEST_P(BipartiteTest, Exhaustive) {
}
INSTANTIATE_TEST_SUITE_P(AllGraphs, BipartiteTest,
- ::testing::Range(0, 5));
+ ::testing::Range(static_cast<size_t>(0),
+ static_cast<size_t>(5)));
// Parameterized by a pair interpreted as (LhsSize, RhsSize).
class BipartiteNonSquareTest
@@ -5857,7 +5859,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);
}
@@ -5902,15 +5904,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())