Browse Source

Vk: add a trivial test for Mesh move/copy.

pull/504/head
Vladimír Vondruš 5 years ago
parent
commit
4cc1bf11b7
  1. 30
      src/Magnum/Vk/Test/MeshTest.cpp

30
src/Magnum/Vk/Test/MeshTest.cpp

@ -42,7 +42,9 @@ struct MeshTest: TestSuite::Tester {
void mapIndexTypeInvalid(); void mapIndexTypeInvalid();
void construct(); void construct();
void countsOffsets(); void constructCountsOffsets();
void constructCopy();
void constructMove();
void addVertexBuffer(); void addVertexBuffer();
void addVertexBufferOwned(); void addVertexBufferOwned();
@ -61,7 +63,9 @@ MeshTest::MeshTest() {
&MeshTest::mapIndexTypeInvalid, &MeshTest::mapIndexTypeInvalid,
&MeshTest::construct, &MeshTest::construct,
&MeshTest::countsOffsets, &MeshTest::constructCountsOffsets,
&MeshTest::constructCopy,
&MeshTest::constructMove,
&MeshTest::addVertexBuffer, &MeshTest::addVertexBuffer,
&MeshTest::addVertexBufferOwned, &MeshTest::addVertexBufferOwned,
@ -124,7 +128,7 @@ void MeshTest::construct() {
CORRADE_VERIFY(!mesh.isIndexed()); CORRADE_VERIFY(!mesh.isIndexed());
} }
void MeshTest::countsOffsets() { void MeshTest::constructCountsOffsets() {
Mesh mesh{MeshLayout{MeshPrimitive::Triangles}}; Mesh mesh{MeshLayout{MeshPrimitive::Triangles}};
mesh.setCount(15) mesh.setCount(15)
.setVertexOffset(3) .setVertexOffset(3)
@ -138,6 +142,26 @@ void MeshTest::countsOffsets() {
CORRADE_COMPARE(mesh.instanceOffset(), 9); CORRADE_COMPARE(mesh.instanceOffset(), 9);
} }
void MeshTest::constructCopy() {
CORRADE_VERIFY(!std::is_copy_constructible<Mesh>{});
CORRADE_VERIFY(!std::is_copy_assignable<Mesh>{});
}
void MeshTest::constructMove() {
/* The move is defaulted, so test just the very basics */
Mesh a{MeshLayout{MeshPrimitive::Triangles}};
a.setCount(15);
Mesh b = std::move(a);
CORRADE_COMPARE(b.layout().vkPipelineInputAssemblyStateCreateInfo().topology, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
CORRADE_COMPARE(b.count(), 15);
Mesh c{MeshLayout{MeshPrimitive::Points}};
c = std::move(b);
CORRADE_COMPARE(c.layout().vkPipelineInputAssemblyStateCreateInfo().topology, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
CORRADE_COMPARE(c.count(), 15);
}
void MeshTest::addVertexBuffer() { void MeshTest::addVertexBuffer() {
Mesh mesh{MeshLayout{MeshPrimitive::TriangleFan} Mesh mesh{MeshLayout{MeshPrimitive::TriangleFan}
.addBinding(1, 2) .addBinding(1, 2)

Loading…
Cancel
Save