From 412ee9a04bcf6f2c1f4a2df69ab615b5faf65f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 4 Aug 2018 12:02:56 +0200 Subject: [PATCH] Shaders: simplify Flat shader test. --- src/Magnum/Shaders/Test/FlatGLTest.cpp | 96 +++++++++----------------- 1 file changed, 32 insertions(+), 64 deletions(-) diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index 9de76d38b..c9fd62ae3 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -23,6 +23,8 @@ DEALINGS IN THE SOFTWARE. */ +#include + #include "Magnum/GL/OpenGLTester.h" #include "Magnum/Shaders/Flat.h" @@ -31,60 +33,41 @@ namespace Magnum { namespace Shaders { namespace Test { struct FlatGLTest: GL::OpenGLTester { explicit FlatGLTest(); - void construct2D(); - void construct3D(); - void construct2DTextured(); - void construct3DTextured(); + template void construct(); - void constructMove2D(); - void constructMove3D(); + template void constructMove(); }; -FlatGLTest::FlatGLTest() { - addTests({&FlatGLTest::construct2D, - &FlatGLTest::construct3D, - &FlatGLTest::construct2DTextured, - &FlatGLTest::construct3DTextured, +namespace { - &FlatGLTest::constructMove2D, - &FlatGLTest::constructMove3D}); -} +constexpr struct { + const char* name; + Flat2D::Flags flags; +} ConstructData[]{ + {"", {}}, + {"textured", Flat2D::Flag::Textured} +}; -void FlatGLTest::construct2D() { - Flat2D shader; - { - #ifdef CORRADE_TARGET_APPLE - CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); - #endif - CORRADE_VERIFY(shader.id()); - CORRADE_VERIFY(shader.validate().first); - } } -void FlatGLTest::construct3D() { - Flat3D shader; - { - #ifdef CORRADE_TARGET_APPLE - CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); - #endif - CORRADE_VERIFY(shader.id()); - CORRADE_VERIFY(shader.validate().first); - } +FlatGLTest::FlatGLTest() { + addInstancedTests({ + &FlatGLTest::construct<2>, + &FlatGLTest::construct<3>}, + Containers::arraySize(ConstructData)); + + addTests({ + &FlatGLTest::constructMove<2>, + &FlatGLTest::constructMove<3>}); } -void FlatGLTest::construct2DTextured() { - Flat2D shader(Flat2D::Flag::Textured); - { - #ifdef CORRADE_TARGET_APPLE - CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); - #endif - CORRADE_VERIFY(shader.id()); - CORRADE_VERIFY(shader.validate().first); - } -} +template void FlatGLTest::construct() { + setTestCaseName(Utility::formatString("construct<{}>", dimensions)); + + auto&& data = ConstructData[testCaseInstanceId()]; + setTestCaseDescription(data.name); -void FlatGLTest::construct3DTextured() { - Flat3D shader(Flat3D::Flag::Textured); + Flat shader{data.flags}; { #ifdef CORRADE_TARGET_APPLE CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); @@ -94,35 +77,20 @@ void FlatGLTest::construct3DTextured() { } } -void FlatGLTest::constructMove2D() { - Flat2D a; - const GLuint id = a.id(); - CORRADE_VERIFY(id); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - Flat2D b{std::move(a)}; - CORRADE_COMPARE(b.id(), id); - CORRADE_VERIFY(!a.id()); - - Flat2D c{NoCreate}; - c = std::move(b); - CORRADE_COMPARE(c.id(), id); - CORRADE_VERIFY(!b.id()); -} +template void FlatGLTest::constructMove() { + setTestCaseName(Utility::formatString("constructMove<{}>", dimensions)); -void FlatGLTest::constructMove3D() { - Flat3D a; + Flat a; const GLuint id = a.id(); CORRADE_VERIFY(id); MAGNUM_VERIFY_NO_GL_ERROR(); - Flat3D b{std::move(a)}; + Flat b{std::move(a)}; CORRADE_COMPARE(b.id(), id); CORRADE_VERIFY(!a.id()); - Flat3D c{NoCreate}; + Flat c{NoCreate}; c = std::move(b); CORRADE_COMPARE(c.id(), id); CORRADE_VERIFY(!b.id());