From f8c44a0ae449dd78d703e94c295287d051560217 Mon Sep 17 00:00:00 2001 From: kosak Date: Tue, 28 Apr 2015 21:59:44 +0000 Subject: [PATCH] Work around some unsigned->signed warnings in our tests/. Thanks to Diego Barrios Romero . --- test/gtest-death-test_test.cc | 24 ++++++++++++------------ test/gtest-listener_test.cc | 11 ++++++----- test/gtest-port_test.cc | 4 ++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/test/gtest-death-test_test.cc b/test/gtest-death-test_test.cc index b25bc229..d62cf6ef 100644 --- a/test/gtest-death-test_test.cc +++ b/test/gtest-death-test_test.cc @@ -887,9 +887,9 @@ class MockDeathTestFactory : public DeathTestFactory { // Accessors. int AssumeRoleCalls() const { return assume_role_calls_; } int WaitCalls() const { return wait_calls_; } - int PassedCalls() const { return passed_args_.size(); } + size_t PassedCalls() const { return passed_args_.size(); } bool PassedArgument(int n) const { return passed_args_[n]; } - int AbortCalls() const { return abort_args_.size(); } + size_t AbortCalls() const { return abort_args_.size(); } DeathTest::AbortReason AbortArgument(int n) const { return abort_args_[n]; } @@ -1050,8 +1050,8 @@ TEST_F(MacroLogicDeathTest, NothingHappens) { EXPECT_FALSE(flag); EXPECT_EQ(0, factory_->AssumeRoleCalls()); EXPECT_EQ(0, factory_->WaitCalls()); - EXPECT_EQ(0, factory_->PassedCalls()); - EXPECT_EQ(0, factory_->AbortCalls()); + EXPECT_EQ(0U, factory_->PassedCalls()); + EXPECT_EQ(0U, factory_->AbortCalls()); EXPECT_FALSE(factory_->TestDeleted()); } @@ -1065,9 +1065,9 @@ TEST_F(MacroLogicDeathTest, ChildExitsSuccessfully) { EXPECT_FALSE(flag); EXPECT_EQ(1, factory_->AssumeRoleCalls()); EXPECT_EQ(1, factory_->WaitCalls()); - ASSERT_EQ(1, factory_->PassedCalls()); + ASSERT_EQ(1U, factory_->PassedCalls()); EXPECT_FALSE(factory_->PassedArgument(0)); - EXPECT_EQ(0, factory_->AbortCalls()); + EXPECT_EQ(0U, factory_->AbortCalls()); EXPECT_TRUE(factory_->TestDeleted()); } @@ -1080,9 +1080,9 @@ TEST_F(MacroLogicDeathTest, ChildExitsUnsuccessfully) { EXPECT_FALSE(flag); EXPECT_EQ(1, factory_->AssumeRoleCalls()); EXPECT_EQ(1, factory_->WaitCalls()); - ASSERT_EQ(1, factory_->PassedCalls()); + ASSERT_EQ(1U, factory_->PassedCalls()); EXPECT_TRUE(factory_->PassedArgument(0)); - EXPECT_EQ(0, factory_->AbortCalls()); + EXPECT_EQ(0U, factory_->AbortCalls()); EXPECT_TRUE(factory_->TestDeleted()); } @@ -1096,8 +1096,8 @@ TEST_F(MacroLogicDeathTest, ChildPerformsReturn) { EXPECT_TRUE(flag); EXPECT_EQ(1, factory_->AssumeRoleCalls()); EXPECT_EQ(0, factory_->WaitCalls()); - EXPECT_EQ(0, factory_->PassedCalls()); - EXPECT_EQ(1, factory_->AbortCalls()); + EXPECT_EQ(0U, factory_->PassedCalls()); + EXPECT_EQ(1U, factory_->AbortCalls()); EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT, factory_->AbortArgument(0)); EXPECT_TRUE(factory_->TestDeleted()); @@ -1112,13 +1112,13 @@ TEST_F(MacroLogicDeathTest, ChildDoesNotDie) { EXPECT_TRUE(flag); EXPECT_EQ(1, factory_->AssumeRoleCalls()); EXPECT_EQ(0, factory_->WaitCalls()); - EXPECT_EQ(0, factory_->PassedCalls()); + EXPECT_EQ(0U, factory_->PassedCalls()); // This time there are two calls to Abort: one since the test didn't // die, and another from the ReturnSentinel when it's destroyed. The // sentinel normally isn't destroyed if a test doesn't die, since // _exit(2) is called in that case by ForkingDeathTest, but not by // our MockDeathTest. - ASSERT_EQ(2, factory_->AbortCalls()); + ASSERT_EQ(2U, factory_->AbortCalls()); EXPECT_EQ(DeathTest::TEST_DID_NOT_DIE, factory_->AbortArgument(0)); EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT, diff --git a/test/gtest-listener_test.cc b/test/gtest-listener_test.cc index 99662cff..90747685 100644 --- a/test/gtest-listener_test.cc +++ b/test/gtest-listener_test.cc @@ -176,16 +176,16 @@ using ::testing::internal::EventRecordingListener; void VerifyResults(const std::vector& data, const char* const* expected_data, - int expected_data_size) { - const int actual_size = data.size(); + size_t expected_data_size) { + const size_t actual_size = data.size(); // If the following assertion fails, a new entry will be appended to // data. Hence we save data.size() first. EXPECT_EQ(expected_data_size, actual_size); // Compares the common prefix. - const int shorter_size = expected_data_size <= actual_size ? + const size_t shorter_size = expected_data_size <= actual_size ? expected_data_size : actual_size; - int i = 0; + size_t i = 0; for (; i < shorter_size; ++i) { ASSERT_STREQ(expected_data[i], data[i].c_str()) << "at position " << i; @@ -193,7 +193,8 @@ void VerifyResults(const std::vector& data, // Prints extra elements in the actual data. for (; i < actual_size; ++i) { - printf(" Actual event #%d: %s\n", i, data[i].c_str()); + printf(" Actual event #%lu: %s\n", + static_cast(i), data[i].c_str()); } } diff --git a/test/gtest-port_test.cc b/test/gtest-port_test.cc index 370c952b..c904f1e7 100644 --- a/test/gtest-port_test.cc +++ b/test/gtest-port_test.cc @@ -1219,11 +1219,11 @@ class DestructorTracker { } private: - static int GetNewIndex() { + static size_t GetNewIndex() { DestructorCall::List().push_back(new DestructorCall); return DestructorCall::List().size() - 1; } - const int index_; + const size_t index_; GTEST_DISALLOW_ASSIGN_(DestructorTracker); };