Browse Source

Audio: add debug operator for Source::Type.

pull/342/head
Vladimír Vondruš 7 years ago
parent
commit
c442c07190
  1. 14
      src/Magnum/Audio/Source.cpp
  2. 3
      src/Magnum/Audio/Source.h
  3. 10
      src/Magnum/Audio/Test/SourceTest.cpp

14
src/Magnum/Audio/Source.cpp

@ -140,4 +140,18 @@ Debug& operator<<(Debug& debug, const Source::State value) {
return debug << "Audio::Source::State(" << Debug::nospace << reinterpret_cast<void*>(ALint(value)) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const Source::Type value) {
switch(value) {
/* LCOV_EXCL_START */
#define _c(value) case Source::Type::value: return debug << "Audio::Source::Type::" #value;
_c(Undetermined)
_c(Static)
_c(Streaming)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "Audio::Source::Type(" << Debug::nospace << reinterpret_cast<void*>(ALint(value)) << Debug::nospace << ")";
}
}}

3
src/Magnum/Audio/Source.h

@ -748,6 +748,9 @@ class MAGNUM_AUDIO_EXPORT Source {
/** @debugoperatorclassenum{Source,Source::State} */
MAGNUM_AUDIO_EXPORT Debug& operator<<(Debug& debug, Source::State value);
/** @debugoperatorclassenum{Source,Source::Type} */
MAGNUM_AUDIO_EXPORT Debug& operator<<(Debug& debug, Source::Type value);
inline Source::Source(Source&& other): _id(other._id) {
other._id = 0;
}

10
src/Magnum/Audio/Test/SourceTest.cpp

@ -35,10 +35,12 @@ struct SourceTest: TestSuite::Tester {
explicit SourceTest();
void debugState();
void debugType();
};
SourceTest::SourceTest() {
addTests({&SourceTest::debugState});
addTests({&SourceTest::debugState,
&SourceTest::debugType});
}
void SourceTest::debugState() {
@ -47,6 +49,12 @@ void SourceTest::debugState() {
CORRADE_COMPARE(out.str(), "Audio::Source::State::Playing Audio::Source::State(0xdead)\n");
}
void SourceTest::debugType() {
std::ostringstream out;
Debug(&out) << Source::Type::Streaming << Source::Type(0xdead);
CORRADE_COMPARE(out.str(), "Audio::Source::Type::Streaming Audio::Source::Type(0xdead)\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Audio::Test::SourceTest)

Loading…
Cancel
Save