Browse Source

Debug output for AbstractImage::Format and AbstractImage::Type enums.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
8ce184ef7b
  1. 83
      src/AbstractImage.cpp
  2. 6
      src/AbstractImage.h
  3. 50
      src/Test/AbstractImageTest.cpp
  4. 1
      src/Test/CMakeLists.txt

83
src/AbstractImage.cpp

@ -119,4 +119,87 @@ std::size_t AbstractImage::pixelSize(Format format, Type type) {
return 0;
}
Debug operator<<(Debug debug, AbstractImage::Format value) {
switch(value) {
#define _c(value) case AbstractImage::Format::value: return debug << "AbstractImage::Format::" #value;
_c(Red)
#ifndef MAGNUM_TARGET_GLES
_c(Green)
_c(Blue)
#endif
_c(RG)
_c(RGB)
_c(RGBA)
#ifndef MAGNUM_TARGET_GLES
_c(BGR)
#endif
_c(BGRA)
#ifndef MAGNUM_TARGET_GLES2
_c(RedInteger)
_c(GreenInteger)
_c(BlueInteger)
_c(RGInteger)
_c(RGBInteger)
_c(RGBAInteger)
_c(BGRInteger)
_c(BGRAInteger)
#endif
_c(DepthComponent)
_c(StencilIndex)
_c(DepthStencil)
#undef _c
}
return debug << "AbstractImage::Format::(invalid)";
}
Debug operator<<(Debug debug, AbstractImage::Type value) {
switch(value) {
#define _c(value) case AbstractImage::Type::value: return debug << "AbstractImage::Type::" #value;
_c(UnsignedByte)
#ifndef MAGNUM_TARGET_GLES2
_c(Byte)
#endif
_c(UnsignedShort)
#ifndef MAGNUM_TARGET_GLES2
_c(Short)
#endif
_c(UnsignedInt)
#ifndef MAGNUM_TARGET_GLES2
_c(Int)
#endif
_c(HalfFloat)
_c(Float)
#ifndef MAGNUM_TARGET_GLES2
_c(UnsignedByte332)
_c(UnsignedByte233Rev)
#endif
_c(UnsignedShort565)
#ifndef MAGNUM_TARGET_GLES
_c(UnsignedShort565Rev)
#endif
_c(UnsignedShort4444)
_c(UnsignedShort4444Rev)
_c(UnsignedShort5551)
_c(UnsignedShort1555Rev)
#ifndef MAGNUM_TARGET_GLES
_c(UnsignedInt8888)
_c(UnsignedInt8888Rev)
_c(UnsignedInt1010102)
#endif
_c(UnsignedInt2101010Rev)
#ifndef MAGNUM_TARGET_GLES2
_c(UnsignedInt10F11F11FRev)
_c(UnsignedInt5999Rev)
#endif
_c(UnsignedInt248)
#ifndef MAGNUM_TARGET_GLES2
_c(Float32UnsignedInt248Rev)
#endif
#undef _c
}
return debug << "AbstractImage::Type::(invalid)";
}
}

6
src/AbstractImage.h

@ -456,6 +456,12 @@ class MAGNUM_EXPORT AbstractImage {
inline AbstractImage::~AbstractImage() {}
/** @debugoperator{Magnum::AbstractImage} */
Debug MAGNUM_EXPORT operator<<(Debug debug, AbstractImage::Format value);
/** @debugoperator{Magnum::AbstractImage} */
Debug MAGNUM_EXPORT operator<<(Debug debug, AbstractImage::Type value);
}
#endif

50
src/Test/AbstractImageTest.cpp

@ -0,0 +1,50 @@
/*
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 "AbstractImage.h"
namespace Magnum { namespace Test {
class AbstractImageTest: public Corrade::TestSuite::Tester {
public:
explicit AbstractImageTest();
void debugFormat();
void debugType();
};
AbstractImageTest::AbstractImageTest() {
addTests(&AbstractImageTest::debugFormat,
&AbstractImageTest::debugType);
}
void AbstractImageTest::debugFormat() {
std::ostringstream o;
Debug(&o) << AbstractImage::Format::RGBA;
CORRADE_COMPARE(o.str(), "AbstractImage::Format::RGBA\n");
}
void AbstractImageTest::debugType() {
std::ostringstream o;
Debug(&o) << AbstractImage::Type::UnsignedShort5551;
CORRADE_COMPARE(o.str(), "AbstractImage::Type::UnsignedShort5551\n");
}
}}
CORRADE_TEST_MAIN(Magnum::Test::AbstractImageTest)

1
src/Test/CMakeLists.txt

@ -1,3 +1,4 @@
corrade_add_test(AbstractImageTest AbstractImageTest.cpp LIBRARIES Magnum)
corrade_add_test(ArrayTest ArrayTest.cpp)
corrade_add_test(ColorTest ColorTest.cpp LIBRARIES MagnumMathTestLib)
corrade_add_test(MeshTest MeshTest.cpp LIBRARIES Magnum)

Loading…
Cancel
Save