Skip to content
Snippets Groups Projects
Commit 1fd33bdb authored by Simon Praetorius's avatar Simon Praetorius
Browse files

Add test for non-copyable and non-moveable types

parent 61531e64
Branches
Tags
1 merge request!1158Fillin missing functionality in ReservedVector and make it constexpr
......@@ -34,6 +34,24 @@ struct A
int size_ = 0;
};
struct NoCopy
{
NoCopy() = default;
NoCopy(const NoCopy&) = delete;
NoCopy(NoCopy&&) = default;
NoCopy& operator= (const NoCopy&) = delete;
NoCopy& operator= (NoCopy&&) = default;
};
struct NoMove
{
NoMove() = default;
NoMove(const NoMove&) = default;
NoMove(NoMove&&) = delete;
NoMove& operator= (const NoMove&) = default;
NoMove& operator= (NoMove&&) = delete;
};
int main() {
Dune::TestSuite test;
// check that make_array works
......@@ -103,7 +121,7 @@ int main() {
test.check( *it == i++ );
}
{ // check non-fundamental types
{ // check non-trivial types
Dune::ReservedVector<A, 8> rvA;
rvA.push_back(A(5));
rvA.emplace_back(A(5));
......@@ -111,6 +129,21 @@ int main() {
test.check( rvA.size() == 3 );
}
{ // check non-copyable types
Dune::ReservedVector<NoCopy, 8> rv;
rv.push_back(NoCopy{});
rv.emplace_back();
test.check( rv.size() == 2 );
}
{ // check non-movable types
Dune::ReservedVector<NoMove, 8> rv;
NoMove x;
rv.push_back(x);
rv.emplace_back();
test.check( rv.size() == 2 );
}
{ // check constexpr
constexpr Dune::ReservedVector<unsigned int, 8> crv{3,2,1};
static_assert(crv.size() == 3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment