1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include "../catch.hpp"
#include "rkcommon/tasking/parallel_foreach.h"
#include <algorithm>
#include <vector>
using rkcommon::tasking::parallel_foreach;
TEST_CASE("parallel_foreach", "[parallel_foreach]")
{
const size_t N_ELEMENTS = size_t(1e8);
const int bad_value = 0;
const int good_value = 1;
std::vector<int> v(N_ELEMENTS);
std::fill(v.begin(), v.end(), bad_value);
parallel_foreach(v, [&](int &value) { value = good_value; });
auto found = std::find(v.begin(), v.end(), bad_value);
REQUIRE(found == v.end());
}
|