From 50ef1df21345c961adf8d7d326b16935b90d4dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 26 Jul 2013 12:22:19 +0200 Subject: [PATCH] Trade: debug output operator for TextureData::Type enum. --- src/CMakeLists.txt | 3 +- src/Trade/Test/CMakeLists.txt | 1 + src/Trade/Test/TextureDataTest.cpp | 52 ++++++++++++++++++++++++++++++ src/Trade/TextureData.cpp | 42 ++++++++++++++++++++++++ src/Trade/TextureData.h | 4 +++ 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/Trade/Test/TextureDataTest.cpp create mode 100644 src/Trade/TextureData.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cee41dec2..bb6c8fb12 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,7 +81,8 @@ set(Magnum_SRCS Trade/ObjectData2D.cpp Trade/ObjectData3D.cpp Trade/PhongMaterialData.cpp - Trade/SceneData.cpp) + Trade/SceneData.cpp + Trade/TextureData.cpp) # Desktop-only code if(NOT TARGET_GLES) diff --git a/src/Trade/Test/CMakeLists.txt b/src/Trade/Test/CMakeLists.txt index 9efdaffeb..d1a162e92 100644 --- a/src/Trade/Test/CMakeLists.txt +++ b/src/Trade/Test/CMakeLists.txt @@ -33,3 +33,4 @@ corrade_add_test(TradeAbstractMaterialDataTest AbstractMaterialDataTest.cpp LIBR corrade_add_test(TradeImageDataTest ImageDataTest.cpp LIBRARIES Magnum) corrade_add_test(TradeObjectData2DTest ObjectData2DTest.cpp LIBRARIES Magnum) corrade_add_test(TradeObjectData3DTest ObjectData3DTest.cpp LIBRARIES Magnum) +corrade_add_test(TradeTextureDataTest TextureDataTest.cpp LIBRARIES Magnum) diff --git a/src/Trade/Test/TextureDataTest.cpp b/src/Trade/Test/TextureDataTest.cpp new file mode 100644 index 000000000..3fb83bd70 --- /dev/null +++ b/src/Trade/Test/TextureDataTest.cpp @@ -0,0 +1,52 @@ +/* + 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 +#include + +#include "Trade/TextureData.h" + +namespace Magnum { namespace Trade { namespace Test { + +class TextureDataTest: public TestSuite::Tester { + public: + explicit TextureDataTest(); + + void debug(); +}; + +TextureDataTest::TextureDataTest() { + addTests({&TextureDataTest::debug}); +} + +void TextureDataTest::debug() { + std::ostringstream out; + + Debug(&out) << TextureData::Type::Texture3D; + CORRADE_COMPARE(out.str(), "Trade::TextureData::Type::Texture3D\n"); +} + +}}} + +CORRADE_TEST_MAIN(Magnum::Trade::Test::TextureDataTest) diff --git a/src/Trade/TextureData.cpp b/src/Trade/TextureData.cpp new file mode 100644 index 000000000..96da87c2d --- /dev/null +++ b/src/Trade/TextureData.cpp @@ -0,0 +1,42 @@ +/* + 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 "TextureData.h" + +namespace Magnum { namespace Trade { + +Debug operator<<(Debug debug, const TextureData::Type value) { + switch(value) { + #define _c(value) case TextureData::Type::value: return debug << "Trade::TextureData::Type::" #value; + _c(Texture1D) + _c(Texture2D) + _c(Texture3D) + _c(Cube) + #undef _c + } + + return debug << "Trade::TextureData::Type::(unknown)"; +} + +}} diff --git a/src/Trade/TextureData.h b/src/Trade/TextureData.h index faa98a31a..8a9bcd3fc 100644 --- a/src/Trade/TextureData.h +++ b/src/Trade/TextureData.h @@ -30,6 +30,7 @@ #include "Array.h" #include "Sampler.h" +#include "magnumVisibility.h" namespace Magnum { namespace Trade { @@ -107,6 +108,9 @@ class TextureData { UnsignedInt _image; }; +/** @debugoperator{Magnum::Trade::TextureData} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, TextureData::Type value); + }} #endif