Skip to content
Merged
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
15 changes: 9 additions & 6 deletions tests/test_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,11 @@ TEMPLATE_TEST_CASE("general accumulate()", "[statistics]",
v.push_back(5);
v.push_back(3);
v.push_back(9);
auto const expectation = TestType{ 18 };
REQUIRE(std::accumulate(v.cbegin(), v.cend(), TestType{ },
[](TestType a, TestType el) { return a + el; }) == 18);
[](TestType a, TestType el) { return a + el; }) == expectation);
REQUIRE(gul17::accumulate<TestType>(v,
[](TestType a, TestType el) { return a + el; }) == 18);
[](TestType a, TestType el) { return a + el; }) == expectation);
}
SECTION("pointer accumulate") {
auto a = TestType{ 4 };
Expand All @@ -478,10 +479,11 @@ TEMPLATE_TEST_CASE("general accumulate()", "[statistics]",
v.push_back(&b);
v.push_back(&c);
v.push_back(&d);
auto const expectation = TestType{ 14 };
REQUIRE(std::accumulate(v.cbegin(), v.cend(), TestType{ },
[](TestType accu, TestType* el) { return accu + *el; }) == 14);
[](TestType accu, TestType* el) { return accu + *el; }) == expectation);
REQUIRE(gul17::accumulate<TestType>(v,
[](TestType accu, TestType* el) { return accu + *el; }) == 14);
[](TestType accu, TestType* el) { return accu + *el; }) == expectation);
}
SECTION("user type accumulate") {
struct UserType {
Expand All @@ -495,10 +497,11 @@ TEMPLATE_TEST_CASE("general accumulate()", "[statistics]",
v.emplace_back(TestType{ 2 }, true);
v.emplace_back(TestType{ 3 }, true);
v.emplace_back(TestType{ 7 }, true);
auto const expectation = TestType{ 19 };
REQUIRE(std::accumulate(v.cbegin(), v.cend(), TestType{ },
[](TestType accu, UserType const& el) { return accu + el.e; }) == 19);
[](TestType accu, UserType const& el) { return accu + el.e; }) == expectation);
REQUIRE(gul17::accumulate<TestType>(v,
[](TestType accu, UserType const& el) { return accu + el.e; }) == 19);
[](TestType accu, UserType const& el) { return accu + el.e; }) == expectation);
}
}

Expand Down
Loading