Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions libs/core/algorithms/tests/unit/algorithms/max_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void test_max_element(IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -54,7 +54,7 @@ void test_max_element(ExPolicy policy, IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -83,7 +83,7 @@ void test_max_element_async(ExPolicy p, IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -135,7 +135,7 @@ void test_max_element_exception(IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -194,7 +194,7 @@ void test_max_element_exception(ExPolicy policy, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -250,7 +250,7 @@ void test_max_element_exception_async(ExPolicy p, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool returned_from_algorithm = false;
Expand Down Expand Up @@ -345,7 +345,7 @@ void test_max_element_bad_alloc(IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -400,7 +400,7 @@ void test_max_element_bad_alloc(ExPolicy policy, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -454,7 +454,7 @@ void test_max_element_bad_alloc_async(ExPolicy p, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool returned_from_algorithm = false;
Expand Down
18 changes: 9 additions & 9 deletions libs/core/algorithms/tests/unit/algorithms/min_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void test_min_element(IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -55,7 +55,7 @@ void test_min_element(ExPolicy policy, IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -84,7 +84,7 @@ void test_min_element_async(ExPolicy p, IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -136,7 +136,7 @@ void test_min_element_exception(IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -195,7 +195,7 @@ void test_min_element_exception(ExPolicy policy, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -251,7 +251,7 @@ void test_min_element_exception_async(ExPolicy p, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool returned_from_algorithm = false;
Expand Down Expand Up @@ -346,7 +346,7 @@ void test_min_element_bad_alloc(IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -401,7 +401,7 @@ void test_min_element_bad_alloc(ExPolicy policy, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -455,7 +455,7 @@ void test_min_element_bad_alloc_async(ExPolicy p, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool returned_from_algorithm = false;
Expand Down
18 changes: 9 additions & 9 deletions libs/core/algorithms/tests/unit/algorithms/minmax_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void test_minmax_element(IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -60,7 +60,7 @@ void test_minmax_element(ExPolicy policy, IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -93,7 +93,7 @@ void test_minmax_element_async(ExPolicy p, IteratorTag)
typedef std::vector<std::size_t>::iterator base_iterator;
typedef test::test_iterator<base_iterator, IteratorTag> iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

iterator end(std::end(c));
base_iterator ref_end(std::end(c));
Expand Down Expand Up @@ -149,7 +149,7 @@ void test_minmax_element_exception(IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -208,7 +208,7 @@ void test_minmax_element_exception(ExPolicy policy, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -264,7 +264,7 @@ void test_minmax_element_exception_async(ExPolicy p, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool returned_from_algorithm = false;
Expand Down Expand Up @@ -359,7 +359,7 @@ void test_minmax_element_bad_alloc(IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -414,7 +414,7 @@ void test_minmax_element_bad_alloc(ExPolicy policy, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool caught_exception = false;
Expand Down Expand Up @@ -468,7 +468,7 @@ void test_minmax_element_bad_alloc_async(ExPolicy p, IteratorTag)
typedef test::decorated_iterator<base_iterator, IteratorTag>
decorated_iterator;

std::vector<std::size_t> c = test::random_iota(10007);
std::vector<std::size_t> c = test::random_repeat(10007);

{
bool returned_from_algorithm = false;
Expand Down
11 changes: 11 additions & 0 deletions libs/core/algorithms/tests/unit/algorithms/test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ namespace test {
return c;
}

inline std::vector<std::size_t> random_repeat(std::size_t size)
{
std::vector<std::size_t> c(size);
std::random_device rd;
std::mt19937 g(rd());
std::uniform_int_distribution<std::size_t> uni(0, (size - 1) / 2);
for (auto& x : c)
x = uni(g);
return c;
}

template <typename T>
inline std::vector<T> random_iota(std::size_t size)
{
Expand Down
Loading