Skip to content

Commit

Permalink
Fixed a few more Wsign-conversion warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
OleErikPeistorpet committed Jun 2, 2024
1 parent e74567a commit fc05f9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dynarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ is_trivially_relocatable<Alloc> specify_trivial_relocate(dynarray<T, Alloc>);

//! Overloads generic unordered_erase(RandomAccessContainer &, Integral) (in range_algo.h)
template< typename T, typename A > inline
void unordered_erase(dynarray<T, A> & d, size_t index) { d.unordered_erase(d.begin() + index); }
void unordered_erase(dynarray<T, A> & d, ptrdiff_t index) { d.unordered_erase(d.begin() + index); }

#if OEL_MEM_BOUND_DEBUG_LVL
inline namespace debug
Expand Down
25 changes: 13 additions & 12 deletions unit_test/dynarray_mutate_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,33 +440,34 @@ TEST_F(dynarrayTest, insertRTrivial)

TEST_F(dynarrayTest, insertR)
{
size_t const initSize = 2;
using oel::ssize;
constexpr ptrdiff_t initSize{2};
std::array<TrivialRelocat, 2> const toInsert{TrivialRelocat{-1}, TrivialRelocat{-2}};
for (auto nReserve : {initSize, initSize + toInsert.size()})
for (size_t insertOffset = 0; insertOffset <= initSize; ++insertOffset)
for (unsigned countThrow = 0; countThrow <= toInsert.size(); ++countThrow)
for (auto nReserve : {initSize, initSize + ssize(toInsert)})
for (ptrdiff_t insertOffset{}; insertOffset <= initSize; ++insertOffset)
for (int countThrow{}; countThrow <= ssize(toInsert); ++countThrow)
{ {
dynarray<TrivialRelocat> dest(oel::reserve, nReserve);
dynarray<TrivialRelocat> dest(oel::reserve, oel::as_unsigned(nReserve));
dest.emplace_back(1);
dest.emplace_back(2);

if (countThrow < toInsert.size())
if (countThrow < ssize(toInsert))
{
#if OEL_HAS_EXCEPTIONS
TrivialRelocat::countToThrowOn = oel::as_signed(countThrow);
TrivialRelocat::countToThrowOn = countThrow;
EXPECT_THROW( dest.insert_range(dest.begin() + insertOffset, toInsert), TestException );
#endif
EXPECT_TRUE(initSize <= dest.size() and dest.size() <= initSize + countThrow);
EXPECT_TRUE(initSize <= ssize(dest) and ssize(dest) <= initSize + countThrow);
}
else
{ dest.insert_range(dest.begin() + insertOffset, toInsert);

EXPECT_TRUE(dest.size() == initSize + toInsert.size());
EXPECT_TRUE(ssize(dest) == initSize + ssize(toInsert));
}
if (dest.size() > initSize)
{
for (unsigned i = 0; i < countThrow; ++i)
EXPECT_TRUE( *toInsert[i] == *dest[i + insertOffset] );
for (size_t i{}; i < oel::as_unsigned(countThrow); ++i)
EXPECT_TRUE( *toInsert[i] == *dest[i + oel::as_unsigned(insertOffset)] );
}
if (insertOffset == 0)
{
Expand All @@ -483,7 +484,7 @@ TEST_F(dynarrayTest, insertR)
EXPECT_EQ(2, *dest.back());
}
}
EXPECT_EQ(TrivialRelocat::nConstructions, TrivialRelocat::nDestruct + oel::ssize(toInsert));
EXPECT_EQ(TrivialRelocat::nConstructions, TrivialRelocat::nDestruct + ssize(toInsert));
}
}

Expand Down

0 comments on commit fc05f9e

Please sign in to comment.