diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 2f4f2d9df..3013215b2 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -233,8 +233,8 @@ template class Matrix { #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix& value) { - debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); debug << "Matrix("; + debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); for(size_t row = 0; row != size; ++row) { if(row != 0) debug << ",\n "; for(size_t col = 0; col != size; ++col) { @@ -242,7 +242,9 @@ template Corrade::Utility::Debug operator<<(Corrade::Utili debug << value.at(row, col); } } - return debug << ')'; + debug << ')'; + debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true); + return debug; } #endif diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index 8d97c4b7d..c44decc8f 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -247,6 +247,16 @@ void MatrixTest::debug() { " 5, 4, -1, 4,\n" " 8, 7, 8, 5,\n" " 4, 3, 0, 9)\n")); + + o.str(""); + Debug(&o) << "a" << Matrix4() << "b" << Matrix4(); + QCOMPARE(QString::fromStdString(o.str()), QString("a Matrix(1, 0, 0, 0,\n" + " 0, 1, 0, 0,\n" + " 0, 0, 1, 0,\n" + " 0, 0, 0, 1) b Matrix(1, 0, 0, 0,\n" + " 0, 1, 0, 0,\n" + " 0, 0, 1, 0,\n" + " 0, 0, 0, 1)\n")); } }}} diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index 5cdb4131e..b6b7b93a2 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -140,6 +140,10 @@ void VectorTest::debug() { ostringstream o; Debug(&o) << Vector4(vec); QCOMPARE(QString::fromStdString(o.str()), QString("Vector(0.5, 15, 1, 1)\n")); + + o.str(""); + Debug(&o) << "a" << Vector4() << "b" << Vector4(); + QCOMPARE(QString::fromStdString(o.str()), QString("a Vector(0, 0, 0, 0) b Vector(0, 0, 0, 0)\n")); } }}} diff --git a/src/Math/Vector.h b/src/Math/Vector.h index c866350da..bab8a704d 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -179,13 +179,15 @@ template class Vector { #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector& value) { - debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); debug << "Vector("; + debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); for(size_t i = 0; i != size; ++i) { if(i != 0) debug << ", "; debug << value.at(i); } - return debug << ')'; + debug << ')'; + debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true); + return debug; } #endif