From 2d1d9f4b29ae41a88da1d8f69b085d1996cb67f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 30 Sep 2019 11:46:17 +0200 Subject: [PATCH] Shaders: simplified [DistanceField]Vector and VertexColor shader tests. --- .../Test/DistanceFieldVectorGLTest.cpp | 59 +++++-------------- src/Magnum/Shaders/Test/VectorGLTest.cpp | 59 +++++-------------- src/Magnum/Shaders/Test/VertexColorGLTest.cpp | 59 +++++-------------- 3 files changed, 45 insertions(+), 132 deletions(-) diff --git a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp index 9ba2b0ba1..7ac598038 100644 --- a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp @@ -31,36 +31,22 @@ namespace Magnum { namespace Shaders { namespace Test { namespace { struct DistanceFieldVectorGLTest: GL::OpenGLTester { explicit DistanceFieldVectorGLTest(); - void construct2D(); - void construct3D(); - - void constructMove2D(); - void constructMove3D(); + template void construct(); + template void constructMove(); }; DistanceFieldVectorGLTest::DistanceFieldVectorGLTest() { - addTests({&DistanceFieldVectorGLTest::construct2D, - &DistanceFieldVectorGLTest::construct3D, - - &DistanceFieldVectorGLTest::constructMove2D, - &DistanceFieldVectorGLTest::constructMove3D}); + addTests({ + &DistanceFieldVectorGLTest::construct<2>, + &DistanceFieldVectorGLTest::construct<3>, + &DistanceFieldVectorGLTest::constructMove<2>, + &DistanceFieldVectorGLTest::constructMove<3>}); } -void DistanceFieldVectorGLTest::construct2D() { - DistanceFieldVector2D shader; - CORRADE_VERIFY(shader.id()); - { - #ifdef CORRADE_TARGET_APPLE - CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); - #endif - CORRADE_VERIFY(shader.validate().first); - } - - MAGNUM_VERIFY_NO_GL_ERROR(); -} +template void DistanceFieldVectorGLTest::construct() { + setTestCaseTemplateName(std::to_string(dimensions)); -void DistanceFieldVectorGLTest::construct3D() { - DistanceFieldVector3D shader; + DistanceFieldVector shader; CORRADE_VERIFY(shader.id()); { #ifdef CORRADE_TARGET_APPLE @@ -72,35 +58,20 @@ void DistanceFieldVectorGLTest::construct3D() { MAGNUM_VERIFY_NO_GL_ERROR(); } -void DistanceFieldVectorGLTest::constructMove2D() { - DistanceFieldVector2D a; - const GLuint id = a.id(); - CORRADE_VERIFY(id); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - DistanceFieldVector2D b{std::move(a)}; - CORRADE_COMPARE(b.id(), id); - CORRADE_VERIFY(!a.id()); - - DistanceFieldVector2D c{NoCreate}; - c = std::move(b); - CORRADE_COMPARE(c.id(), id); - CORRADE_VERIFY(!b.id()); -} +template void DistanceFieldVectorGLTest::constructMove() { + setTestCaseTemplateName(std::to_string(dimensions)); -void DistanceFieldVectorGLTest::constructMove3D() { - DistanceFieldVector3D a; + DistanceFieldVector a; const GLuint id = a.id(); CORRADE_VERIFY(id); MAGNUM_VERIFY_NO_GL_ERROR(); - DistanceFieldVector3D b{std::move(a)}; + DistanceFieldVector b{std::move(a)}; CORRADE_COMPARE(b.id(), id); CORRADE_VERIFY(!a.id()); - DistanceFieldVector3D c{NoCreate}; + DistanceFieldVector c{NoCreate}; c = std::move(b); CORRADE_COMPARE(c.id(), id); CORRADE_VERIFY(!b.id()); diff --git a/src/Magnum/Shaders/Test/VectorGLTest.cpp b/src/Magnum/Shaders/Test/VectorGLTest.cpp index 8c2368938..880f1edb9 100644 --- a/src/Magnum/Shaders/Test/VectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/VectorGLTest.cpp @@ -31,36 +31,22 @@ namespace Magnum { namespace Shaders { namespace Test { namespace { struct VectorGLTest: GL::OpenGLTester { explicit VectorGLTest(); - void construct2D(); - void construct3D(); - - void constructMove2D(); - void constructMove3D(); + template void construct(); + template void constructMove(); }; VectorGLTest::VectorGLTest() { - addTests({&VectorGLTest::construct2D, - &VectorGLTest::construct3D, - - &VectorGLTest::constructMove2D, - &VectorGLTest::constructMove3D}); + addTests({ + &VectorGLTest::construct<2>, + &VectorGLTest::construct<3>, + &VectorGLTest::constructMove<2>, + &VectorGLTest::constructMove<3>}); } -void VectorGLTest::construct2D() { - Vector2D shader; - CORRADE_VERIFY(shader.id()); - { - #ifdef CORRADE_TARGET_APPLE - CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); - #endif - CORRADE_VERIFY(shader.validate().first); - } - - MAGNUM_VERIFY_NO_GL_ERROR(); -} +template void VectorGLTest::construct() { + setTestCaseTemplateName(std::to_string(dimensions)); -void VectorGLTest::construct3D() { - Vector3D shader; + Vector shader; CORRADE_VERIFY(shader.id()); { #ifdef CORRADE_TARGET_APPLE @@ -72,35 +58,20 @@ void VectorGLTest::construct3D() { MAGNUM_VERIFY_NO_GL_ERROR(); } -void VectorGLTest::constructMove2D() { - Vector2D a; - const GLuint id = a.id(); - CORRADE_VERIFY(id); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - Vector2D b{std::move(a)}; - CORRADE_COMPARE(b.id(), id); - CORRADE_VERIFY(!a.id()); - - Vector2D c{NoCreate}; - c = std::move(b); - CORRADE_COMPARE(c.id(), id); - CORRADE_VERIFY(!b.id()); -} +template void VectorGLTest::constructMove() { + setTestCaseTemplateName(std::to_string(dimensions)); -void VectorGLTest::constructMove3D() { - Vector3D a; + Vector a; const GLuint id = a.id(); CORRADE_VERIFY(id); MAGNUM_VERIFY_NO_GL_ERROR(); - Vector3D b{std::move(a)}; + Vector b{std::move(a)}; CORRADE_COMPARE(b.id(), id); CORRADE_VERIFY(!a.id()); - Vector3D c{NoCreate}; + Vector c{NoCreate}; c = std::move(b); CORRADE_COMPARE(c.id(), id); CORRADE_VERIFY(!b.id()); diff --git a/src/Magnum/Shaders/Test/VertexColorGLTest.cpp b/src/Magnum/Shaders/Test/VertexColorGLTest.cpp index 85d9eb6f9..55709e03d 100644 --- a/src/Magnum/Shaders/Test/VertexColorGLTest.cpp +++ b/src/Magnum/Shaders/Test/VertexColorGLTest.cpp @@ -31,36 +31,22 @@ namespace Magnum { namespace Shaders { namespace Test { namespace { struct VertexColorGLTest: GL::OpenGLTester { explicit VertexColorGLTest(); - void construct2D(); - void construct3D(); - - void constructMove2D(); - void constructMove3D(); + template void construct(); + template void constructMove(); }; VertexColorGLTest::VertexColorGLTest() { - addTests({&VertexColorGLTest::construct2D, - &VertexColorGLTest::construct3D, - - &VertexColorGLTest::constructMove2D, - &VertexColorGLTest::constructMove3D}); + addTests({ + &VertexColorGLTest::construct<2>, + &VertexColorGLTest::construct<3>, + &VertexColorGLTest::constructMove<2>, + &VertexColorGLTest::constructMove<3>}); } -void VertexColorGLTest::construct2D() { - VertexColor2D shader; - CORRADE_VERIFY(shader.id()); - { - #ifdef CORRADE_TARGET_APPLE - CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); - #endif - CORRADE_VERIFY(shader.validate().first); - } - - MAGNUM_VERIFY_NO_GL_ERROR(); -} +template void VertexColorGLTest::construct() { + setTestCaseTemplateName(std::to_string(dimensions)); -void VertexColorGLTest::construct3D() { - VertexColor3D shader; + VertexColor shader; CORRADE_VERIFY(shader.id()); { #ifdef CORRADE_TARGET_APPLE @@ -72,35 +58,20 @@ void VertexColorGLTest::construct3D() { MAGNUM_VERIFY_NO_GL_ERROR(); } -void VertexColorGLTest::constructMove2D() { - VertexColor2D a; - const GLuint id = a.id(); - CORRADE_VERIFY(id); - - MAGNUM_VERIFY_NO_GL_ERROR(); - - VertexColor2D b{std::move(a)}; - CORRADE_COMPARE(b.id(), id); - CORRADE_VERIFY(!a.id()); - - VertexColor2D c{NoCreate}; - c = std::move(b); - CORRADE_COMPARE(c.id(), id); - CORRADE_VERIFY(!b.id()); -} +template void VertexColorGLTest::constructMove() { + setTestCaseTemplateName(std::to_string(dimensions)); -void VertexColorGLTest::constructMove3D() { - VertexColor3D a; + VertexColor a; const GLuint id = a.id(); CORRADE_VERIFY(id); MAGNUM_VERIFY_NO_GL_ERROR(); - VertexColor3D b{std::move(a)}; + VertexColor b{std::move(a)}; CORRADE_COMPARE(b.id(), id); CORRADE_VERIFY(!a.id()); - VertexColor3D c{NoCreate}; + VertexColor c{NoCreate}; c = std::move(b); CORRADE_COMPARE(c.id(), id); CORRADE_VERIFY(!b.id());