diff --git a/src/Trade/AbstractMaterialData.cpp b/src/Trade/AbstractMaterialData.cpp index d62afcf40..7df183d61 100644 --- a/src/Trade/AbstractMaterialData.cpp +++ b/src/Trade/AbstractMaterialData.cpp @@ -24,10 +24,22 @@ #include "AbstractMaterialData.h" +#include + namespace Magnum { namespace Trade { AbstractMaterialData::AbstractMaterialData(Type type): _type(type) {} AbstractMaterialData::~AbstractMaterialData() {} +Debug operator<<(Debug debug, const AbstractMaterialData::Type value) { + switch(value) { + #define _c(value) case AbstractMaterialData::Type::value: return debug << "Trade::AbstractMaterialData::Type::" #value; + _c(Phong) + #undef _c + } + + return debug << "Trade::AbstractMaterialData::Type::(unknown)"; +} + }} diff --git a/src/Trade/AbstractMaterialData.h b/src/Trade/AbstractMaterialData.h index e737c57da..2cf22eddf 100644 --- a/src/Trade/AbstractMaterialData.h +++ b/src/Trade/AbstractMaterialData.h @@ -29,7 +29,7 @@ */ #include "magnumVisibility.h" -#include "Types.h" +#include "Magnum.h" namespace Magnum { namespace Trade { @@ -73,6 +73,9 @@ class MAGNUM_EXPORT AbstractMaterialData { Type _type; }; +/** @debugoperator{Magnum::Trade::AbstractMaterialData} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, AbstractMaterialData::Type value); + }} #endif diff --git a/src/Trade/Test/AbstractMaterialDataTest.cpp b/src/Trade/Test/AbstractMaterialDataTest.cpp new file mode 100644 index 000000000..be2ab6ec8 --- /dev/null +++ b/src/Trade/Test/AbstractMaterialDataTest.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/AbstractMaterialData.h" + +namespace Magnum { namespace Trade { namespace Test { + +class AbstractMaterialDataTest: public TestSuite::Tester { + public: + explicit AbstractMaterialDataTest(); + + void debug(); +}; + +AbstractMaterialDataTest::AbstractMaterialDataTest() { + addTests({&AbstractMaterialDataTest::debug}); +} + +void AbstractMaterialDataTest::debug() { + std::ostringstream out; + + Debug(&out) << AbstractMaterialData::Type::Phong; + CORRADE_COMPARE(out.str(), "Trade::AbstractMaterialData::Type::Phong\n"); +} + +}}} + +CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractMaterialDataTest) diff --git a/src/Trade/Test/CMakeLists.txt b/src/Trade/Test/CMakeLists.txt index beb1c2ccf..9efdaffeb 100644 --- a/src/Trade/Test/CMakeLists.txt +++ b/src/Trade/Test/CMakeLists.txt @@ -29,6 +29,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(TradeAbstractImageConverterTest AbstractImageConverterTest.cpp LIBRARIES Magnum) corrade_add_test(TradeAbstractImporterTest AbstractImporterTest.cpp LIBRARIES Magnum) +corrade_add_test(TradeAbstractMaterialDataTest AbstractMaterialDataTest.cpp LIBRARIES Magnum) corrade_add_test(TradeImageDataTest ImageDataTest.cpp LIBRARIES Magnum) corrade_add_test(TradeObjectData2DTest ObjectData2DTest.cpp LIBRARIES Magnum) corrade_add_test(TradeObjectData3DTest ObjectData3DTest.cpp LIBRARIES Magnum)