C++11: VectorT now also accepts non-arithmetic types as Scalar.

This commit is contained in:
Hans-Christian Ebke
2015-11-19 15:20:41 +01:00
parent 4c36fcfee8
commit 580e5526d8
2 changed files with 88 additions and 18 deletions

View File

@@ -176,4 +176,46 @@ TEST_F(OpenMeshVectorTest, size_dim) {
EXPECT_EQ(2, v2i.dim());
}
namespace {
class C {
public:
C() {}
C(const C &rhs) { ADD_FAILURE() << "Copy constructor used."; }
C(C &&rhs) { ++copy_con; }
C &operator= (const C &rhs) {
ADD_FAILURE() << "Copy assignemnt used.";
return *this;
}
C &operator= (C &&rhs) { ++copy_ass; return *this; }
static int copy_con;
static int copy_ass;
};
int C::copy_con = 0;
int C::copy_ass = 0;
}
/**
* Checks two things:
* 1) Whether VectorT works with a non-arithmetic type.
* 2) Whether move construction and assignment works.
*/
TEST_F(OpenMeshVectorTest, move_constructor_assignment) {
C::copy_con = 0;
C::copy_ass = 0;
// Test move assigning.
OpenMesh::VectorT<C, 3> x, y;
x = std::move(y);
EXPECT_EQ(3, C::copy_ass);
EXPECT_EQ(0, C::copy_con);
// Test move constructing.
OpenMesh::VectorT<C, 3> z(std::move(x));
EXPECT_EQ(3, C::copy_ass);
EXPECT_EQ(3, C::copy_con);
}
}