Skip to content

Commit

Permalink
[oneDPL][ranges][zip_view][test] + test_zip_view_base_op()
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDvorskiy committed Nov 28, 2024
1 parent 73f5a35 commit 304e42a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/parallel_api/ranges/std_ranges_zip_view.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,43 @@
#include "std_ranges_test.h"
#include <oneapi/dpl/ranges>

#if _ENABLE_STD_RANGES_TESTING
#include <vector>

void test_zip_view_base_op()
{
namespace dpl_ranges = oneapi::dpl::ranges;

constexpr int max_n = 100;
std::vector<int> vec1(max_n);
std::vector<int> vec2(max_n/2);

auto zip_view = dpl_ranges::zip(vec1, vec2);

static_assert(std::random_access_iterator<decltype(zip_view.begin())>);
static_assert(std::sentinel_for<decltype(zip_view.end()), decltype(zip_view.begin())>);

static_assert(std::random_access_iterator<decltype(zip_view.cbegin())>);
static_assert(std::sentinel_for<decltype(zip_view.cend()), decltype(zip_view.cbegin())>);

EXPECT_TRUE(zip_view.end() - zip_view.begin() == max_n/2,
"Difference operation between an iterator and a sentinel (zip_view) returns a wrong result.");

EXPECT_TRUE(zip_view[2] == *(zip_view.begin() + 2),
"Subscription or dereferencing operation for zip_view returns a wrong result.");

EXPECT_TRUE(std::ranges::size(zip_view) == max_n/2, "zip_view::size method returns a wrong result.");
EXPECT_TRUE((bool)zip_view, "zip_view::operator bool() method returns a wrong result.");
}
#endif //_ENABLE_STD_RANGES_TESTING

std::int32_t
main()
{
#if _ENABLE_STD_RANGES_TESTING

test_zip_view_base_op();

namespace dpl_ranges = oneapi::dpl::ranges;

constexpr int max_n = 10;
Expand Down

0 comments on commit 304e42a

Please sign in to comment.