Browse Source

Trade: debug output operator for TextureData::Type enum.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
50ef1df213
  1. 3
      src/CMakeLists.txt
  2. 1
      src/Trade/Test/CMakeLists.txt
  3. 52
      src/Trade/Test/TextureDataTest.cpp
  4. 42
      src/Trade/TextureData.cpp
  5. 4
      src/Trade/TextureData.h

3
src/CMakeLists.txt

@ -81,7 +81,8 @@ set(Magnum_SRCS
Trade/ObjectData2D.cpp Trade/ObjectData2D.cpp
Trade/ObjectData3D.cpp Trade/ObjectData3D.cpp
Trade/PhongMaterialData.cpp Trade/PhongMaterialData.cpp
Trade/SceneData.cpp) Trade/SceneData.cpp
Trade/TextureData.cpp)
# Desktop-only code # Desktop-only code
if(NOT TARGET_GLES) if(NOT TARGET_GLES)

1
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(TradeImageDataTest ImageDataTest.cpp LIBRARIES Magnum)
corrade_add_test(TradeObjectData2DTest ObjectData2DTest.cpp LIBRARIES Magnum) corrade_add_test(TradeObjectData2DTest ObjectData2DTest.cpp LIBRARIES Magnum)
corrade_add_test(TradeObjectData3DTest ObjectData3DTest.cpp LIBRARIES Magnum) corrade_add_test(TradeObjectData3DTest ObjectData3DTest.cpp LIBRARIES Magnum)
corrade_add_test(TradeTextureDataTest TextureDataTest.cpp LIBRARIES Magnum)

52
src/Trade/Test/TextureDataTest.cpp

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

42
src/Trade/TextureData.cpp

@ -0,0 +1,42 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
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)";
}
}}

4
src/Trade/TextureData.h

@ -30,6 +30,7 @@
#include "Array.h" #include "Array.h"
#include "Sampler.h" #include "Sampler.h"
#include "magnumVisibility.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -107,6 +108,9 @@ class TextureData {
UnsignedInt _image; UnsignedInt _image;
}; };
/** @debugoperator{Magnum::Trade::TextureData} */
Debug MAGNUM_EXPORT operator<<(Debug debug, TextureData::Type value);
}} }}
#endif #endif

Loading…
Cancel
Save