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 {
explicit DistanceFieldVectorGLTest();
void compile2D();
void compile3D();
void construct2D();
void construct3D();
void constructMove2D();
void constructMove3D();
};
DistanceFieldVectorGLTest::DistanceFieldVectorGLTest() {
addTests({&DistanceFieldVectorGLTest::compile2D,
&DistanceFieldVectorGLTest::compile3D});
addTests({&DistanceFieldVectorGLTest::construct2D,
&DistanceFieldVectorGLTest::construct3D,
&DistanceFieldVectorGLTest::constructMove2D,
&DistanceFieldVectorGLTest::constructMove3D});
}
void DistanceFieldVectorGLTest::compile2D() {
Shaders::DistanceFieldVector2D shader;
void DistanceFieldVectorGLTest::construct2D() {
DistanceFieldVector2D 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 DistanceFieldVectorGLTest::compile3D() {
Shaders::DistanceFieldVector3D shader;
void DistanceFieldVectorGLTest::construct3D() {
DistanceFieldVector3D 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 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)

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

@ -34,16 +34,22 @@ struct DistanceFieldVectorTest: TestSuite::Tester {
void constructNoCreate2D();
void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
};
DistanceFieldVectorTest::DistanceFieldVectorTest() {
addTests({&DistanceFieldVectorTest::constructNoCreate2D,
&DistanceFieldVectorTest::constructNoCreate3D});
&DistanceFieldVectorTest::constructNoCreate3D,
&DistanceFieldVectorTest::constructCopy2D,
&DistanceFieldVectorTest::constructCopy3D});
}
void DistanceFieldVectorTest::constructNoCreate2D() {
{
Shaders::DistanceFieldVector2D shader{NoCreate};
DistanceFieldVector2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
@ -52,13 +58,23 @@ void DistanceFieldVectorTest::constructNoCreate2D() {
void DistanceFieldVectorTest::constructNoCreate3D() {
{
Shaders::DistanceFieldVector3D shader{NoCreate};
DistanceFieldVector3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
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)

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

@ -31,59 +31,103 @@ namespace Magnum { namespace Shaders { namespace Test {
struct FlatGLTest: GL::OpenGLTester {
explicit FlatGLTest();
void compile2D();
void compile3D();
void compile2DTextured();
void compile3DTextured();
void construct2D();
void construct3D();
void construct2DTextured();
void construct3DTextured();
void constructMove2D();
void constructMove3D();
};
FlatGLTest::FlatGLTest() {
addTests({&FlatGLTest::compile2D,
&FlatGLTest::compile3D,
&FlatGLTest::compile2DTextured,
&FlatGLTest::compile3DTextured});
addTests({&FlatGLTest::construct2D,
&FlatGLTest::construct3D,
&FlatGLTest::construct2DTextured,
&FlatGLTest::construct3DTextured,
&FlatGLTest::constructMove2D,
&FlatGLTest::constructMove3D});
}
void FlatGLTest::compile2D() {
Shaders::Flat2D shader;
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::compile3D() {
Shaders::Flat3D shader;
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);
}
}
void FlatGLTest::compile2DTextured() {
Shaders::Flat2D shader(Shaders::Flat2D::Flag::Textured);
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);
}
}
void FlatGLTest::compile3DTextured() {
Shaders::Flat3D shader(Shaders::Flat3D::Flag::Textured);
void FlatGLTest::construct3DTextured() {
Flat3D shader(Flat3D::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);
}
}
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)

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

@ -34,16 +34,22 @@ struct FlatTest: TestSuite::Tester {
void constructNoCreate2D();
void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
};
FlatTest::FlatTest() {
addTests({&FlatTest::constructNoCreate2D,
&FlatTest::constructNoCreate3D});
&FlatTest::constructNoCreate3D,
&FlatTest::constructCopy2D,
&FlatTest::constructCopy3D});
}
void FlatTest::constructNoCreate2D() {
{
Shaders::Flat2D shader{NoCreate};
Flat2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
@ -52,13 +58,23 @@ void FlatTest::constructNoCreate2D() {
void FlatTest::constructNoCreate3D() {
{
Shaders::Flat3D shader{NoCreate};
Flat3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
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)

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

@ -33,33 +33,38 @@ namespace Magnum { namespace Shaders { namespace Test {
struct MeshVisualizerGLTest: GL::OpenGLTester {
explicit MeshVisualizerGLTest();
void compile();
void construct();
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void compileWireframeGeometryShader();
void constructWireframeGeometryShader();
#endif
void compileWireframeNoGeometryShader();
void constructWireframeNoGeometryShader();
void constructMove();
};
MeshVisualizerGLTest::MeshVisualizerGLTest() {
addTests({&MeshVisualizerGLTest::compile,
addTests({&MeshVisualizerGLTest::construct,
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
&MeshVisualizerGLTest::compileWireframeGeometryShader,
&MeshVisualizerGLTest::constructWireframeGeometryShader,
#endif
&MeshVisualizerGLTest::compileWireframeNoGeometryShader});
&MeshVisualizerGLTest::constructWireframeNoGeometryShader,
&MeshVisualizerGLTest::constructMove});
}
void MeshVisualizerGLTest::compile() {
Shaders::MeshVisualizer shader;
void MeshVisualizerGLTest::construct() {
MeshVisualizer 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);
}
}
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void MeshVisualizerGLTest::compileWireframeGeometryShader() {
void MeshVisualizerGLTest::constructWireframeGeometryShader() {
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::geometry_shader4>())
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();
#endif
Shaders::MeshVisualizer shader(Shaders::MeshVisualizer::Flag::Wireframe);
MeshVisualizer shader(MeshVisualizer::Flag::Wireframe);
{
#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);
}
}
#endif
void MeshVisualizerGLTest::compileWireframeNoGeometryShader() {
Shaders::MeshVisualizer shader(Shaders::MeshVisualizer::Flag::Wireframe|Shaders::MeshVisualizer::Flag::NoGeometryShader);
void MeshVisualizerGLTest::constructWireframeNoGeometryShader() {
MeshVisualizer shader(MeshVisualizer::Flag::Wireframe|MeshVisualizer::Flag::NoGeometryShader);
{
#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 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)

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

@ -33,21 +33,28 @@ struct MeshVisualizerTest: TestSuite::Tester {
explicit MeshVisualizerTest();
void constructNoCreate();
void constructCopy();
};
MeshVisualizerTest::MeshVisualizerTest() {
addTests({&MeshVisualizerTest::constructNoCreate});
addTests({&MeshVisualizerTest::constructNoCreate,
&MeshVisualizerTest::constructCopy});
}
void MeshVisualizerTest::constructNoCreate() {
{
Shaders::MeshVisualizer shader{NoCreate};
MeshVisualizer shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
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)

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

@ -31,107 +31,136 @@ namespace Magnum { namespace Shaders { namespace Test {
struct PhongGLTest: GL::OpenGLTester {
explicit PhongGLTest();
void compile();
void compileAmbientTexture();
void compileDiffuseTexture();
void compileSpecularTexture();
void compileAmbientDiffuseTexture();
void compileAmbientSpecularTexture();
void compileDiffuseSpecularTexture();
void compileAmbientDiffuseSpecularTexture();
void construct();
void constructAmbientTexture();
void constructDiffuseTexture();
void constructSpecularTexture();
void constructAmbientDiffuseTexture();
void constructAmbientSpecularTexture();
void constructDiffuseSpecularTexture();
void constructAmbientDiffuseSpecularTexture();
void constructMove();
};
PhongGLTest::PhongGLTest() {
addTests({&PhongGLTest::compile,
&PhongGLTest::compileAmbientTexture,
&PhongGLTest::compileDiffuseTexture,
&PhongGLTest::compileSpecularTexture,
&PhongGLTest::compileAmbientDiffuseTexture,
&PhongGLTest::compileAmbientSpecularTexture,
&PhongGLTest::compileDiffuseSpecularTexture,
&PhongGLTest::compileAmbientDiffuseSpecularTexture});
addTests({&PhongGLTest::construct,
&PhongGLTest::constructAmbientTexture,
&PhongGLTest::constructDiffuseTexture,
&PhongGLTest::constructSpecularTexture,
&PhongGLTest::constructAmbientDiffuseTexture,
&PhongGLTest::constructAmbientSpecularTexture,
&PhongGLTest::constructDiffuseSpecularTexture,
&PhongGLTest::constructAmbientDiffuseSpecularTexture,
&PhongGLTest::constructMove});
}
void PhongGLTest::compile() {
Shaders::Phong shader;
void PhongGLTest::construct() {
Phong 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 PhongGLTest::compileAmbientTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture);
void PhongGLTest::constructAmbientTexture() {
Phong shader(Phong::Flag::AmbientTexture);
{
#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 PhongGLTest::compileDiffuseTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::DiffuseTexture);
void PhongGLTest::constructDiffuseTexture() {
Phong shader(Phong::Flag::DiffuseTexture);
{
#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 PhongGLTest::compileSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::SpecularTexture);
void PhongGLTest::constructSpecularTexture() {
Phong shader(Phong::Flag::SpecularTexture);
{
#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 PhongGLTest::compileAmbientDiffuseTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::DiffuseTexture);
void PhongGLTest::constructAmbientDiffuseTexture() {
Phong shader(Phong::Flag::AmbientTexture|Phong::Flag::DiffuseTexture);
{
#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 PhongGLTest::compileAmbientSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::SpecularTexture);
void PhongGLTest::constructAmbientSpecularTexture() {
Phong shader(Phong::Flag::AmbientTexture|Phong::Flag::SpecularTexture);
{
#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 PhongGLTest::compileDiffuseSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::DiffuseTexture|Shaders::Phong::Flag::SpecularTexture);
void PhongGLTest::constructDiffuseSpecularTexture() {
Phong shader(Phong::Flag::DiffuseTexture|Phong::Flag::SpecularTexture);
{
#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 PhongGLTest::compileAmbientDiffuseSpecularTexture() {
Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::DiffuseTexture|Shaders::Phong::Flag::SpecularTexture);
void PhongGLTest::constructAmbientDiffuseSpecularTexture() {
Phong shader(Phong::Flag::AmbientTexture|Phong::Flag::DiffuseTexture|Phong::Flag::SpecularTexture);
{
#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 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)

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

@ -33,21 +33,28 @@ struct PhongTest: TestSuite::Tester {
explicit PhongTest();
void constructNoCreate();
void constructCopy();
};
PhongTest::PhongTest() {
addTests({&PhongTest::constructNoCreate});
addTests({&PhongTest::constructNoCreate,
&PhongTest::constructCopy});
}
void PhongTest::constructNoCreate() {
{
Shaders::Phong shader{NoCreate};
Phong shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
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)

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

@ -31,35 +31,77 @@ namespace Magnum { namespace Shaders { namespace Test {
struct VectorGLTest: GL::OpenGLTester {
explicit VectorGLTest();
void compile2D();
void compile3D();
void construct2D();
void construct3D();
void constructMove2D();
void constructMove3D();
};
VectorGLTest::VectorGLTest() {
addTests({&VectorGLTest::compile2D,
&VectorGLTest::compile3D});
addTests({&VectorGLTest::construct2D,
&VectorGLTest::construct3D,
&VectorGLTest::constructMove2D,
&VectorGLTest::constructMove3D});
}
void VectorGLTest::compile2D() {
Shaders::Vector2D shader;
void VectorGLTest::construct2D() {
Vector2D 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 VectorGLTest::compile3D() {
Shaders::Vector3D shader;
void VectorGLTest::construct3D() {
Vector3D 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 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)

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

@ -34,16 +34,22 @@ struct VectorTest: TestSuite::Tester {
void constructNoCreate2D();
void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
};
VectorTest::VectorTest() {
addTests({&VectorTest::constructNoCreate2D,
&VectorTest::constructNoCreate3D});
&VectorTest::constructNoCreate3D,
&VectorTest::constructCopy2D,
&VectorTest::constructCopy3D});
}
void VectorTest::constructNoCreate2D() {
{
Shaders::Vector2D shader{NoCreate};
Vector2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
@ -52,13 +58,23 @@ void VectorTest::constructNoCreate2D() {
void VectorTest::constructNoCreate3D() {
{
Shaders::Vector3D shader{NoCreate};
Vector3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
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)

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

@ -31,35 +31,77 @@ namespace Magnum { namespace Shaders { namespace Test {
struct VertexColorGLTest: GL::OpenGLTester {
explicit VertexColorGLTest();
void compile2D();
void compile3D();
void construct2D();
void construct3D();
void constructMove2D();
void constructMove3D();
};
VertexColorGLTest::VertexColorGLTest() {
addTests({&VertexColorGLTest::compile2D,
&VertexColorGLTest::compile3D});
addTests({&VertexColorGLTest::construct2D,
&VertexColorGLTest::construct3D,
&VertexColorGLTest::constructMove2D,
&VertexColorGLTest::constructMove3D});
}
void VertexColorGLTest::compile2D() {
Shaders::VertexColor2D shader;
void VertexColorGLTest::construct2D() {
VertexColor2D 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 VertexColorGLTest::compile3D() {
Shaders::VertexColor3D shader;
void VertexColorGLTest::construct3D() {
VertexColor3D 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 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)

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

@ -34,16 +34,22 @@ struct VertexColorTest: TestSuite::Tester {
void constructNoCreate2D();
void constructNoCreate3D();
void constructCopy2D();
void constructCopy3D();
};
VertexColorTest::VertexColorTest() {
addTests({&VertexColorTest::constructNoCreate2D,
&VertexColorTest::constructNoCreate3D});
&VertexColorTest::constructNoCreate3D,
&VertexColorTest::constructCopy2D,
&VertexColorTest::constructCopy3D});
}
void VertexColorTest::constructNoCreate2D() {
{
Shaders::VertexColor2D shader{NoCreate};
VertexColor2D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
@ -52,13 +58,23 @@ void VertexColorTest::constructNoCreate2D() {
void VertexColorTest::constructNoCreate3D() {
{
Shaders::VertexColor3D shader{NoCreate};
VertexColor3D shader{NoCreate};
CORRADE_COMPARE(shader.id(), 0);
}
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)

Loading…
Cancel
Save