diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 833bdc617..1f20f218e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,9 @@ set(Magnum_SRCS Trade/AbstractImporter.cpp Trade/MeshData2D.cpp - Trade/MeshData3D.cpp) + Trade/MeshData3D.cpp + Trade/ObjectData2D.cpp + Trade/ObjectData3D.cpp) # Desktop-only code if(NOT TARGET_GLES) diff --git a/src/Trade/CMakeLists.txt b/src/Trade/CMakeLists.txt index 12b1fd60d..11d7bac8f 100644 --- a/src/Trade/CMakeLists.txt +++ b/src/Trade/CMakeLists.txt @@ -14,3 +14,8 @@ set(MagnumTrade_HEADERS SceneData.h TextureData.h) install(FILES ${MagnumTrade_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade) + +if(BUILD_TESTS) + enable_testing() + add_subdirectory(Test) +endif() diff --git a/src/Trade/ObjectData2D.cpp b/src/Trade/ObjectData2D.cpp new file mode 100644 index 000000000..bf71a36cc --- /dev/null +++ b/src/Trade/ObjectData2D.cpp @@ -0,0 +1,34 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "ObjectData2D.h" + +namespace Magnum { namespace Trade { + +#ifndef DOXYGEN_GENERATING_OUTPUT +Debug operator<<(Debug debug, ObjectData2D::InstanceType value) { + switch(value) { + #define _c(value) case ObjectData2D::InstanceType::value: return debug << "Trade::ObjectData2D::InstanceType::" #value; + _c(Camera) + _c(Mesh) + _c(Empty) + #undef _c + } + + return debug << "ObjectData2D::InstanceType::(invalid)"; +} +#endif + +}} diff --git a/src/Trade/ObjectData2D.h b/src/Trade/ObjectData2D.h index 49c049d31..40ae13a97 100644 --- a/src/Trade/ObjectData2D.h +++ b/src/Trade/ObjectData2D.h @@ -95,6 +95,9 @@ class ObjectData2D { std::int32_t _instanceId; }; +/** @debugoperator{Magnum::Trade::ObjectData2D} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, ObjectData2D::InstanceType value); + }} #endif diff --git a/src/Trade/ObjectData3D.cpp b/src/Trade/ObjectData3D.cpp new file mode 100644 index 000000000..ee4fc9fae --- /dev/null +++ b/src/Trade/ObjectData3D.cpp @@ -0,0 +1,35 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "ObjectData3D.h" + +namespace Magnum { namespace Trade { + +#ifndef DOXYGEN_GENERATING_OUTPUT +Debug operator<<(Debug debug, ObjectData3D::InstanceType value) { + switch(value) { + #define _c(value) case ObjectData3D::InstanceType::value: return debug << "Trade::ObjectData3D::InstanceType::" #value; + _c(Camera) + _c(Light) + _c(Mesh) + _c(Empty) + #undef _c + } + + return debug << "ObjectData3D::InstanceType::(invalid)"; +} +#endif + +}} diff --git a/src/Trade/ObjectData3D.h b/src/Trade/ObjectData3D.h index 2db3a0d29..e6862cb52 100644 --- a/src/Trade/ObjectData3D.h +++ b/src/Trade/ObjectData3D.h @@ -96,6 +96,9 @@ class ObjectData3D { std::int32_t _instanceId; }; +/** @debugoperator{Magnum::Trade::ObjectData3D} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, ObjectData3D::InstanceType value); + }} #endif diff --git a/src/Trade/Test/CMakeLists.txt b/src/Trade/Test/CMakeLists.txt new file mode 100644 index 000000000..84ba62f24 --- /dev/null +++ b/src/Trade/Test/CMakeLists.txt @@ -0,0 +1,2 @@ +corrade_add_test(TradeObjectData2DTest ObjectData2DTest.cpp LIBRARIES Magnum) +corrade_add_test(TradeObjectData3DTest ObjectData3DTest.cpp LIBRARIES Magnum) diff --git a/src/Trade/Test/ObjectData2DTest.cpp b/src/Trade/Test/ObjectData2DTest.cpp new file mode 100644 index 000000000..81e35b922 --- /dev/null +++ b/src/Trade/Test/ObjectData2DTest.cpp @@ -0,0 +1,42 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include +#include + +#include "Trade/ObjectData2D.h" + +namespace Magnum { namespace Trade { namespace Test { + +class ObjectData2DTest: public Corrade::TestSuite::Tester { + public: + explicit ObjectData2DTest(); + + void debug(); +}; + +ObjectData2DTest::ObjectData2DTest() { + addTests(&ObjectData2DTest::debug); +} + +void ObjectData2DTest::debug() { + std::ostringstream o; + Debug(&o) << ObjectData2D::InstanceType::Empty; + CORRADE_COMPARE(o.str(), "Trade::ObjectData2D::InstanceType::Empty\n"); +} + +}}} + +CORRADE_TEST_MAIN(Magnum::Trade::Test::ObjectData2DTest) diff --git a/src/Trade/Test/ObjectData3DTest.cpp b/src/Trade/Test/ObjectData3DTest.cpp new file mode 100644 index 000000000..95636e0cb --- /dev/null +++ b/src/Trade/Test/ObjectData3DTest.cpp @@ -0,0 +1,42 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include +#include + +#include "Trade/ObjectData3D.h" + +namespace Magnum { namespace Trade { namespace Test { + +class ObjectData3DTest: public Corrade::TestSuite::Tester { + public: + explicit ObjectData3DTest(); + + void debug(); +}; + +ObjectData3DTest::ObjectData3DTest() { + addTests(&ObjectData3DTest::debug); +} + +void ObjectData3DTest::debug() { + std::ostringstream o; + Debug(&o) << ObjectData3D::InstanceType::Light; + CORRADE_COMPARE(o.str(), "Trade::ObjectData3D::InstanceType::Light\n"); +} + +}}} + +CORRADE_TEST_MAIN(Magnum::Trade::Test::ObjectData3DTest)