From e0be7c14f1903717e4eb35faf682c3ba2d0ee7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Apr 2018 15:10:22 +0200 Subject: [PATCH] Max out Array test coverage. Of course the untested part has a bug. --- src/Magnum/Array.h | 6 +++--- src/Magnum/Test/ArrayTest.cpp | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Array.h b/src/Magnum/Array.h index f6edc34ec..8f5c35020 100644 --- a/src/Magnum/Array.h +++ b/src/Magnum/Array.h @@ -201,12 +201,12 @@ template class Array3D: public Array<3, T> { /** @debugoperator{Array} */ template Debug& operator<<(Debug& debug, const Array& value) { - debug << "Array(" << Corrade::Utility::Debug::nospace; + debug << "Array(" << Debug::nospace; for(UnsignedInt i = 0; i != dimensions; ++i) { - if(i != 0) debug << ","; + if(i != 0) debug << Debug::nospace << ","; debug << value[i]; } - return debug << Corrade::Utility::Debug::nospace << ")"; + return debug << Debug::nospace << ")"; } /** @debugoperator{Array1D} */ diff --git a/src/Magnum/Test/ArrayTest.cpp b/src/Magnum/Test/ArrayTest.cpp index 456161698..6a96d2a6f 100644 --- a/src/Magnum/Test/ArrayTest.cpp +++ b/src/Magnum/Test/ArrayTest.cpp @@ -23,6 +23,7 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #include "Magnum/Array.h" @@ -35,6 +36,8 @@ struct ArrayTest: TestSuite::Tester { void construct(); void equality(); void access(); + + void debug(); }; typedef Magnum::Array1D Array1D; @@ -44,7 +47,9 @@ typedef Magnum::Array3D Array3D; ArrayTest::ArrayTest() { addTests({&ArrayTest::construct, &ArrayTest::equality, - &ArrayTest::access}); + &ArrayTest::access, + + &ArrayTest::debug}); } void ArrayTest::construct() { @@ -109,6 +114,13 @@ void ArrayTest::access() { CORRADE_COMPARE(cc.xy(), Array2D(-5, 6)); } +void ArrayTest::debug() { + std::ostringstream out; + + Debug{&out} << Array<4, Int>{5, 6, 7, 8} << Array1D{13} << Array2D{71, 2} << Array3D{1, 2, 3}; + CORRADE_COMPARE(out.str(), "Array(5, 6, 7, 8) Array(13) Array(71, 2) Array(1, 2, 3)\n"); +} + }} CORRADE_TEST_MAIN(Magnum::Test::ArrayTest)