Browse Source

DebugTools: improve CompareImage failure message.

The comparison is <=, so if it passes, it's not "below".
pull/364/head
Vladimír Vondruš 7 years ago
parent
commit
f84a91ea06
  1. 2
      doc/snippets/debugtools-compareimage.ansi
  2. 4
      src/Magnum/DebugTools/CompareImage.cpp
  3. 10
      src/Magnum/DebugTools/Test/CompareImageTest.cpp

2
doc/snippets/debugtools-compareimage.ansi

@ -1,7 +1,7 @@
Starting ProcessingTest with 1 test cases... Starting ProcessingTest with 1 test cases...
 FAIL [1] process() at …/debugtools-compareimage.cpp on line 77  FAIL [1] process() at …/debugtools-compareimage.cpp on line 77
Images actual and expected have max delta above threshold, actual 189 Images actual and expected have max delta above threshold, actual 189
but at most 170 expected. Mean delta 13.5776 is below threshold 96. but at most 170 expected. Mean delta 13.5776 is within threshold 96.
Delta image: Delta image:
| | | |
| | | |

4
src/Magnum/DebugTools/CompareImage.cpp

@ -611,12 +611,12 @@ void ImageComparatorBase::printMessage(TestSuite::ComparisonStatusFlags, Debug&
else if(_state->result == Result::AboveMaxThreshold) else if(_state->result == Result::AboveMaxThreshold)
out << "max delta above threshold, actual" << _state->max out << "max delta above threshold, actual" << _state->max
<< "but at most" << _state->maxThreshold << "but at most" << _state->maxThreshold
<< "expected. Mean delta" << _state->mean << "is below threshold" << "expected. Mean delta" << _state->mean << "is within threshold"
<< _state->meanThreshold << Debug::nospace << "."; << _state->meanThreshold << Debug::nospace << ".";
else if(_state->result == Result::AboveMeanThreshold) else if(_state->result == Result::AboveMeanThreshold)
out << "mean delta above threshold, actual" << _state->mean out << "mean delta above threshold, actual" << _state->mean
<< "but at most" << _state->meanThreshold << "but at most" << _state->meanThreshold
<< "expected. Max delta" << _state->max << "is below threshold" << "expected. Max delta" << _state->max << "is within threshold"
<< _state->maxThreshold << Debug::nospace << "."; << _state->maxThreshold << Debug::nospace << ".";
else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ else CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */

10
src/Magnum/DebugTools/Test/CompareImageTest.cpp

@ -588,7 +588,7 @@ void CompareImageTest::compareAboveMaxThreshold() {
} }
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"Images a and b have max delta above threshold, actual 39 but at most 30 expected. Mean delta 18.5 is below threshold 20. Delta image:\n" "Images a and b have max delta above threshold, actual 39 but at most 30 expected. Mean delta 18.5 is within threshold 20. Delta image:\n"
" |?M|\n" " |?M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
" [1,1] #abcd85, expected #abcdfa (Δ = 39)\n"); " [1,1] #abcd85, expected #abcdfa (Δ = 39)\n");
@ -607,7 +607,7 @@ void CompareImageTest::compareAboveMeanThreshold() {
} }
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"Images a and b have mean delta above threshold, actual 18.5 but at most 18 expected. Max delta 39 is below threshold 50. Delta image:\n" "Images a and b have mean delta above threshold, actual 18.5 but at most 18 expected. Max delta 39 is within threshold 50. Delta image:\n"
" |?M|\n" " |?M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
" [1,1] #abcd85, expected #abcdfa (Δ = 39)\n" " [1,1] #abcd85, expected #abcdfa (Δ = 39)\n"
@ -684,7 +684,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
NaNs. This is *not* a libc++ thing, tho -- libc++ on Linux prints signed NaNs. */ NaNs. This is *not* a libc++ thing, tho -- libc++ on Linux prints signed NaNs. */
#if defined(CORRADE_TARGET_APPLE) || defined(CORRADE_TARGET_ANDROID) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(__MINGW32__) #if defined(CORRADE_TARGET_APPLE) || defined(CORRADE_TARGET_ANDROID) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(__MINGW32__)
CORRADE_COMPARE(out.str(), 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 below threshold 15. Delta image:\n" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
" [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n" " [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n"
@ -697,7 +697,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
/* MSVC prints -nan(ind) instead of ±nan. But only sometimes. */ /* MSVC prints -nan(ind) instead of ±nan. But only sometimes. */
#elif defined(CORRADE_TARGET_WINDOWS) && defined(_MSC_VER) #elif defined(CORRADE_TARGET_WINDOWS) && defined(_MSC_VER)
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"Images a and b have mean delta above threshold, actual -nan(ind) but at most 0.5 expected. Max delta 3.1 is below threshold 15. Delta image:\n" "Images a and b have mean delta above threshold, actual -nan(ind) but at most 0.5 expected. Max delta 3.1 is within threshold 15. Delta image:\n"
" |MMMM M ,M|\n" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
" [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n" " [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n"
@ -710,7 +710,7 @@ void CompareImageTest::compareSpecialsMeanOnly() {
/* Linux */ /* Linux */
#else #else
CORRADE_COMPARE(out.str(), 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 below threshold 15. Delta image:\n" "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" " |MMMM M ,M|\n"
" Pixels above max/mean threshold:\n" " Pixels above max/mean threshold:\n"
" [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n" " [5,0] Vector(-inf), expected Vector(inf) (Δ = inf)\n"

Loading…
Cancel
Save