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 construct();
void countsOffsets();
void constructCountsOffsets();
void constructCopy();
void constructMove();
void addVertexBuffer();
void addVertexBufferOwned();
@ -61,7 +63,9 @@ MeshTest::MeshTest() {
&MeshTest::mapIndexTypeInvalid,
&MeshTest::construct,
&MeshTest::countsOffsets,
&MeshTest::constructCountsOffsets,
&MeshTest::constructCopy,
&MeshTest::constructMove,
&MeshTest::addVertexBuffer,
&MeshTest::addVertexBufferOwned,
@ -124,7 +128,7 @@ void MeshTest::construct() {
CORRADE_VERIFY(!mesh.isIndexed());
}
void MeshTest::countsOffsets() {
void MeshTest::constructCountsOffsets() {
Mesh mesh{MeshLayout{MeshPrimitive::Triangles}};
mesh.setCount(15)
.setVertexOffset(3)
@ -138,6 +142,26 @@ void MeshTest::countsOffsets() {
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() {
Mesh mesh{MeshLayout{MeshPrimitive::TriangleFan}
.addBinding(1, 2)

Loading…
Cancel
Save