forked from boostorg/unordered
Merged revisions 42856-42881 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r42880 | danieljames | 2008-01-20 16:10:43 +0000 (Sun, 20 Jan 2008) | 17 lines Simplify the tests a little: Add a parameter to random_values to control what sort of values it generates. This means that instead of using equivalent_object to test collisions (which was a total hack) we now just need another parameter. This requires some meta programming to act differently for maps and sets. Because of this pairs no longer need to be generated so remove the code for doing that (which doesn't work on some compilers). Remove the generator object, just call generate directly. Remove some of the tests using int containers, they didn't really add to anthing other than the compile time (some tests are timing out). ........ [SVN r42882]
This commit is contained in:
@@ -23,6 +23,7 @@ namespace test
|
||||
class less;
|
||||
class equal_to;
|
||||
template <class T> class allocator;
|
||||
object generate(object const*);
|
||||
|
||||
class object
|
||||
{
|
||||
@@ -62,44 +63,6 @@ namespace test
|
||||
}
|
||||
};
|
||||
|
||||
// This object is usd to test how well the containers cope with equivalent keys.
|
||||
class equivalent_object
|
||||
{
|
||||
friend class hash;
|
||||
friend class equal_to;
|
||||
friend class less;
|
||||
int tag1_, tag2_;
|
||||
public:
|
||||
explicit equivalent_object(int t1 = 0, int t2 = 0) : tag1_(t1), tag2_(t2) {}
|
||||
|
||||
~equivalent_object() {
|
||||
tag1_ = -1;
|
||||
tag2_ = -1;
|
||||
}
|
||||
|
||||
friend bool operator==(equivalent_object const& x1, equivalent_object const& x2) {
|
||||
return x1.tag1_ == x2.tag1_;
|
||||
}
|
||||
|
||||
friend bool operator!=(equivalent_object const& x1, equivalent_object const& x2) {
|
||||
return x1.tag1_ != x2.tag1_;
|
||||
}
|
||||
|
||||
friend bool operator<(equivalent_object const& x1, equivalent_object const& x2) {
|
||||
return x1.tag1_ < x2.tag1_;
|
||||
}
|
||||
|
||||
friend equivalent_object generate(equivalent_object const*) {
|
||||
signed char* x = 0;
|
||||
return equivalent_object(generate(x), generate(x));
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& out, equivalent_object const& o)
|
||||
{
|
||||
return out<<"("<<o.tag1_<<","<<o.tag2_<<")";
|
||||
}
|
||||
};
|
||||
|
||||
class hash
|
||||
{
|
||||
int type_;
|
||||
@@ -117,10 +80,6 @@ namespace test
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t operator()(equivalent_object const& x) const {
|
||||
return x.tag1_;
|
||||
}
|
||||
|
||||
std::size_t operator()(int x) const {
|
||||
return x;
|
||||
}
|
||||
@@ -151,10 +110,6 @@ namespace test
|
||||
}
|
||||
}
|
||||
|
||||
bool operator()(equivalent_object const& x1, equivalent_object const& x2) const {
|
||||
return x1 < x2;
|
||||
}
|
||||
|
||||
std::size_t operator()(int x1, int x2) const {
|
||||
return x1 < x2;
|
||||
}
|
||||
@@ -181,10 +136,6 @@ namespace test
|
||||
}
|
||||
}
|
||||
|
||||
bool operator()(equivalent_object const& x1, equivalent_object const& x2) const {
|
||||
return x1 == x2;
|
||||
}
|
||||
|
||||
std::size_t operator()(int x1, int x2) const {
|
||||
return x1 == x2;
|
||||
}
|
||||
@@ -294,13 +245,6 @@ namespace test
|
||||
y = tmp;
|
||||
}
|
||||
|
||||
void swap(test::equivalent_object& x, test::equivalent_object& y) {
|
||||
test::equivalent_object tmp;
|
||||
tmp = x;
|
||||
x = y;
|
||||
y = tmp;
|
||||
}
|
||||
|
||||
void swap(test::hash& x, test::hash& y) {
|
||||
test::hash tmp;
|
||||
tmp = x;
|
||||
|
||||
Reference in New Issue
Block a user