diff --git a/src/Shaders/CMakeLists.txt b/src/Shaders/CMakeLists.txt index 6e4747b37..e1517e356 100644 --- a/src/Shaders/CMakeLists.txt +++ b/src/Shaders/CMakeLists.txt @@ -58,3 +58,7 @@ target_link_libraries(MagnumShaders Magnum) install(TARGETS MagnumShaders DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(FILES ${MagnumShaders_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Shaders) + +if(BUILD_TESTS) + add_subdirectory(Test) +endif() diff --git a/src/Shaders/Test/CMakeLists.txt b/src/Shaders/Test/CMakeLists.txt new file mode 100644 index 000000000..c7b45ce7e --- /dev/null +++ b/src/Shaders/Test/CMakeLists.txt @@ -0,0 +1,28 @@ +# +# This file is part of Magnum. +# +# Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +if(BUILD_GL_TESTS) + corrade_add_test(ShadersDistanceFieldVectorTest DistanceFieldVectorTest.cpp LIBRARIES MagnumShaders ${GL_TEST_LIBRARIES}) + corrade_add_test(ShadersVectorTest VectorTest.cpp LIBRARIES MagnumShaders ${GL_TEST_LIBRARIES}) +endif() diff --git a/src/Shaders/Test/DistanceFieldVectorTest.cpp b/src/Shaders/Test/DistanceFieldVectorTest.cpp new file mode 100644 index 000000000..fe7323af3 --- /dev/null +++ b/src/Shaders/Test/DistanceFieldVectorTest.cpp @@ -0,0 +1,55 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "Shaders/DistanceFieldVector.h" +#include "Test/AbstractOpenGLTester.h" + +namespace Magnum { namespace Shaders { namespace Test { + +class DistanceFieldVectorTest: public Magnum::Test::AbstractOpenGLTester { + public: + explicit DistanceFieldVectorTest(); + + void compile2D(); + void compile3D(); +}; + +DistanceFieldVectorTest::DistanceFieldVectorTest() { + addTests({&DistanceFieldVectorTest::compile2D, + &DistanceFieldVectorTest::compile3D}); +} + +void DistanceFieldVectorTest::compile2D() { + Shaders::DistanceFieldVector2D shader; + CORRADE_VERIFY(shader.validate().first); +} + +void DistanceFieldVectorTest::compile3D() { + Shaders::DistanceFieldVector3D shader; + CORRADE_VERIFY(shader.validate().first); +} + +}}} + +CORRADE_TEST_MAIN(Magnum::Shaders::Test::DistanceFieldVectorTest) diff --git a/src/Shaders/Test/VectorTest.cpp b/src/Shaders/Test/VectorTest.cpp new file mode 100644 index 000000000..58b112900 --- /dev/null +++ b/src/Shaders/Test/VectorTest.cpp @@ -0,0 +1,55 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "Shaders/Vector.h" +#include "Test/AbstractOpenGLTester.h" + +namespace Magnum { namespace Shaders { namespace Test { + +class VectorTest: public Magnum::Test::AbstractOpenGLTester { + public: + explicit VectorTest(); + + void compile2D(); + void compile3D(); +}; + +VectorTest::VectorTest() { + addTests({&VectorTest::compile2D, + &VectorTest::compile3D}); +} + +void VectorTest::compile2D() { + Shaders::Vector2D shader; + CORRADE_VERIFY(shader.validate().first); +} + +void VectorTest::compile3D() { + Shaders::Vector3D shader; + CORRADE_VERIFY(shader.validate().first); +} + +}}} + +CORRADE_TEST_MAIN(Magnum::Shaders::Test::VectorTest)