forked from boostorg/unordered
Test inserting and constructing from input iterators.
Check thrown exception types properly. Return by reference from 'get_key' so that the keys aren't copied. [SVN r3115]
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/exception_safety.hpp>
|
||||
#include "../helpers/random_values.hpp"
|
||||
#include "../helpers/input_iterator.hpp"
|
||||
|
||||
struct objects
|
||||
{
|
||||
@@ -111,9 +112,20 @@ struct range_construct_test5 : public range<T>, objects
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Write a test using an input iterator.
|
||||
template <class T>
|
||||
struct input_range_construct_test : public range<T>, objects
|
||||
{
|
||||
input_range_construct_test() : range<T>(60) {}
|
||||
|
||||
void run() const {
|
||||
T x(test::input_iterator(this->values.begin()),
|
||||
test::input_iterator(this->values.end()),
|
||||
0, hash, equal_to, allocator);
|
||||
}
|
||||
};
|
||||
|
||||
RUN_EXCEPTION_TESTS(
|
||||
(construct_test1)(construct_test2)(construct_test3)(construct_test4)(construct_test5)
|
||||
(range_construct_test1)(range_construct_test2)(range_construct_test3)(range_construct_test4)(range_construct_test5),
|
||||
(range_construct_test1)(range_construct_test2)(range_construct_test3)(range_construct_test4)(range_construct_test5)
|
||||
(input_range_construct_test),
|
||||
CONTAINER_SEQ)
|
||||
|
||||
@@ -25,7 +25,14 @@ struct erase_test_base : public test::exception_base
|
||||
}
|
||||
|
||||
void check(T const& x) const {
|
||||
// TODO: Check that exception was thrown by hash or predicate object?
|
||||
std::string scope(test::scope);
|
||||
|
||||
// TODO: Instead of checking for 'operator==', I should check against
|
||||
// a scope stack.
|
||||
BOOST_CHECK(scope.find("hash::") != std::string::npos ||
|
||||
scope.find("equal_to::") != std::string::npos ||
|
||||
scope == "operator==(object, object)");
|
||||
|
||||
test::check_equivalent_keys(x);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../helpers/random_values.hpp"
|
||||
#include "../helpers/invariants.hpp"
|
||||
#include "../helpers/strong.hpp"
|
||||
#include "../helpers/input_iterator.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -31,7 +32,7 @@ struct insert_test_base : public test::exception_base
|
||||
void check(T const& x, strong_type const& strong) const {
|
||||
std::string scope(test::scope);
|
||||
|
||||
if(scope.find_first_of("hash::operator()") == std::string::npos)
|
||||
if(scope.find("hash::operator()") == std::string::npos)
|
||||
strong.test(x);
|
||||
test::check_equivalent_keys(x);
|
||||
}
|
||||
|
||||
@@ -33,9 +33,13 @@ struct rehash_test_base : public test::exception_base
|
||||
void check(T const& x, strong_type const& strong) const {
|
||||
std::string scope(test::scope);
|
||||
|
||||
if(scope.find_first_of("hash::operator()") == std::string::npos &&
|
||||
scope.find_first_of("equal_to::operator()") == std::string::npos)
|
||||
// TODO: Instead of checking for 'operator==', I should check against
|
||||
// a scope stack.
|
||||
if(scope.find("hash::operator()") == std::string::npos &&
|
||||
scope.find("equal_to::operator()") == std::string::npos &&
|
||||
scope != "operator==(object, object)")
|
||||
strong.test(x);
|
||||
|
||||
test::check_equivalent_keys(x);
|
||||
}
|
||||
};
|
||||
@@ -78,3 +82,4 @@ struct rehash_test4 : rehash_test_base<T>
|
||||
RUN_EXCEPTION_TESTS(
|
||||
(rehash_test0)(rehash_test1)(rehash_test2)(rehash_test3)(rehash_test4),
|
||||
CONTAINER_SEQ)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user