forked from boostorg/unordered
Fix signed conversion warnings.
This commit is contained in:
@@ -89,8 +89,9 @@ void container_test(X& r, T const&)
|
||||
|
||||
// size_type can represent any non-negative value type of difference_type
|
||||
// I'm not sure about either of these tests...
|
||||
size_type max_diff((std::numeric_limits<difference_type>::max)());
|
||||
difference_type converted_diff(max_diff);
|
||||
size_type max_diff = static_cast<size_type>(
|
||||
(std::numeric_limits<difference_type>::max)());
|
||||
difference_type converted_diff(static_cast<difference_type>(max_diff));
|
||||
BOOST_TEST((std::numeric_limits<difference_type>::max)()
|
||||
== converted_diff);
|
||||
|
||||
|
||||
@@ -25,9 +25,11 @@ namespace equality_tests
|
||||
return x % 1000 == y % 1000;
|
||||
}
|
||||
|
||||
int operator()(int x) const
|
||||
std::size_t operator()(int x) const
|
||||
{
|
||||
return alt_hash_ ? x % 250 : (x + 5) % 250;
|
||||
return alt_hash_ ?
|
||||
static_cast<std::size_t>(x % 250) :
|
||||
static_cast<std::size_t>((x + 5) % 250);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -43,19 +43,19 @@ void write_container(Container const& x)
|
||||
// Make everything collide - for testing erase in a single bucket.
|
||||
struct collision_hash
|
||||
{
|
||||
int operator()(int) const { return 0; }
|
||||
std::size_t operator()(int) const { return 0; }
|
||||
};
|
||||
|
||||
// For testing erase in 2 buckets.
|
||||
struct collision2_hash
|
||||
{
|
||||
int operator()(int x) const { return x & 1; }
|
||||
std::size_t operator()(int x) const { return static_cast<std::size_t>(x & 1); }
|
||||
};
|
||||
|
||||
// For testing erase in lots of buckets.
|
||||
struct collision3_hash
|
||||
{
|
||||
int operator()(int x) const { return x; }
|
||||
std::size_t operator()(int x) const { return static_cast<std::size_t>(x); }
|
||||
};
|
||||
|
||||
typedef boost::unordered_multimap<int, int,
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace erase_tests
|
||||
|
||||
test::seed_t initialize_seed(85638);
|
||||
|
||||
int random_value(int max) {
|
||||
std::size_t random_value(std::size_t max) {
|
||||
using namespace std;
|
||||
return rand() % max;
|
||||
return static_cast<std::size_t>(rand()) % max;
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
@@ -35,6 +35,7 @@ void erase_tests1(Container*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::const_iterator c_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::difference_type difference_type;
|
||||
|
||||
std::cerr<<"Erase by key.\n";
|
||||
{
|
||||
@@ -89,7 +90,7 @@ void erase_tests1(Container*, test::random_generator generator)
|
||||
int iterations = 0;
|
||||
while(size > 0 && !x.empty())
|
||||
{
|
||||
int index = random_value((int) x.size());
|
||||
std::size_t index = random_value(x.size());
|
||||
c_iterator prev, pos, next;
|
||||
if(index == 0) {
|
||||
prev = pos = x.begin();
|
||||
@@ -162,12 +163,14 @@ void erase_tests1(Container*, test::random_generator generator)
|
||||
iterators.push_back(x.cend());
|
||||
|
||||
while(iterators.size() > 1) {
|
||||
int start = random_value((int) iterators.size());
|
||||
int length = random_value((int) (iterators.size() - start));
|
||||
std::size_t start = random_value(iterators.size());
|
||||
std::size_t length = random_value(iterators.size() - start);
|
||||
x.erase(iterators[start], iterators[start + length]);
|
||||
iterators.erase(
|
||||
boost::next(iterators.begin(), start),
|
||||
boost::next(iterators.begin(), start + length));
|
||||
boost::next(iterators.begin(),
|
||||
static_cast<difference_type>(start)),
|
||||
boost::next(iterators.begin(),
|
||||
static_cast<difference_type>(start + length)));
|
||||
|
||||
BOOST_TEST(x.size() == iterators.size() - 1);
|
||||
BOOST_DEDUCED_TYPENAME std::vector<c_iterator>::const_iterator
|
||||
@@ -216,7 +219,7 @@ void erase_tests1(Container*, test::random_generator generator)
|
||||
int iterations = 0;
|
||||
while(size > 0 && !x.empty())
|
||||
{
|
||||
int index = random_value((int) x.size());
|
||||
std::size_t index = random_value(x.size());
|
||||
BOOST_DEDUCED_TYPENAME Container::const_iterator prev, pos, next;
|
||||
if(index == 0) {
|
||||
prev = pos = x.begin();
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace insert_tests {
|
||||
|
||||
test::seed_t initialize_seed(243432);
|
||||
|
||||
int random_value(int max) {
|
||||
std::size_t random_value(std::size_t max) {
|
||||
using namespace std;
|
||||
return rand() % max;
|
||||
return static_cast<std::size_t>(rand()) % max;
|
||||
}
|
||||
|
||||
template <class X>
|
||||
@@ -319,7 +319,7 @@ void insert_tests2(X*, test::random_generator generator)
|
||||
|
||||
BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator
|
||||
next = it;
|
||||
for (int j = random_value(20); j > 0; ++j) {
|
||||
for (std::size_t j = random_value(20); j > 0; ++j) {
|
||||
++next;
|
||||
if (next == v.end()) { break; }
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void reserve_test1(X*, test::random_generator generator)
|
||||
{
|
||||
for (int random_mlf = 0; random_mlf < 2; ++random_mlf)
|
||||
{
|
||||
for (int i = 1; i < 2000; i += i < 50 ? 1 : 13)
|
||||
for (std::size_t i = 1; i < 2000; i += i < 50 ? 1 : 13)
|
||||
{
|
||||
test::random_values<X> v(i, generator);
|
||||
|
||||
@@ -171,7 +171,7 @@ void reserve_test2(X*, test::random_generator generator)
|
||||
{
|
||||
for (int random_mlf = 0; random_mlf < 2; ++random_mlf)
|
||||
{
|
||||
for (int i = 0; i < 2000; i += i < 50 ? 1 : 13)
|
||||
for (std::size_t i = 0; i < 2000; i += i < 50 ? 1 : 13)
|
||||
{
|
||||
test::random_values<X> v(i, generator);
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace unnecessary_copy_tests
|
||||
#endif
|
||||
{
|
||||
std::size_t hash_value(unnecessary_copy_tests::count_copies const& x) {
|
||||
return x.tag_;
|
||||
return static_cast<std::size_t>(x.tag_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user