forked from boostorg/unordered
Use 'limited_range' to catch error in exception tests
This would have caught the error fixed in 3fe259a79e
.
This commit is contained in:
@ -18,7 +18,9 @@ test::seed_t initialize_seed(12847);
|
||||
template <class T> struct self_assign_base : public test::exception_base
|
||||
{
|
||||
test::random_values<T> values;
|
||||
self_assign_base(std::size_t count = 0) : values(count) {}
|
||||
self_assign_base(std::size_t count = 0) : values(count, test::limited_range)
|
||||
{
|
||||
}
|
||||
|
||||
typedef T data_type;
|
||||
T init() const { return T(values.begin(), values.end()); }
|
||||
@ -95,11 +97,12 @@ template <class T> struct assign_base : public test::exception_base
|
||||
template <class T> struct assign_values : assign_base<T>
|
||||
{
|
||||
assign_values(unsigned int count1, unsigned int count2, int tag1, int tag2,
|
||||
float mlf1 = 1.0, float mlf2 = 1.0)
|
||||
test::random_generator gen = test::default_generator, float mlf1 = 1.0,
|
||||
float mlf2 = 1.0)
|
||||
: assign_base<T>(tag1, tag2, mlf1, mlf2)
|
||||
{
|
||||
this->x_values.fill(count1);
|
||||
this->y_values.fill(count2);
|
||||
this->x_values.fill(count1, gen);
|
||||
this->y_values.fill(count2, gen);
|
||||
this->x.insert(this->x_values.begin(), this->x_values.end());
|
||||
this->y.insert(this->y_values.begin(), this->y_values.end());
|
||||
}
|
||||
@ -115,11 +118,21 @@ template <class T> struct assign_test2 : assign_values<T>
|
||||
assign_test2() : assign_values<T>(60, 0, 0, 0) {}
|
||||
};
|
||||
|
||||
template <class T> struct assign_test2a : assign_values<T>
|
||||
{
|
||||
assign_test2a() : assign_values<T>(60, 0, 0, 0, test::limited_range) {}
|
||||
};
|
||||
|
||||
template <class T> struct assign_test3 : assign_values<T>
|
||||
{
|
||||
assign_test3() : assign_values<T>(0, 60, 0, 0) {}
|
||||
};
|
||||
|
||||
template <class T> struct assign_test3a : assign_values<T>
|
||||
{
|
||||
assign_test3a() : assign_values<T>(0, 60, 0, 0, test::limited_range) {}
|
||||
};
|
||||
|
||||
template <class T> struct assign_test4 : assign_values<T>
|
||||
{
|
||||
assign_test4() : assign_values<T>(10, 10, 1, 2) {}
|
||||
@ -130,9 +143,17 @@ template <class T> struct assign_test4a : assign_values<T>
|
||||
assign_test4a() : assign_values<T>(10, 100, 1, 2) {}
|
||||
};
|
||||
|
||||
template <class T> struct assign_test4b : assign_values<T>
|
||||
{
|
||||
assign_test4b() : assign_values<T>(10, 100, 1, 2, test::limited_range) {}
|
||||
};
|
||||
|
||||
template <class T> struct assign_test5 : assign_values<T>
|
||||
{
|
||||
assign_test5() : assign_values<T>(5, 60, 0, 0, 1.0f, 0.1f) {}
|
||||
assign_test5()
|
||||
: assign_values<T>(5, 60, 0, 0, test::default_generator, 1.0f, 0.1f)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct equivalent_test1 : assign_base<T>
|
||||
@ -150,8 +171,15 @@ template <class T> struct equivalent_test1 : assign_base<T>
|
||||
}
|
||||
};
|
||||
|
||||
EXCEPTION_TESTS_REPEAT(5, (self_assign_test1)(self_assign_test2)(assign_test1)(
|
||||
assign_test2)(assign_test3)(assign_test4)(
|
||||
assign_test4a)(assign_test5)(equivalent_test1),
|
||||
// clang-format off
|
||||
EXCEPTION_TESTS_REPEAT(5,
|
||||
(self_assign_test1)(self_assign_test2)
|
||||
(assign_test1)(assign_test2)(assign_test2a)
|
||||
(assign_test3)(assign_test3a)
|
||||
(assign_test4)(assign_test4a)(assign_test4b)
|
||||
(assign_test5)
|
||||
(equivalent_test1),
|
||||
CONTAINER_SEQ)
|
||||
// clang-format on
|
||||
|
||||
RUN_TESTS()
|
||||
|
@ -98,8 +98,8 @@ template <class T> struct range : public test::exception_base
|
||||
{
|
||||
test::random_values<T> values;
|
||||
|
||||
range() : values(5) {}
|
||||
range(unsigned int count) : values(count) {}
|
||||
range() : values(5, test::limited_range) {}
|
||||
range(unsigned int count) : values(count, test::limited_range) {}
|
||||
};
|
||||
|
||||
template <class T> struct range_construct_test1 : public range<T>, objects
|
||||
|
@ -32,7 +32,10 @@ template <class T> struct copy_test2 : public test::exception_base
|
||||
test::random_values<T> values;
|
||||
T x;
|
||||
|
||||
copy_test2() : values(5), x(values.begin(), values.end()) {}
|
||||
copy_test2()
|
||||
: values(5, test::limited_range), x(values.begin(), values.end())
|
||||
{
|
||||
}
|
||||
|
||||
void run() const
|
||||
{
|
||||
@ -61,6 +64,26 @@ template <class T> struct copy_test3 : public test::exception_base
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct copy_test3a : public test::exception_base
|
||||
{
|
||||
test::random_values<T> values;
|
||||
T x;
|
||||
|
||||
copy_test3a()
|
||||
: values(100, test::limited_range), x(values.begin(), values.end())
|
||||
{
|
||||
}
|
||||
|
||||
void run() const
|
||||
{
|
||||
T y(x);
|
||||
|
||||
DISABLE_EXCEPTIONS;
|
||||
test::check_container(y, this->values);
|
||||
test::check_equivalent_keys(y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct copy_with_allocator_test : public test::exception_base
|
||||
{
|
||||
test::random_values<T> values;
|
||||
@ -79,6 +102,10 @@ template <class T> struct copy_with_allocator_test : public test::exception_base
|
||||
}
|
||||
};
|
||||
|
||||
EXCEPTION_TESTS((copy_test1)(copy_test2)(copy_test3)(copy_with_allocator_test),
|
||||
// clang-format off
|
||||
EXCEPTION_TESTS(
|
||||
(copy_test1)(copy_test2)(copy_test3)(copy_test3a)(copy_with_allocator_test),
|
||||
CONTAINER_SEQ)
|
||||
// clang-format on
|
||||
|
||||
RUN_TESTS()
|
||||
|
@ -14,7 +14,9 @@ test::seed_t initialize_seed(835193);
|
||||
template <class T> struct erase_test_base : public test::exception_base
|
||||
{
|
||||
test::random_values<T> values;
|
||||
erase_test_base(unsigned int count = 5) : values(count) {}
|
||||
erase_test_base(unsigned int count = 5) : values(count, test::limited_range)
|
||||
{
|
||||
}
|
||||
|
||||
typedef T data_type;
|
||||
|
||||
|
@ -70,8 +70,8 @@ template <class T> struct move_assign_values : move_assign_base<T>
|
||||
int tag2, float mlf1 = 1.0, float mlf2 = 1.0)
|
||||
: move_assign_base<T>(tag1, tag2, mlf1, mlf2)
|
||||
{
|
||||
this->x_values.fill(count1);
|
||||
this->y_values.fill(count2);
|
||||
this->x_values.fill(count1, test::limited_range);
|
||||
this->y_values.fill(count2, test::limited_range);
|
||||
this->x.insert(this->x_values.begin(), this->x_values.end());
|
||||
this->y.insert(this->y_values.begin(), this->y_values.end());
|
||||
}
|
||||
@ -111,10 +111,10 @@ template <class T> struct equivalent_test1 : move_assign_base<T>
|
||||
{
|
||||
equivalent_test1() : move_assign_base<T>(0, 0)
|
||||
{
|
||||
test::random_values<T> x_values2(10);
|
||||
test::random_values<T> x_values2(10, test::limited_range);
|
||||
this->x_values.insert(x_values2.begin(), x_values2.end());
|
||||
this->x_values.insert(x_values2.begin(), x_values2.end());
|
||||
test::random_values<T> y_values2(10);
|
||||
test::random_values<T> y_values2(10, test::limited_range);
|
||||
this->y_values.insert(y_values2.begin(), y_values2.end());
|
||||
this->y_values.insert(y_values2.begin(), y_values2.end());
|
||||
this->x.insert(this->x_values.begin(), this->x_values.end());
|
||||
|
@ -20,7 +20,7 @@ template <class T> struct rehash_test_base : public test::exception_base
|
||||
test::random_values<T> values;
|
||||
unsigned int n;
|
||||
rehash_test_base(unsigned int count = 100, unsigned int n_ = 0)
|
||||
: values(count), n(n_)
|
||||
: values(count, test::limited_range), n(n_)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,9 @@ test::seed_t initialize_seed(9387);
|
||||
template <class T> struct self_swap_base : public test::exception_base
|
||||
{
|
||||
test::random_values<T> values;
|
||||
self_swap_base(std::size_t count = 0) : values(count) {}
|
||||
self_swap_base(std::size_t count = 0) : values(count, test::limited_range)
|
||||
{
|
||||
}
|
||||
|
||||
typedef T data_type;
|
||||
T init() const { return T(values.begin(), values.end()); }
|
||||
@ -65,7 +67,8 @@ template <class T> struct swap_base : public test::exception_base
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
|
||||
swap_base(unsigned int count1, unsigned int count2, int tag1, int tag2)
|
||||
: x_values(count1), y_values(count2),
|
||||
: x_values(count1, test::limited_range),
|
||||
y_values(count2, test::limited_range),
|
||||
initial_x(x_values.begin(), x_values.end(), 0, hasher(tag1),
|
||||
key_equal(tag1), allocator_type(tag1)),
|
||||
initial_y(
|
||||
|
Reference in New Issue
Block a user