From c442c07190c010f854a3f5e1216f4e7e26b5773b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 25 May 2019 16:07:01 +0200 Subject: [PATCH] Audio: add debug operator for Source::Type. --- src/Magnum/Audio/Source.cpp | 14 ++++++++++++++ src/Magnum/Audio/Source.h | 3 +++ src/Magnum/Audio/Test/SourceTest.cpp | 10 +++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Audio/Source.cpp b/src/Magnum/Audio/Source.cpp index 7bf957417..25e3e99d3 100644 --- a/src/Magnum/Audio/Source.cpp +++ b/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(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(ALint(value)) << Debug::nospace << ")"; +} + }} diff --git a/src/Magnum/Audio/Source.h b/src/Magnum/Audio/Source.h index 2628806cc..57f877d1f 100644 --- a/src/Magnum/Audio/Source.h +++ b/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; } diff --git a/src/Magnum/Audio/Test/SourceTest.cpp b/src/Magnum/Audio/Test/SourceTest.cpp index 57f61dca6..87e8ca3b6 100644 --- a/src/Magnum/Audio/Test/SourceTest.cpp +++ b/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)