Skip to content

Commit

Permalink
Update unit_test_parallelisation.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektrikAkar committed Aug 16, 2024
1 parent 6c1a14e commit 105d6a9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/unit/unit_test_parallelisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
#include <vector>
#include <atomic>

TEST_CASE("Parallel Execution", "[run_std]")
TEST_CASE("Parallel Execution", "[run_openmp]")
{
std::vector<int> results(100, 0);
auto task = [&](int i) { results[i] = 1; };

dtwc::run_std(task, results.size(), true);
dtwc::run_openmp(task, results.size(), true);

for (int res : results)
REQUIRE(res == 1);
}

TEST_CASE("Sequential Execution", "[run_std]")
TEST_CASE("Sequential Execution", "[run_openmp]")
{
std::vector<int> results(100, 0);
auto task = [&](int i) { results[i] = 1; };

dtwc::run_std(task, results.size(), false);
dtwc::run_openmp(task, results.size(), false);

for (int res : results) {
REQUIRE(res == 1);
Expand All @@ -58,20 +58,20 @@ TEST_CASE("Functionality of run", "[run]")
}
}

TEST_CASE("Correct Number of Iterations", "[run_std]")
TEST_CASE("Correct Number of Iterations", "[run_openmp]")
{
std::atomic<int> count = 0;
auto task = [&](int) { count++; };

dtwc::run_std(task, 50, true);
dtwc::run_openmp(task, 50, true);
REQUIRE(count == 50);
}

TEST_CASE("Boundary Conditions", "[run_std]")
TEST_CASE("Boundary Conditions", "[run_openmp]")
{
int count = 0;
auto task = [&](int) { count++; };

dtwc::run_std(task, 0, true);
dtwc::run_openmp(task, 0, true);
REQUIRE(count == 0);
}

0 comments on commit 105d6a9

Please sign in to comment.