From 6721c0e3b2bd97fde497810de472f45d2009d096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 21 Apr 2020 14:38:02 +0200 Subject: [PATCH] DebugTools: ugh WTF. I really need to implement my own float printer already, this is a mess. --- .../DebugTools/Test/CompareImageTest.cpp | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/Magnum/DebugTools/Test/CompareImageTest.cpp b/src/Magnum/DebugTools/Test/CompareImageTest.cpp index b63c0191c..91d16a53c 100644 --- a/src/Magnum/DebugTools/Test/CompareImageTest.cpp +++ b/src/Magnum/DebugTools/Test/CompareImageTest.cpp @@ -739,9 +739,22 @@ void CompareImageTest::compareSpecials() { " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"); #endif - /* Linux, Emscripten */ + /* Linux, Emscripten. Somehow, a Release build sometimes gives a positive + NaN, so test for both. */ #else - CORRADE_COMPARE(out.str(), + constexpr const char* expectedPositive = + "Images a and b have both max and mean delta above threshold, actual 3.1/nan but at most 1.5/0.5 expected. Delta image:\n" + " |MMMM M ,M|\n" + " Pixels above max/mean threshold:\n" + " [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n" + " [3,0] Vector(0.3), expected Vector(nan) (Δ = nan)\n" + " [2,0] Vector(nan), expected Vector(0.3) (Δ = nan)\n" + " [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n" + " [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n" + " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"; + if(out.str() == expectedPositive) + CORRADE_COMPARE(out.str(), expectedPositive); + else CORRADE_COMPARE(out.str(), "Images a and b have both max and mean delta above threshold, actual 3.1/-nan but at most 1.5/0.5 expected. Delta image:\n" " |MMMM M ,M|\n" " Pixels above max/mean threshold:\n" @@ -821,9 +834,22 @@ void CompareImageTest::compareSpecialsMeanOnly() { " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"); #endif - /* Linux, Emscripten */ + /* Linux, Emscripten. Somehow, a Release build sometimes gives a positive + NaN, so test for both. */ #else - CORRADE_COMPARE(out.str(), + constexpr const char* expectedPositive = + "Images a and b have mean delta above threshold, actual nan but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n" + " |MMMM M ,M|\n" + " Pixels above max/mean threshold:\n" + " [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n" + " [3,0] Vector(0.3), expected Vector(nan) (Δ = nan)\n" + " [2,0] Vector(nan), expected Vector(0.3) (Δ = nan)\n" + " [1,0] Vector(0.3), expected Vector(-inf) (Δ = inf)\n" + " [0,0] Vector(inf), expected Vector(1) (Δ = inf)\n" + " [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n"; + if(out.str() == expectedPositive) + CORRADE_COMPARE(out.str(), expectedPositive); + else CORRADE_COMPARE(out.str(), "Images a and b have mean delta above threshold, actual -nan but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n" " |MMMM M ,M|\n" " Pixels above max/mean threshold:\n"