Fix exception handling in rehash_impl

And improve tests so they will catch the error, and other similar errors.
This commit is contained in:
Daniel James
2017-05-04 19:30:18 +01:00
parent d49d0e90a8
commit 47a8c3fc67
10 changed files with 268 additions and 36 deletions
+28 -13
View File
@@ -7,6 +7,8 @@
#include "../helpers/input_iterator.hpp"
#include "../helpers/random_values.hpp"
#include "../helpers/invariants.hpp"
#include "../helpers/tracker.hpp"
template <typename T> inline void avoid_unused_warning(T const&) {}
@@ -25,7 +27,8 @@ template <class T> struct construct_test1 : public objects, test::exception_base
void run() const
{
T x;
avoid_unused_warning(x);
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
};
@@ -34,7 +37,8 @@ template <class T> struct construct_test2 : public objects, test::exception_base
void run() const
{
T x(300);
avoid_unused_warning(x);
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
};
@@ -43,7 +47,8 @@ template <class T> struct construct_test3 : public objects, test::exception_base
void run() const
{
T x(0, hash);
avoid_unused_warning(x);
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
};
@@ -52,7 +57,8 @@ template <class T> struct construct_test4 : public objects, test::exception_base
void run() const
{
T x(0, hash, equal_to);
avoid_unused_warning(x);
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
};
@@ -61,7 +67,8 @@ template <class T> struct construct_test5 : public objects, test::exception_base
void run() const
{
T x(50, hash, equal_to, allocator);
avoid_unused_warning(x);
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
};
@@ -70,7 +77,8 @@ template <class T> struct construct_test6 : public objects, test::exception_base
void run() const
{
T x(allocator);
avoid_unused_warning(x);
BOOST_TEST(x.empty());
test::check_equivalent_keys(x);
}
};
@@ -87,7 +95,8 @@ template <class T> struct range_construct_test1 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end());
avoid_unused_warning(x);
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
};
@@ -96,7 +105,8 @@ template <class T> struct range_construct_test2 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end(), 0);
avoid_unused_warning(x);
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
};
@@ -105,7 +115,8 @@ template <class T> struct range_construct_test3 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end(), 0, hash);
avoid_unused_warning(x);
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
};
@@ -114,7 +125,8 @@ template <class T> struct range_construct_test4 : public range<T>, objects
void run() const
{
T x(this->values.begin(), this->values.end(), 100, hash, equal_to);
avoid_unused_warning(x);
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
};
@@ -128,7 +140,8 @@ template <class T> struct range_construct_test5 : public range<T>, objects
{
T x(this->values.begin(), this->values.end(), 0, hash, equal_to,
allocator);
avoid_unused_warning(x);
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
};
@@ -143,7 +156,8 @@ template <class T> struct input_range_construct_test : public range<T>, objects
end = this->values.end();
T x(test::input_iterator(begin), test::input_iterator(end), 0, hash,
equal_to, allocator);
avoid_unused_warning(x);
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
};
@@ -156,7 +170,8 @@ template <class T> struct copy_range_construct_test : public range<T>, objects
T x(test::copy_iterator(this->values.begin()),
test::copy_iterator(this->values.end()), 0, hash, equal_to,
allocator);
avoid_unused_warning(x);
test::check_container(x, this->values);
test::check_equivalent_keys(x);
}
};