mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 19:37:14 +02:00
Unordered: More invariant testing.
In case there are elements in buckets that aren't in the element list. Required because the data structure has changed since the original implementation. [SVN r80226]
This commit is contained in:
@ -82,16 +82,39 @@ namespace test
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Finally, check that size matches up.
|
// Check that size matches up.
|
||||||
|
|
||||||
if(x1.size() != size) {
|
if(x1.size() != size) {
|
||||||
BOOST_ERROR("x1.size() doesn't match actual size.");
|
BOOST_ERROR("x1.size() doesn't match actual size.");
|
||||||
std::cout<<x1.size()<<"/"<<size<<std::endl;
|
std::cout<<x1.size()<<"/"<<size<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check the load factor.
|
||||||
|
|
||||||
float load_factor =
|
float load_factor =
|
||||||
static_cast<float>(size) / static_cast<float>(x1.bucket_count());
|
static_cast<float>(size) / static_cast<float>(x1.bucket_count());
|
||||||
using namespace std;
|
using namespace std;
|
||||||
if(fabs(x1.load_factor() - load_factor) > x1.load_factor() / 64)
|
if(fabs(x1.load_factor() - load_factor) > x1.load_factor() / 64)
|
||||||
BOOST_ERROR("x1.load_factor() doesn't match actual load_factor.");
|
BOOST_ERROR("x1.load_factor() doesn't match actual load_factor.");
|
||||||
|
|
||||||
|
// Check that size in the buckets matches up.
|
||||||
|
|
||||||
|
BOOST_DEDUCED_TYPENAME X::size_type bucket_size = 0;
|
||||||
|
|
||||||
|
for (BOOST_DEDUCED_TYPENAME X::size_type
|
||||||
|
i = 0; i < x1.bucket_count(); ++i)
|
||||||
|
{
|
||||||
|
for (BOOST_DEDUCED_TYPENAME X::const_local_iterator
|
||||||
|
begin = x1.begin(i), end = x1.end(i); begin != end; ++begin)
|
||||||
|
{
|
||||||
|
++bucket_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(x1.size() != bucket_size) {
|
||||||
|
BOOST_ERROR("x1.size() doesn't match bucket size.");
|
||||||
|
std::cout<<x1.size()<<"/"<<bucket_size<<std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user