diff --git a/src/Magnum/GL/Test/MeshTest.cpp b/src/Magnum/GL/Test/MeshTest.cpp index f3f053be0..880302abe 100644 --- a/src/Magnum/GL/Test/MeshTest.cpp +++ b/src/Magnum/GL/Test/MeshTest.cpp @@ -153,6 +153,28 @@ void MeshTest::mapPrimitive() { CORRADE_COMPARE(meshPrimitive(Magnum::MeshPrimitive::Triangles), MeshPrimitive::Triangles); CORRADE_COMPARE(meshPrimitive(Magnum::MeshPrimitive::TriangleStrip), MeshPrimitive::TriangleStrip); CORRADE_COMPARE(meshPrimitive(Magnum::MeshPrimitive::TriangleFan), MeshPrimitive::TriangleFan); + + /* Ensure all generic primitives are handled. This goes through the first + 16 bits, which should be enough. Going through 32 bits takes 8 seconds, + too much. */ + for(UnsignedInt i = 1; i <= 0xffff; ++i) { + const auto primitive = Magnum::MeshPrimitive(i); + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif + switch(primitive) { + #define _c(primitive) \ + case Magnum::MeshPrimitive::primitive: \ + CORRADE_VERIFY(UnsignedInt(meshPrimitive(Magnum::MeshPrimitive::primitive)) >= 0); \ + break; + #include "Magnum/Implementation/meshPrimitiveMapping.hpp" + #undef _c + } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + } } void MeshTest::mapPrimitiveInvalid() { @@ -168,6 +190,28 @@ void MeshTest::mapIndexType() { CORRADE_COMPARE(meshIndexType(Magnum::MeshIndexType::UnsignedByte), MeshIndexType::UnsignedByte); CORRADE_COMPARE(meshIndexType(Magnum::MeshIndexType::UnsignedShort), MeshIndexType::UnsignedShort); CORRADE_COMPARE(meshIndexType(Magnum::MeshIndexType::UnsignedInt), MeshIndexType::UnsignedInt); + + /* Ensure all generic index types are handled. This goes through the first + 16 bits, which should be enough. Going through 32 bits takes 8 seconds, + too much. */ + for(UnsignedInt i = 1; i <= 0xffff; ++i) { + const auto type = Magnum::MeshIndexType(i); + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif + switch(type) { + #define _c(type) \ + case Magnum::MeshIndexType::type: \ + CORRADE_VERIFY(UnsignedInt(meshIndexType(Magnum::MeshIndexType::type)) >= 0); \ + break; + #include "Magnum/Implementation/meshIndexTypeMapping.hpp" + #undef _c + } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + } } void MeshTest::mapIndexTypeInvalid() { diff --git a/src/Magnum/Vk/Test/EnumsTest.cpp b/src/Magnum/Vk/Test/EnumsTest.cpp index 25adba473..3671f6638 100644 --- a/src/Magnum/Vk/Test/EnumsTest.cpp +++ b/src/Magnum/Vk/Test/EnumsTest.cpp @@ -116,6 +116,29 @@ void EnumsTest::mapVkPrimitiveTopology() { CORRADE_VERIFY(hasVkPrimitiveTopology(Magnum::MeshPrimitive::TriangleFan)); CORRADE_COMPARE(vkPrimitiveTopology(Magnum::MeshPrimitive::TriangleFan), VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN); + + /* Ensure all generic primitives are handled. This goes through the first + 16 bits, which should be enough. Going through 32 bits takes 8 seconds, + too much. */ + for(UnsignedInt i = 1; i <= 0xffff; ++i) { + const auto primitive = Magnum::MeshPrimitive(i); + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif + switch(primitive) { + #define _c(primitive) \ + case Magnum::MeshPrimitive::primitive: \ + if(hasVkPrimitiveTopology(Magnum::MeshPrimitive::primitive)) \ + CORRADE_VERIFY(UnsignedInt(vkPrimitiveTopology(Magnum::MeshPrimitive::primitive)) >= 0); \ + break; + #include "Magnum/Implementation/meshPrimitiveMapping.hpp" + #undef _c + } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + } } void EnumsTest::mapVkPrimitiveTopologyUnsupported() { @@ -147,6 +170,28 @@ void EnumsTest::mapVkIndexType() { CORRADE_VERIFY(hasVkIndexType(Magnum::MeshIndexType::UnsignedInt)); CORRADE_COMPARE(vkIndexType(Magnum::MeshIndexType::UnsignedInt), VK_INDEX_TYPE_UINT32); + + /* Ensure all generic index types are handled. This goes through the first + 16 bits, which should be enough. Going through 32 bits takes 8 seconds, + too much. */ + for(UnsignedInt i = 1; i <= 0xffff; ++i) { + const auto type = Magnum::MeshIndexType(i); + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif + switch(type) { + #define _c(type) \ + case Magnum::MeshIndexType::type: \ + CORRADE_VERIFY(UnsignedInt(vkIndexType(Magnum::MeshIndexType::type)) >= 0); \ + break; + #include "Magnum/Implementation/meshIndexTypeMapping.hpp" + #undef _c + } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + } } void EnumsTest::mapVkIndexTypeUnsupported() {