Browse Source

Trade: debug output for AbstractImporter::Feature and Features.

pull/191/head
Vladimír Vondruš 8 years ago
parent
commit
365f501f72
  1. 2
      doc/changelog.dox
  2. 18
      src/Magnum/Trade/AbstractImporter.cpp
  3. 6
      src/Magnum/Trade/AbstractImporter.h
  4. 23
      src/Magnum/Trade/Test/AbstractImporterTest.cpp

2
doc/changelog.dox

@ -74,6 +74,8 @@ See also:
separate translation / rotation / scaling specification instead of a
combined transformation matrix. See @ref Trade::ObjectData2D::transformation()
and @ref Trade::ObjectData3D::transformation() for more information.
- Debug output for @ref Trade::AbstractImporter::Feature enum and
@ref Trade::AbstractImporter::Features enum set
@subsection changelog-latest-changes Changes and improvements

18
src/Magnum/Trade/AbstractImporter.cpp

@ -26,6 +26,7 @@
#include "AbstractImporter.h"
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Directory.h>
@ -496,4 +497,21 @@ const void* AbstractImporter::importerState() const {
const void* AbstractImporter::doImporterState() const { return nullptr; }
Debug& operator<<(Debug& debug, const AbstractImporter::Feature value) {
switch(value) {
#define _c(v) case AbstractImporter::Feature::v: return debug << "Trade::AbstractImporter::Feature::" #v;
_c(OpenData)
_c(OpenState)
#undef _c
}
return debug << "Trade::AbstractImporter::Feature(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const AbstractImporter::Features value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::AbstractImporter::Features{}", {
AbstractImporter::Feature::OpenData,
AbstractImporter::Feature::OpenState});
}
}}

6
src/Magnum/Trade/AbstractImporter.h

@ -872,6 +872,12 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
CORRADE_ENUMSET_OPERATORS(AbstractImporter::Features)
/** @debugoperatorclassenum{AbstractImporter,AbstractImporter::Feature} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AbstractImporter::Feature value);
/** @debugoperatorclassenum{AbstractImporter,AbstractImporter::Features} */
MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AbstractImporter::Features value);
}}
#endif

23
src/Magnum/Trade/Test/AbstractImporterTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/Directory.h>
@ -38,10 +39,16 @@ class AbstractImporterTest: public TestSuite::Tester {
explicit AbstractImporterTest();
void openFile();
void debugFeature();
void debugFeatures();
};
AbstractImporterTest::AbstractImporterTest() {
addTests({&AbstractImporterTest::openFile});
addTests({&AbstractImporterTest::openFile,
&AbstractImporterTest::debugFeature,
&AbstractImporterTest::debugFeatures});
}
void AbstractImporterTest::openFile() {
@ -68,6 +75,20 @@ void AbstractImporterTest::openFile() {
CORRADE_VERIFY(importer.isOpened());
}
void AbstractImporterTest::debugFeature() {
std::ostringstream out;
Debug{&out} << AbstractImporter::Feature::OpenData << AbstractImporter::Feature(0xf0);
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::Feature::OpenData Trade::AbstractImporter::Feature(0xf0)\n");
}
void AbstractImporterTest::debugFeatures() {
std::ostringstream out;
Debug{&out} << (AbstractImporter::Feature::OpenData|AbstractImporter::Feature::OpenState) << AbstractImporter::Features{};
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::Feature::OpenData|Trade::AbstractImporter::Feature::OpenState Trade::AbstractImporter::Features{}\n");
}
}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractImporterTest)

Loading…
Cancel
Save