fix signed warning errors in unittests

A bunch of gtest assert statements fail due to signed warnings as
unadorned constants are treated as signed integers.  Mark them all
unsigned to avoid that.

One example (focus on the "[with ...]" blocks that show the types):
In file included from src/breakpad_googletest_includes.h:33:0,
                 from src/common/memory_unittest.cc:30:
src/testing/gtest/include/gtest/gtest.h: In instantiation of 'testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = int; T2 = long unsigned int]':
src/testing/gtest/include/gtest/gtest.h:1524:23: required from 'static testing::AssertionResult testing::internal::EqHelper<true>::Compare(const char*, const char*, const T1&, const T2&, typename testing::internal::EnableIf<(! testing::internal::is_pointer<T2>::value)>::type*) [with T1 = int; T2 = long unsigned int; typename testing::internal::EnableIf<(! testing::internal::is_pointer<T2>::value)>::type = void]'
src/common/memory_unittest.cc:41:246: required from here
src/testing/gtest/include/gtest/gtest.h:1448:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
   if (expected == actual) {
                ^
cc1plus: some warnings being treated as errors
Makefile:5180: recipe for target 'src/common/src_client_linux_linux_client_unittest_shlib-memory_unittest.o' failed
make[2]: *** [src/common/src_client_linux_linux_client_unittest_shlib-memory_unittest.o] Error 1

R=ted.mielczarek@gmail.com

Review URL: https://codereview.chromium.org/2013893003 .
This commit is contained in:
Mike Frysinger 2016-05-26 10:09:46 -04:00
parent 6368037ef2
commit bad9e55ea5
2 changed files with 13 additions and 13 deletions

View file

@ -38,13 +38,13 @@ typedef testing::Test PageAllocatorTest;
TEST(PageAllocatorTest, Setup) { TEST(PageAllocatorTest, Setup) {
PageAllocator allocator; PageAllocator allocator;
EXPECT_EQ(0, allocator.pages_allocated()); EXPECT_EQ(0U, allocator.pages_allocated());
} }
TEST(PageAllocatorTest, SmallObjects) { TEST(PageAllocatorTest, SmallObjects) {
PageAllocator allocator; PageAllocator allocator;
EXPECT_EQ(0, allocator.pages_allocated()); EXPECT_EQ(0U, allocator.pages_allocated());
for (unsigned i = 1; i < 1024; ++i) { for (unsigned i = 1; i < 1024; ++i) {
uint8_t *p = reinterpret_cast<uint8_t*>(allocator.Alloc(i)); uint8_t *p = reinterpret_cast<uint8_t*>(allocator.Alloc(i));
ASSERT_FALSE(p == NULL); ASSERT_FALSE(p == NULL);
@ -55,10 +55,10 @@ TEST(PageAllocatorTest, SmallObjects) {
TEST(PageAllocatorTest, LargeObject) { TEST(PageAllocatorTest, LargeObject) {
PageAllocator allocator; PageAllocator allocator;
EXPECT_EQ(0, allocator.pages_allocated()); EXPECT_EQ(0U, allocator.pages_allocated());
uint8_t *p = reinterpret_cast<uint8_t*>(allocator.Alloc(10000)); uint8_t *p = reinterpret_cast<uint8_t*>(allocator.Alloc(10000));
ASSERT_FALSE(p == NULL); ASSERT_FALSE(p == NULL);
EXPECT_EQ(3, allocator.pages_allocated()); EXPECT_EQ(3U, allocator.pages_allocated());
for (unsigned i = 1; i < 10; ++i) { for (unsigned i = 1; i < 10; ++i) {
uint8_t *p = reinterpret_cast<uint8_t*>(allocator.Alloc(i)); uint8_t *p = reinterpret_cast<uint8_t*>(allocator.Alloc(i));
ASSERT_FALSE(p == NULL); ASSERT_FALSE(p == NULL);
@ -79,7 +79,7 @@ TEST(WastefulVectorTest, Setup) {
TEST(WastefulVectorTest, Simple) { TEST(WastefulVectorTest, Simple) {
PageAllocator allocator_; PageAllocator allocator_;
EXPECT_EQ(0, allocator_.pages_allocated()); EXPECT_EQ(0U, allocator_.pages_allocated());
wasteful_vector<unsigned> v(&allocator_); wasteful_vector<unsigned> v(&allocator_);
for (unsigned i = 0; i < 256; ++i) { for (unsigned i = 0; i < 256; ++i) {
@ -89,7 +89,7 @@ TEST(WastefulVectorTest, Simple) {
} }
ASSERT_FALSE(v.empty()); ASSERT_FALSE(v.empty());
ASSERT_EQ(v.size(), 256u); ASSERT_EQ(v.size(), 256u);
EXPECT_EQ(1, allocator_.pages_allocated()); EXPECT_EQ(1U, allocator_.pages_allocated());
for (unsigned i = 0; i < 256; ++i) for (unsigned i = 0; i < 256; ++i)
ASSERT_EQ(v[i], i); ASSERT_EQ(v[i], i);
} }
@ -97,7 +97,7 @@ TEST(WastefulVectorTest, Simple) {
TEST(WastefulVectorTest, UsesPageAllocator) { TEST(WastefulVectorTest, UsesPageAllocator) {
PageAllocator allocator_; PageAllocator allocator_;
wasteful_vector<unsigned> v(&allocator_); wasteful_vector<unsigned> v(&allocator_);
EXPECT_EQ(1, allocator_.pages_allocated()); EXPECT_EQ(1U, allocator_.pages_allocated());
v.push_back(1); v.push_back(1);
ASSERT_TRUE(allocator_.OwnsPointer(&v[0])); ASSERT_TRUE(allocator_.OwnsPointer(&v[0]));
@ -105,20 +105,20 @@ TEST(WastefulVectorTest, UsesPageAllocator) {
TEST(WastefulVectorTest, AutoWastefulVector) { TEST(WastefulVectorTest, AutoWastefulVector) {
PageAllocator allocator_; PageAllocator allocator_;
EXPECT_EQ(0, allocator_.pages_allocated()); EXPECT_EQ(0U, allocator_.pages_allocated());
auto_wasteful_vector<unsigned, 4> v(&allocator_); auto_wasteful_vector<unsigned, 4> v(&allocator_);
EXPECT_EQ(0, allocator_.pages_allocated()); EXPECT_EQ(0U, allocator_.pages_allocated());
v.push_back(1); v.push_back(1);
EXPECT_EQ(0, allocator_.pages_allocated()); EXPECT_EQ(0U, allocator_.pages_allocated());
EXPECT_FALSE(allocator_.OwnsPointer(&v[0])); EXPECT_FALSE(allocator_.OwnsPointer(&v[0]));
v.resize(4); v.resize(4);
EXPECT_EQ(0, allocator_.pages_allocated()); EXPECT_EQ(0U, allocator_.pages_allocated());
EXPECT_FALSE(allocator_.OwnsPointer(&v[0])); EXPECT_FALSE(allocator_.OwnsPointer(&v[0]));
v.resize(10); v.resize(10);
EXPECT_EQ(1, allocator_.pages_allocated()); EXPECT_EQ(1U, allocator_.pages_allocated());
EXPECT_TRUE(allocator_.OwnsPointer(&v[0])); EXPECT_TRUE(allocator_.OwnsPointer(&v[0]));
} }

View file

@ -414,7 +414,7 @@ TEST_F(MinidumpProcessorTest, TestBasicProcessing) {
ASSERT_EQ(state.crash_reason(), "EXCEPTION_ACCESS_VIOLATION_WRITE"); ASSERT_EQ(state.crash_reason(), "EXCEPTION_ACCESS_VIOLATION_WRITE");
ASSERT_EQ(state.crash_address(), 0x45U); ASSERT_EQ(state.crash_address(), 0x45U);
ASSERT_EQ(state.threads()->size(), size_t(1)); ASSERT_EQ(state.threads()->size(), size_t(1));
EXPECT_EQ((*state.threads())[0]->tid(), 3060); EXPECT_EQ((*state.threads())[0]->tid(), 3060U);
ASSERT_EQ(state.requesting_thread(), 0); ASSERT_EQ(state.requesting_thread(), 0);
EXPECT_EQ(1171480435U, state.time_date_stamp()); EXPECT_EQ(1171480435U, state.time_date_stamp());
EXPECT_EQ(1171480435U, state.process_create_time()); EXPECT_EQ(1171480435U, state.process_create_time());