Browse Source

Testing Mesh move constructor and assignment.

pull/51/head
Vladimír Vondruš 13 years ago
parent
commit
34c6565e71
  1. 5
      src/Mesh.cpp
  2. 48
      src/Test/MeshGLTest.cpp

5
src/Mesh.cpp

@ -93,6 +93,9 @@ Mesh::Mesh(MeshPrimitive primitive): _primitive(primitive), _vertexCount(0), _in
}
Mesh::~Mesh() {
/* Moved out, nothing to do */
if(!_id) return;
/* Remove current vao from the state */
GLuint& current = Context::current()->state().mesh->currentVAO;
if(current == _id) current = 0;
@ -278,7 +281,7 @@ void Mesh::destroyImplementationDefault() {}
void Mesh::destroyImplementationVAO() {
/** @todo Get some extension wrangler instead to avoid linker errors to glDeleteVertexArrays() on ES2 */
#ifndef MAGNUM_TARGET_GLES2
if(_id) glDeleteVertexArrays(1, &_id);
glDeleteVertexArrays(1, &_id);
#endif
}

48
src/Test/MeshGLTest.cpp

@ -33,11 +33,57 @@ class MeshGLTest: public AbstractOpenGLTester {
public:
explicit MeshGLTest();
void construct();
void constructCopy();
void constructMove();
void label();
};
MeshGLTest::MeshGLTest() {
addTests({&MeshGLTest::label});
addTests({&MeshGLTest::construct,
&MeshGLTest::constructCopy,
&MeshGLTest::constructMove,
&MeshGLTest::label});
}
void MeshGLTest::construct() {
{
const Mesh mesh;
MAGNUM_VERIFY_NO_ERROR();
CORRADE_VERIFY(mesh.id() > 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void MeshGLTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<Mesh, const Mesh&>{}));
CORRADE_VERIFY(!(std::is_assignable<Mesh, const Mesh&>{}));
}
void MeshGLTest::constructMove() {
Mesh a;
const Int id = a.id();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_VERIFY(id > 0);
Mesh b(std::move(a));
CORRADE_COMPARE(a.id(), 0);
CORRADE_COMPARE(b.id(), id);
Mesh c;
const Int cId = c.id();
c = std::move(b);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_VERIFY(cId > 0);
CORRADE_COMPARE(b.id(), cId);
CORRADE_COMPARE(c.id(), id);
}
void MeshGLTest::label() {

Loading…
Cancel
Save