Browse Source

Shaders: improve copy/move construction tests.

Doesn't compile at the moment because AbstractVector has a private
constructor and so the move constructors are not generated or something.
pull/255/head
Vladimír Vondruš 8 years ago
parent
commit
f27b75bd65
  1. 58
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  2. 22
      src/Magnum/Shaders/Test/DistanceFieldVectorTest.cpp
  3. 76
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  4. 22
      src/Magnum/Shaders/Test/FlatTest.cpp
  5. 48
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  6. 11
      src/Magnum/Shaders/Test/MeshVisualizerTest.cpp
  7. 93
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  8. 11
      src/Magnum/Shaders/Test/PhongTest.cpp
  9. 58
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  10. 22
      src/Magnum/Shaders/Test/VectorTest.cpp
  11. 58
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp
  12. 22
      src/Magnum/Shaders/Test/VertexColorTest.cpp

58
src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp

@ -31,35 +31,77 @@ namespace Magnum { namespace Shaders { namespace Test {
struct DistanceFieldVectorGLTest: GL::OpenGLTester { struct DistanceFieldVectorGLTest: GL::OpenGLTester {
explicit DistanceFieldVectorGLTest(); explicit DistanceFieldVectorGLTest();
void compile2D(); void construct2D();
void compile3D(); void construct3D();
void constructMove2D();
void constructMove3D();
}; };
DistanceFieldVectorGLTest::DistanceFieldVectorGLTest() { DistanceFieldVectorGLTest::DistanceFieldVectorGLTest() {
addTests({&DistanceFieldVectorGLTest::compile2D, addTests({&DistanceFieldVectorGLTest::construct2D,
&DistanceFieldVectorGLTest::compile3D}); &DistanceFieldVectorGLTest::construct3D,
&DistanceFieldVectorGLTest::constructMove2D,
&DistanceFieldVectorGLTest::constructMove3D});
} }
void DistanceFieldVectorGLTest::compile2D() { void DistanceFieldVectorGLTest::construct2D() {
Shaders::DistanceFieldVector2D shader; DistanceFieldVector2D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void DistanceFieldVectorGLTest::compile3D() { void DistanceFieldVectorGLTest::construct3D() {
Shaders::DistanceFieldVector3D shader; DistanceFieldVector3D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
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());
}
void DistanceFieldVectorGLTest::constructMove3D() {
DistanceFieldVector3D a;
const GLuint id = a.id();
CORRADE_VERIFY(id);
MAGNUM_VERIFY_NO_GL_ERROR();
DistanceFieldVector3D b{std::move(a)};
CORRADE_COMPARE(b.id(), id);
CORRADE_VERIFY(!a.id());
DistanceFieldVector3D c{NoCreate};
c = std::move(b);
CORRADE_COMPARE(c.id(), id);
CORRADE_VERIFY(!b.id());
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::DistanceFieldVectorGLTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::DistanceFieldVectorGLTest)

22
src/Magnum/Shaders/Test/DistanceFieldVectorTest.cpp

@ -34,16 +34,22 @@ struct DistanceFieldVectorTest: TestSuite::Tester {
void constructNoCreate2D(); void constructNoCreate2D();
void constructNoCreate3D(); void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
}; };
DistanceFieldVectorTest::DistanceFieldVectorTest() { DistanceFieldVectorTest::DistanceFieldVectorTest() {
addTests({&DistanceFieldVectorTest::constructNoCreate2D, addTests({&DistanceFieldVectorTest::constructNoCreate2D,
&DistanceFieldVectorTest::constructNoCreate3D}); &DistanceFieldVectorTest::constructNoCreate3D,
&DistanceFieldVectorTest::constructCopy2D,
&DistanceFieldVectorTest::constructCopy3D});
} }
void DistanceFieldVectorTest::constructNoCreate2D() { void DistanceFieldVectorTest::constructNoCreate2D() {
{ {
Shaders::DistanceFieldVector2D shader{NoCreate}; DistanceFieldVector2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
@ -52,13 +58,23 @@ void DistanceFieldVectorTest::constructNoCreate2D() {
void DistanceFieldVectorTest::constructNoCreate3D() { void DistanceFieldVectorTest::constructNoCreate3D() {
{ {
Shaders::DistanceFieldVector3D shader{NoCreate}; DistanceFieldVector3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
CORRADE_VERIFY(true); CORRADE_VERIFY(true);
} }
void DistanceFieldVectorTest::constructCopy2D() {
CORRADE_VERIFY(!(std::is_constructible<DistanceFieldVector2D, const DistanceFieldVector2D&>{}));
CORRADE_VERIFY(!(std::is_assignable<DistanceFieldVector2D, const DistanceFieldVector2D&>{}));
}
void DistanceFieldVectorTest::constructCopy3D() {
CORRADE_VERIFY(!(std::is_constructible<DistanceFieldVector3D, const DistanceFieldVector3D&>{}));
CORRADE_VERIFY(!(std::is_assignable<DistanceFieldVector3D, const DistanceFieldVector3D&>{}));
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::DistanceFieldVectorTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::DistanceFieldVectorTest)

76
src/Magnum/Shaders/Test/FlatGLTest.cpp

@ -31,59 +31,103 @@ namespace Magnum { namespace Shaders { namespace Test {
struct FlatGLTest: GL::OpenGLTester { struct FlatGLTest: GL::OpenGLTester {
explicit FlatGLTest(); explicit FlatGLTest();
void compile2D(); void construct2D();
void compile3D(); void construct3D();
void compile2DTextured(); void construct2DTextured();
void compile3DTextured(); void construct3DTextured();
void constructMove2D();
void constructMove3D();
}; };
FlatGLTest::FlatGLTest() { FlatGLTest::FlatGLTest() {
addTests({&FlatGLTest::compile2D, addTests({&FlatGLTest::construct2D,
&FlatGLTest::compile3D, &FlatGLTest::construct3D,
&FlatGLTest::compile2DTextured, &FlatGLTest::construct2DTextured,
&FlatGLTest::compile3DTextured}); &FlatGLTest::construct3DTextured,
&FlatGLTest::constructMove2D,
&FlatGLTest::constructMove3D});
} }
void FlatGLTest::compile2D() { void FlatGLTest::construct2D() {
Shaders::Flat2D shader; Flat2D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void FlatGLTest::compile3D() { void FlatGLTest::construct3D() {
Shaders::Flat3D shader; Flat3D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void FlatGLTest::compile2DTextured() { void FlatGLTest::construct2DTextured() {
Shaders::Flat2D shader(Shaders::Flat2D::Flag::Textured); Flat2D shader(Flat2D::Flag::Textured);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void FlatGLTest::compile3DTextured() { void FlatGLTest::construct3DTextured() {
Shaders::Flat3D shader(Shaders::Flat3D::Flag::Textured); Flat3D shader(Flat3D::Flag::Textured);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
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());
}
void FlatGLTest::constructMove3D() {
Flat3D a;
const GLuint id = a.id();
CORRADE_VERIFY(id);
MAGNUM_VERIFY_NO_GL_ERROR();
Flat3D b{std::move(a)};
CORRADE_COMPARE(b.id(), id);
CORRADE_VERIFY(!a.id());
Flat3D c{NoCreate};
c = std::move(b);
CORRADE_COMPARE(c.id(), id);
CORRADE_VERIFY(!b.id());
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::FlatGLTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::FlatGLTest)

22
src/Magnum/Shaders/Test/FlatTest.cpp

@ -34,16 +34,22 @@ struct FlatTest: TestSuite::Tester {
void constructNoCreate2D(); void constructNoCreate2D();
void constructNoCreate3D(); void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
}; };
FlatTest::FlatTest() { FlatTest::FlatTest() {
addTests({&FlatTest::constructNoCreate2D, addTests({&FlatTest::constructNoCreate2D,
&FlatTest::constructNoCreate3D}); &FlatTest::constructNoCreate3D,
&FlatTest::constructCopy2D,
&FlatTest::constructCopy3D});
} }
void FlatTest::constructNoCreate2D() { void FlatTest::constructNoCreate2D() {
{ {
Shaders::Flat2D shader{NoCreate}; Flat2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
@ -52,13 +58,23 @@ void FlatTest::constructNoCreate2D() {
void FlatTest::constructNoCreate3D() { void FlatTest::constructNoCreate3D() {
{ {
Shaders::Flat3D shader{NoCreate}; Flat3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
CORRADE_VERIFY(true); CORRADE_VERIFY(true);
} }
void FlatTest::constructCopy2D() {
CORRADE_VERIFY(!(std::is_constructible<Flat2D, const Flat2D&>{}));
CORRADE_VERIFY(!(std::is_assignable<Flat2D, const Flat2D&>{}));
}
void FlatTest::constructCopy3D() {
CORRADE_VERIFY(!(std::is_constructible<Flat3D, const Flat3D&>{}));
CORRADE_VERIFY(!(std::is_assignable<Flat3D, const Flat3D&>{}));
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::FlatTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::FlatTest)

48
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -33,33 +33,38 @@ namespace Magnum { namespace Shaders { namespace Test {
struct MeshVisualizerGLTest: GL::OpenGLTester { struct MeshVisualizerGLTest: GL::OpenGLTester {
explicit MeshVisualizerGLTest(); explicit MeshVisualizerGLTest();
void compile(); void construct();
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void compileWireframeGeometryShader(); void constructWireframeGeometryShader();
#endif #endif
void compileWireframeNoGeometryShader(); void constructWireframeNoGeometryShader();
void constructMove();
}; };
MeshVisualizerGLTest::MeshVisualizerGLTest() { MeshVisualizerGLTest::MeshVisualizerGLTest() {
addTests({&MeshVisualizerGLTest::compile, addTests({&MeshVisualizerGLTest::construct,
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
&MeshVisualizerGLTest::compileWireframeGeometryShader, &MeshVisualizerGLTest::constructWireframeGeometryShader,
#endif #endif
&MeshVisualizerGLTest::compileWireframeNoGeometryShader}); &MeshVisualizerGLTest::constructWireframeNoGeometryShader,
&MeshVisualizerGLTest::constructMove});
} }
void MeshVisualizerGLTest::compile() { void MeshVisualizerGLTest::construct() {
Shaders::MeshVisualizer shader; MeshVisualizer shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void MeshVisualizerGLTest::compileWireframeGeometryShader() { void MeshVisualizerGLTest::constructWireframeGeometryShader() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::geometry_shader4>()) if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::geometry_shader4>())
CORRADE_SKIP(GL::Extensions::ARB::geometry_shader4::string() + std::string(" is not supported")); CORRADE_SKIP(GL::Extensions::ARB::geometry_shader4::string() + std::string(" is not supported"));
@ -73,26 +78,45 @@ void MeshVisualizerGLTest::compileWireframeGeometryShader() {
Debug() << "Using" << GL::Extensions::NV::shader_noperspective_interpolation::string(); Debug() << "Using" << GL::Extensions::NV::shader_noperspective_interpolation::string();
#endif #endif
Shaders::MeshVisualizer shader(Shaders::MeshVisualizer::Flag::Wireframe); MeshVisualizer shader(MeshVisualizer::Flag::Wireframe);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
#endif #endif
void MeshVisualizerGLTest::compileWireframeNoGeometryShader() { void MeshVisualizerGLTest::constructWireframeNoGeometryShader() {
Shaders::MeshVisualizer shader(Shaders::MeshVisualizer::Flag::Wireframe|Shaders::MeshVisualizer::Flag::NoGeometryShader); MeshVisualizer shader(MeshVisualizer::Flag::Wireframe|MeshVisualizer::Flag::NoGeometryShader);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void MeshVisualizerGLTest::constructMove() {
MeshVisualizer a;
const GLuint id = a.id();
CORRADE_VERIFY(id);
MAGNUM_VERIFY_NO_GL_ERROR();
MeshVisualizer b{std::move(a)};
CORRADE_COMPARE(b.id(), id);
CORRADE_VERIFY(!a.id());
MeshVisualizer c{NoCreate};
c = std::move(b);
CORRADE_COMPARE(c.id(), id);
CORRADE_VERIFY(!b.id());
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::MeshVisualizerGLTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::MeshVisualizerGLTest)

11
src/Magnum/Shaders/Test/MeshVisualizerTest.cpp

@ -33,21 +33,28 @@ struct MeshVisualizerTest: TestSuite::Tester {
explicit MeshVisualizerTest(); explicit MeshVisualizerTest();
void constructNoCreate(); void constructNoCreate();
void constructCopy();
}; };
MeshVisualizerTest::MeshVisualizerTest() { MeshVisualizerTest::MeshVisualizerTest() {
addTests({&MeshVisualizerTest::constructNoCreate}); addTests({&MeshVisualizerTest::constructNoCreate,
&MeshVisualizerTest::constructCopy});
} }
void MeshVisualizerTest::constructNoCreate() { void MeshVisualizerTest::constructNoCreate() {
{ {
Shaders::MeshVisualizer shader{NoCreate}; MeshVisualizer shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
CORRADE_VERIFY(true); CORRADE_VERIFY(true);
} }
void MeshVisualizerTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<MeshVisualizer, const MeshVisualizer&>{}));
CORRADE_VERIFY(!(std::is_assignable<MeshVisualizer, const MeshVisualizer&>{}));
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::MeshVisualizerTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::MeshVisualizerTest)

93
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -31,107 +31,136 @@ namespace Magnum { namespace Shaders { namespace Test {
struct PhongGLTest: GL::OpenGLTester { struct PhongGLTest: GL::OpenGLTester {
explicit PhongGLTest(); explicit PhongGLTest();
void compile(); void construct();
void compileAmbientTexture(); void constructAmbientTexture();
void compileDiffuseTexture(); void constructDiffuseTexture();
void compileSpecularTexture(); void constructSpecularTexture();
void compileAmbientDiffuseTexture(); void constructAmbientDiffuseTexture();
void compileAmbientSpecularTexture(); void constructAmbientSpecularTexture();
void compileDiffuseSpecularTexture(); void constructDiffuseSpecularTexture();
void compileAmbientDiffuseSpecularTexture(); void constructAmbientDiffuseSpecularTexture();
void constructMove();
}; };
PhongGLTest::PhongGLTest() { PhongGLTest::PhongGLTest() {
addTests({&PhongGLTest::compile, addTests({&PhongGLTest::construct,
&PhongGLTest::compileAmbientTexture, &PhongGLTest::constructAmbientTexture,
&PhongGLTest::compileDiffuseTexture, &PhongGLTest::constructDiffuseTexture,
&PhongGLTest::compileSpecularTexture, &PhongGLTest::constructSpecularTexture,
&PhongGLTest::compileAmbientDiffuseTexture, &PhongGLTest::constructAmbientDiffuseTexture,
&PhongGLTest::compileAmbientSpecularTexture, &PhongGLTest::constructAmbientSpecularTexture,
&PhongGLTest::compileDiffuseSpecularTexture, &PhongGLTest::constructDiffuseSpecularTexture,
&PhongGLTest::compileAmbientDiffuseSpecularTexture}); &PhongGLTest::constructAmbientDiffuseSpecularTexture,
&PhongGLTest::constructMove});
} }
void PhongGLTest::compile() { void PhongGLTest::construct() {
Shaders::Phong shader; Phong shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::compileAmbientTexture() { void PhongGLTest::constructAmbientTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture); Phong shader(Phong::Flag::AmbientTexture);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::compileDiffuseTexture() { void PhongGLTest::constructDiffuseTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::DiffuseTexture); Phong shader(Phong::Flag::DiffuseTexture);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::compileSpecularTexture() { void PhongGLTest::constructSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::SpecularTexture); Phong shader(Phong::Flag::SpecularTexture);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::compileAmbientDiffuseTexture() { void PhongGLTest::constructAmbientDiffuseTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::DiffuseTexture); Phong shader(Phong::Flag::AmbientTexture|Phong::Flag::DiffuseTexture);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::compileAmbientSpecularTexture() { void PhongGLTest::constructAmbientSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::SpecularTexture); Phong shader(Phong::Flag::AmbientTexture|Phong::Flag::SpecularTexture);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::compileDiffuseSpecularTexture() { void PhongGLTest::constructDiffuseSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::DiffuseTexture|Shaders::Phong::Flag::SpecularTexture); Phong shader(Phong::Flag::DiffuseTexture|Phong::Flag::SpecularTexture);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::compileAmbientDiffuseSpecularTexture() { void PhongGLTest::constructAmbientDiffuseSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::DiffuseTexture|Shaders::Phong::Flag::SpecularTexture); Phong shader(Phong::Flag::AmbientTexture|Phong::Flag::DiffuseTexture|Phong::Flag::SpecularTexture);
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void PhongGLTest::constructMove() {
Phong a;
const GLuint id = a.id();
CORRADE_VERIFY(id);
MAGNUM_VERIFY_NO_GL_ERROR();
Phong b{std::move(a)};
CORRADE_COMPARE(b.id(), id);
CORRADE_VERIFY(!a.id());
Phong c{NoCreate};
c = std::move(b);
CORRADE_COMPARE(c.id(), id);
CORRADE_VERIFY(!b.id());
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::PhongGLTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::PhongGLTest)

11
src/Magnum/Shaders/Test/PhongTest.cpp

@ -33,21 +33,28 @@ struct PhongTest: TestSuite::Tester {
explicit PhongTest(); explicit PhongTest();
void constructNoCreate(); void constructNoCreate();
void constructCopy();
}; };
PhongTest::PhongTest() { PhongTest::PhongTest() {
addTests({&PhongTest::constructNoCreate}); addTests({&PhongTest::constructNoCreate,
&PhongTest::constructCopy});
} }
void PhongTest::constructNoCreate() { void PhongTest::constructNoCreate() {
{ {
Shaders::Phong shader{NoCreate}; Phong shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
CORRADE_VERIFY(true); CORRADE_VERIFY(true);
} }
void PhongTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<Phong, const Phong&>{}));
CORRADE_VERIFY(!(std::is_assignable<Phong, const Phong&>{}));
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::PhongTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::PhongTest)

58
src/Magnum/Shaders/Test/VectorGLTest.cpp

@ -31,35 +31,77 @@ namespace Magnum { namespace Shaders { namespace Test {
struct VectorGLTest: GL::OpenGLTester { struct VectorGLTest: GL::OpenGLTester {
explicit VectorGLTest(); explicit VectorGLTest();
void compile2D(); void construct2D();
void compile3D(); void construct3D();
void constructMove2D();
void constructMove3D();
}; };
VectorGLTest::VectorGLTest() { VectorGLTest::VectorGLTest() {
addTests({&VectorGLTest::compile2D, addTests({&VectorGLTest::construct2D,
&VectorGLTest::compile3D}); &VectorGLTest::construct3D,
&VectorGLTest::constructMove2D,
&VectorGLTest::constructMove3D});
} }
void VectorGLTest::compile2D() { void VectorGLTest::construct2D() {
Shaders::Vector2D shader; Vector2D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void VectorGLTest::compile3D() { void VectorGLTest::construct3D() {
Shaders::Vector3D shader; Vector3D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
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());
}
void VectorGLTest::constructMove3D() {
Vector3D a;
const GLuint id = a.id();
CORRADE_VERIFY(id);
MAGNUM_VERIFY_NO_GL_ERROR();
Vector3D b{std::move(a)};
CORRADE_COMPARE(b.id(), id);
CORRADE_VERIFY(!a.id());
Vector3D c{NoCreate};
c = std::move(b);
CORRADE_COMPARE(c.id(), id);
CORRADE_VERIFY(!b.id());
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::VectorGLTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::VectorGLTest)

22
src/Magnum/Shaders/Test/VectorTest.cpp

@ -34,16 +34,22 @@ struct VectorTest: TestSuite::Tester {
void constructNoCreate2D(); void constructNoCreate2D();
void constructNoCreate3D(); void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
}; };
VectorTest::VectorTest() { VectorTest::VectorTest() {
addTests({&VectorTest::constructNoCreate2D, addTests({&VectorTest::constructNoCreate2D,
&VectorTest::constructNoCreate3D}); &VectorTest::constructNoCreate3D,
&VectorTest::constructCopy2D,
&VectorTest::constructCopy3D});
} }
void VectorTest::constructNoCreate2D() { void VectorTest::constructNoCreate2D() {
{ {
Shaders::Vector2D shader{NoCreate}; Vector2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
@ -52,13 +58,23 @@ void VectorTest::constructNoCreate2D() {
void VectorTest::constructNoCreate3D() { void VectorTest::constructNoCreate3D() {
{ {
Shaders::Vector3D shader{NoCreate}; Vector3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
CORRADE_VERIFY(true); CORRADE_VERIFY(true);
} }
void VectorTest::constructCopy2D() {
CORRADE_VERIFY(!(std::is_constructible<Vector2D, const Vector2D&>{}));
CORRADE_VERIFY(!(std::is_assignable<Vector2D, const Vector2D&>{}));
}
void VectorTest::constructCopy3D() {
CORRADE_VERIFY(!(std::is_constructible<Vector3D, const Vector3D&>{}));
CORRADE_VERIFY(!(std::is_assignable<Vector3D, const Vector3D&>{}));
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::VectorTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::VectorTest)

58
src/Magnum/Shaders/Test/VertexColorGLTest.cpp

@ -31,35 +31,77 @@ namespace Magnum { namespace Shaders { namespace Test {
struct VertexColorGLTest: GL::OpenGLTester { struct VertexColorGLTest: GL::OpenGLTester {
explicit VertexColorGLTest(); explicit VertexColorGLTest();
void compile2D(); void construct2D();
void compile3D(); void construct3D();
void constructMove2D();
void constructMove3D();
}; };
VertexColorGLTest::VertexColorGLTest() { VertexColorGLTest::VertexColorGLTest() {
addTests({&VertexColorGLTest::compile2D, addTests({&VertexColorGLTest::construct2D,
&VertexColorGLTest::compile3D}); &VertexColorGLTest::construct3D,
&VertexColorGLTest::constructMove2D,
&VertexColorGLTest::constructMove3D});
} }
void VertexColorGLTest::compile2D() { void VertexColorGLTest::construct2D() {
Shaders::VertexColor2D shader; VertexColor2D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
void VertexColorGLTest::compile3D() { void VertexColorGLTest::construct3D() {
Shaders::VertexColor3D shader; VertexColor3D shader;
{ {
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.id());
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first);
} }
} }
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());
}
void VertexColorGLTest::constructMove3D() {
VertexColor3D a;
const GLuint id = a.id();
CORRADE_VERIFY(id);
MAGNUM_VERIFY_NO_GL_ERROR();
VertexColor3D b{std::move(a)};
CORRADE_COMPARE(b.id(), id);
CORRADE_VERIFY(!a.id());
VertexColor3D c{NoCreate};
c = std::move(b);
CORRADE_COMPARE(c.id(), id);
CORRADE_VERIFY(!b.id());
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::VertexColorGLTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::VertexColorGLTest)

22
src/Magnum/Shaders/Test/VertexColorTest.cpp

@ -34,16 +34,22 @@ struct VertexColorTest: TestSuite::Tester {
void constructNoCreate2D(); void constructNoCreate2D();
void constructNoCreate3D(); void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
}; };
VertexColorTest::VertexColorTest() { VertexColorTest::VertexColorTest() {
addTests({&VertexColorTest::constructNoCreate2D, addTests({&VertexColorTest::constructNoCreate2D,
&VertexColorTest::constructNoCreate3D}); &VertexColorTest::constructNoCreate3D,
&VertexColorTest::constructCopy2D,
&VertexColorTest::constructCopy3D});
} }
void VertexColorTest::constructNoCreate2D() { void VertexColorTest::constructNoCreate2D() {
{ {
Shaders::VertexColor2D shader{NoCreate}; VertexColor2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
@ -52,13 +58,23 @@ void VertexColorTest::constructNoCreate2D() {
void VertexColorTest::constructNoCreate3D() { void VertexColorTest::constructNoCreate3D() {
{ {
Shaders::VertexColor3D shader{NoCreate}; VertexColor3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0); CORRADE_COMPARE(shader.id(), 0);
} }
CORRADE_VERIFY(true); CORRADE_VERIFY(true);
} }
void VertexColorTest::constructCopy2D() {
CORRADE_VERIFY(!(std::is_constructible<VertexColor2D, const VertexColor2D&>{}));
CORRADE_VERIFY(!(std::is_assignable<VertexColor2D, const VertexColor2D&>{}));
}
void VertexColorTest::constructCopy3D() {
CORRADE_VERIFY(!(std::is_constructible<VertexColor3D, const VertexColor3D&>{}));
CORRADE_VERIFY(!(std::is_assignable<VertexColor3D, const VertexColor3D&>{}));
}
}}} }}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::VertexColorTest) CORRADE_TEST_MAIN(Magnum::Shaders::Test::VertexColorTest)

Loading…
Cancel
Save