Skip to content

Commit

Permalink
Fix bogous MSVC Win32 signed/unsigned mismatch warnings in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
  • Loading branch information
phprus committed Aug 5, 2022
1 parent c2223e6 commit b730a93
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 187 deletions.
10 changes: 5 additions & 5 deletions tests/btree/btree_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ namespace {
// Make sure various methods can be invoked on a const container.
const_b.verify();
ASSERT_TRUE(!const_b.empty());
EXPECT_EQ(const_b.size(), 1);
EXPECT_GT(const_b.max_size(), 0);
EXPECT_EQ(const_b.size(), 1u);
EXPECT_GT(const_b.max_size(), 0u);
EXPECT_TRUE(const_b.contains(key_of_value(value)));
EXPECT_EQ(const_b.count(key_of_value(value)), 1);
}
Expand Down Expand Up @@ -2304,15 +2304,15 @@ namespace {

tracker.ResetCopiesMovesSwaps();
set2 = std::move(set1);
EXPECT_GE(tracker.moves(), 100);
EXPECT_GE(tracker.moves(), 100u);
}
}

TEST(Btree, EmptyTree) {
gtl::btree_set<int> s;
EXPECT_TRUE(s.empty());
EXPECT_EQ(s.size(), 0);
EXPECT_GT(s.max_size(), 0);
EXPECT_EQ(s.size(), 0u);
EXPECT_GT(s.max_size(), 0u);
}

bool IsEven(int k) { return k % 2 == 0; }
Expand Down
2 changes: 1 addition & 1 deletion tests/misc/lru_cache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TEST(CacheTest1, KeepsAllValuesWithinCapacity) {
}

size_t size = cache.size();
EXPECT_EQ(TEST2_CACHE_CAPACITY, size);
EXPECT_EQ(static_cast<size_t>(TEST2_CACHE_CAPACITY), size);
}

TEST(CacheTest1, mtKeepsAllValuesWithinCapacity) {
Expand Down
4 changes: 2 additions & 2 deletions tests/phmap/compressed_tuple_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ TEST(CompressedTupleTest, Nested) {
// MSVC has a bug where many instances of the same base class are layed out in
// the same address when using __declspec(empty_bases).
// This will be fixed in a future version of MSVC.
int expected = 1;
size_t expected = 1;
#else
int expected = 4;
size_t expected = 4;
#endif
EXPECT_EQ(expected, sizeof(y));
EXPECT_EQ(expected, empties.size());
Expand Down
6 changes: 3 additions & 3 deletions tests/phmap/container_memory_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ using ::testing::Pair;
TEST(Memory, AlignmentLargerThanBase) {
std::allocator<int8_t> alloc;
void* mem = Allocate<2>(&alloc, 3);
EXPECT_EQ(0, reinterpret_cast<uintptr_t>(mem) % 2);
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(mem) % 2);
memcpy(mem, "abc", 3);
Deallocate<2>(&alloc, mem, 3);
}

TEST(Memory, AlignmentSmallerThanBase) {
std::allocator<int64_t> alloc;
void* mem = Allocate<2>(&alloc, 3);
EXPECT_EQ(0, reinterpret_cast<uintptr_t>(mem) % 2);
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(mem) % 2);
memcpy(mem, "abc", 3);
Deallocate<2>(&alloc, mem, 3);
}
Expand Down Expand Up @@ -102,7 +102,7 @@ TEST(PairArgs, Piecewise) {
}

TEST(WithConstructed, Simple) {
EXPECT_EQ(1, WithConstructed<std::string_view>(
EXPECT_EQ(1u, WithConstructed<std::string_view>(
std::make_tuple(std::string("a")),
[](std::string_view str) { return str.size(); }));
}
Expand Down
16 changes: 8 additions & 8 deletions tests/phmap/hash_policy_testing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ namespace {

TEST(_, Hash) {
StatefulTestingHash h1;
EXPECT_EQ(1, h1.id());
EXPECT_EQ(1u, h1.id());
StatefulTestingHash h2;
EXPECT_EQ(2, h2.id());
EXPECT_EQ(2u, h2.id());
StatefulTestingHash h1c(h1);
EXPECT_EQ(1, h1c.id());
EXPECT_EQ(1u, h1c.id());
StatefulTestingHash h2m(std::move(h2));
EXPECT_EQ(2, h2m.id());
EXPECT_EQ(0, h2.id());
EXPECT_EQ(2u, h2m.id());
EXPECT_EQ(0u, h2.id());
StatefulTestingHash h3;
EXPECT_EQ(3, h3.id());
EXPECT_EQ(3u, h3.id());
h3 = StatefulTestingHash();
EXPECT_EQ(4, h3.id());
EXPECT_EQ(4u, h3.id());
h3 = std::move(h1);
EXPECT_EQ(1, h3.id());
EXPECT_EQ(1u, h3.id());
}

} // namespace
Expand Down
8 changes: 4 additions & 4 deletions tests/phmap/parallel_hash_set_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ TEST(THIS_TEST_NAME, EmplaceSingle) {
// emplace_single insert a value if not already present, else removes it
for (int i=0; i<12; ++i)
m.emplace_single(i, [i](const Set::constructor& ctor) { ctor(i); });
EXPECT_EQ(m.count(0), 1);
EXPECT_EQ(m.count(1), 0);
EXPECT_EQ(m.count(2), 1);
EXPECT_EQ(m.count(11), 0);
EXPECT_EQ(m.count(0), 1u);
EXPECT_EQ(m.count(1), 0u);
EXPECT_EQ(m.count(2), 1u);
EXPECT_EQ(m.count(11), 0u);
}

} // namespace
Expand Down

0 comments on commit b730a93

Please sign in to comment.