Skip to content
Snippets Groups Projects
Commit c8158e3e authored by René Fritze's avatar René Fritze
Browse files

[test] adds a couple of new ones

parent 47c63dc5
No related branches found
No related tags found
No related merge requests found
// This file is part of the dune-stuff project:
// https://github.com/wwu-numerik/dune-stuff
// Copyright holders: Rene Milk, Felix Schindler
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
#include "main.hxx"
#include <vector>
#include <dune/stuff/common/algorithm.hh>
using namespace Dune::Stuff::Common;
struct Moveable
{
Moveable(int i)
: v(i)
{
}
int v;
};
TEST(MoveIfTest, All)
{
using namespace std;
typedef vector<unique_ptr<Moveable>> Vec;
typedef Vec::value_type Ptr;
const auto size = 6;
Vec values;
for (int i : valueRange(size)) {
values.emplace_back(new Moveable(i * 2));
}
Vec out;
const auto half_size = size / 2;
move_if(values.begin(), values.end(), std::back_inserter(out), [](Ptr& m) { return m->v < size; });
EXPECT_EQ(out.size(), half_size);
auto ctr = [](Ptr& ptr) { return ptr != nullptr; };
EXPECT_EQ(std::count_if(values.begin(), values.end(), ctr), half_size);
for (auto i : valueRange(half_size)) {
EXPECT_NE(out[i], nullptr);
EXPECT_EQ(i * 2, out[i]->v);
}
for (auto i : valueRange(half_size)) {
EXPECT_EQ(nullptr, values[i]);
EXPECT_EQ((i + half_size) * 2, values[i + half_size]->v);
}
}
......@@ -48,6 +48,5 @@ TEST(FixedMapTest, All)
}
EXPECT_EQ(std::make_pair(std::string("0"), 0), *too_big.begin());
// death test segfaults inside gtest -> disabled
// EXPECT_DEATH(*too_big.end(), ".*");
EXPECT_DEATH(*too_big.end(), ".*");
}
......@@ -85,6 +85,9 @@ TYPED_TEST(ThreadValueTest, All)
check_eq(bar, new_value);
}
TEST(ThreadManagerTBB, All)
TEST(ThreadManager, All)
{
auto& tm = DS::threadManager();
EXPECT_LT(tm.current_threads(), tm.max_threads());
EXPECT_LT(tm.thread(), tm.current_threads());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment