From 490c7b00755383eba1354166e20b27e3e3c05920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 14 Feb 2025 18:46:20 +0100 Subject: [PATCH] TextureTools: properly test AtlasLandfill array recursion failure. It only verified the case where there are no more slices, but not when the recursed function fails because there are no more slices. Now it does. --- src/Magnum/TextureTools/Test/AtlasTest.cpp | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Magnum/TextureTools/Test/AtlasTest.cpp b/src/Magnum/TextureTools/Test/AtlasTest.cpp index 2f05c4ce2..0d1ccd9ba 100644 --- a/src/Magnum/TextureTools/Test/AtlasTest.cpp +++ b/src/Magnum/TextureTools/Test/AtlasTest.cpp @@ -1004,15 +1004,23 @@ void AtlasTest::landfillArrayPadded() { } void AtlasTest::landfillArrayNoFit() { - /* Same as landfillArray(portrait, widest first) (which is the default - flags) which fits into {11, 6, 2} but limiting depth to 1 */ - - AtlasLandfill atlas{{11, 6, 1}}; + /* It should fail in the second slice, not first, to test also that the + recursion failure is propagated */ + { + AtlasLandfill atlas{{6, 6, 2}}; + Vector3i offsets[Containers::arraySize(LandfillArraySizes)]; + UnsignedByte rotationData[2]; + Containers::MutableBitArrayView rotations{rotationData, 0, Containers::arraySize(LandfillArraySizes)}; + CORRADE_VERIFY(!atlas.add(LandfillArraySizes, offsets, rotations)); - Vector3i offsets[Containers::arraySize(LandfillArraySizes)]; - UnsignedByte rotationData[2]; - Containers::MutableBitArrayView rotations{rotationData, 0, Containers::arraySize(LandfillArraySizes)}; - CORRADE_VERIFY(!atlas.add(LandfillArraySizes, offsets, rotations)); + /* Sanity check that with one more slice it works */ + } { + AtlasLandfill atlas{{6, 6, 3}}; + Vector3i offsets[Containers::arraySize(LandfillArraySizes)]; + UnsignedByte rotationData[2]; + Containers::MutableBitArrayView rotations{rotationData, 0, Containers::arraySize(LandfillArraySizes)}; + CORRADE_VERIFY(atlas.add(LandfillArraySizes, offsets, rotations)); + } } void AtlasTest::landfillInvalidSize() {