From 4cc1bf11b71d78a7dd054da8c5925ffb34968095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 15 Mar 2021 17:32:56 +0100 Subject: [PATCH] Vk: add a trivial test for Mesh move/copy. --- src/Magnum/Vk/Test/MeshTest.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Vk/Test/MeshTest.cpp b/src/Magnum/Vk/Test/MeshTest.cpp index f8af4f3d3..25c429a89 100644 --- a/src/Magnum/Vk/Test/MeshTest.cpp +++ b/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{}); + CORRADE_VERIFY(!std::is_copy_assignable{}); +} + +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)