Browse Source

Trade: debug output for ObjectData*D::InstanceType enum.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
82f3b948af
  1. 4
      src/CMakeLists.txt
  2. 5
      src/Trade/CMakeLists.txt
  3. 34
      src/Trade/ObjectData2D.cpp
  4. 3
      src/Trade/ObjectData2D.h
  5. 35
      src/Trade/ObjectData3D.cpp
  6. 3
      src/Trade/ObjectData3D.h
  7. 2
      src/Trade/Test/CMakeLists.txt
  8. 42
      src/Trade/Test/ObjectData2DTest.cpp
  9. 42
      src/Trade/Test/ObjectData3DTest.cpp

4
src/CMakeLists.txt

@ -33,7 +33,9 @@ set(Magnum_SRCS
Trade/AbstractImporter.cpp Trade/AbstractImporter.cpp
Trade/MeshData2D.cpp Trade/MeshData2D.cpp
Trade/MeshData3D.cpp) Trade/MeshData3D.cpp
Trade/ObjectData2D.cpp
Trade/ObjectData3D.cpp)
# Desktop-only code # Desktop-only code
if(NOT TARGET_GLES) if(NOT TARGET_GLES)

5
src/Trade/CMakeLists.txt

@ -14,3 +14,8 @@ set(MagnumTrade_HEADERS
SceneData.h SceneData.h
TextureData.h) TextureData.h)
install(FILES ${MagnumTrade_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade) install(FILES ${MagnumTrade_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(Test)
endif()

34
src/Trade/ObjectData2D.cpp

@ -0,0 +1,34 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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
}}

3
src/Trade/ObjectData2D.h

@ -95,6 +95,9 @@ class ObjectData2D {
std::int32_t _instanceId; std::int32_t _instanceId;
}; };
/** @debugoperator{Magnum::Trade::ObjectData2D} */
Debug MAGNUM_EXPORT operator<<(Debug debug, ObjectData2D::InstanceType value);
}} }}
#endif #endif

35
src/Trade/ObjectData3D.cpp

@ -0,0 +1,35 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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
}}

3
src/Trade/ObjectData3D.h

@ -96,6 +96,9 @@ class ObjectData3D {
std::int32_t _instanceId; std::int32_t _instanceId;
}; };
/** @debugoperator{Magnum::Trade::ObjectData3D} */
Debug MAGNUM_EXPORT operator<<(Debug debug, ObjectData3D::InstanceType value);
}} }}
#endif #endif

2
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)

42
src/Trade/Test/ObjectData2DTest.cpp

@ -0,0 +1,42 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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 <sstream>
#include <TestSuite/Tester.h>
#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)

42
src/Trade/Test/ObjectData3DTest.cpp

@ -0,0 +1,42 @@
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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 <sstream>
#include <TestSuite/Tester.h>
#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)
Loading…
Cancel
Save