Browse Source

Math,DebugTools: adapt tests for Android differences in NaN printing.

What a waste of energy. I need my own float printing code already.
pull/539/head
Vladimír Vondruš 4 years ago
parent
commit
5c6b98391d
  1. 48
      src/Magnum/DebugTools/Test/CompareImageTest.cpp
  2. 24
      src/Magnum/Math/Test/Matrix3Test.cpp
  3. 28
      src/Magnum/Math/Test/Matrix4Test.cpp

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

@ -720,23 +720,8 @@ void CompareImageTest::compareSpecials() {
compare.printMessage(flags, d, "a", "b");
}
/* Apple platforms, Android and MinGW32 don't print signed NaNs. This is
*not* a libc++ thing, tho -- libc++ on Linux prints signed NaNs. It used
to be with Emscripten too, but since 1.38.44 works the same as Linux. */
#if defined(CORRADE_TARGET_APPLE) || defined(CORRADE_TARGET_ANDROID) || defined(CORRADE_TARGET_MINGW)
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"
" [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");
/* clang-cl prints -nan(ind) instead of ±nan, but differently than MSVC */
#elif defined(CORRADE_TARGET_CLANG_CL)
#ifdef CORRADE_TARGET_CLANG_CL
CORRADE_COMPARE(out.str(),
"Images a and b have both max and mean delta above threshold, actual 3.1/-nan(ind) but at most 1.5/0.5 expected. Delta image:\n"
" |MMMM M ,M|\n"
@ -789,8 +774,11 @@ void CompareImageTest::compareSpecials() {
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#endif
/* Linux, Emscripten. Somehow, a Release build sometimes gives a positive
NaN, so test for both. */
/* Linux, Emscripten, Android. Somehow, a Release build sometimes gives a
positive NaN, so test for both; Android randomly differs between the
two. Apple platforms and MinGW32 don't print signed NaNs, but it doesn't
make sense to have yet another branch for those so they're handled here
as well. */
#else
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"
@ -829,23 +817,8 @@ void CompareImageTest::compareSpecialsMeanOnly() {
compare.printMessage(flags, d, "a", "b");
}
/* Apple platforms, Android and MinGW32 don't print signed NaNs. This is
*not* a libc++ thing, tho -- libc++ on Linux prints signed NaNs. It used
to be with Emscripten too, but since 1.38.44 works the same as Linux. */
#if defined(CORRADE_TARGET_APPLE) || defined(CORRADE_TARGET_ANDROID) || defined(__MINGW32__)
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"
" [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");
/* clang-cl prints -nan(ind) instead of ±nan, but differently than MSVC */
#elif defined(CORRADE_TARGET_CLANG_CL)
#ifdef CORRADE_TARGET_CLANG_CL
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 within threshold 15. Delta image:\n"
" |MMMM M ,M|\n"
@ -898,8 +871,11 @@ void CompareImageTest::compareSpecialsMeanOnly() {
" [8,0] Vector(3), expected Vector(-0.1) (Δ = 3.1)\n");
#endif
/* Linux, Emscripten. Somehow, a Release build sometimes gives a positive
NaN, so test for both. */
/* Linux, Emscripten, Android. Somehow, a Release build sometimes gives a
positive NaN, so test for both; Android randomly differs between the
two. Apple platforms and MinGW32 don't print signed NaNs, but it doesn't
make sense to have yet another branch for those so they're handled here
as well. */
#else
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"

24
src/Magnum/Math/Test/Matrix3Test.cpp

@ -510,24 +510,30 @@ void Matrix3Test::rotationPartNotOrthogonal() {
Matrix3::shearingX(1.5f).rotation();
Matrix3::scaling(Vector2::yScale(0.0f)).rotation();
#if defined(CORRADE_TARGET_APPLE) || (defined(CORRADE_TARGET_WINDOWS) && defined(__MINGW32__)) || defined(CORRADE_TARGET_ANDROID)
#ifdef CORRADE_TARGET_MSVC
CORRADE_COMPARE(out.str(),
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0.83205,\n"
" 0, 0.5547)\n"
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, nan,\n"
" 0, nan)\n");
#elif defined(CORRADE_TARGET_WINDOWS) && defined(_MSC_VER)
CORRADE_COMPARE(out.str(),
"Matrix(1, -nan(ind),\n"
" 0, -nan(ind))\n");
/* Linux, Emscripten, Android. Somehow Androids randomly differ between
printing positive and negative NaNs. Apple platforms and MinGW32 don't
print signed NaNs, but it doesn't make sense to have yet another branch
for those so they're handled here as well. */
#else
constexpr const char* expectedPositive =
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0.83205,\n"
" 0, 0.5547)\n"
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, -nan(ind),\n"
" 0, -nan(ind))\n");
#else
CORRADE_COMPARE(out.str(),
"Matrix(1, nan,\n"
" 0, nan)\n";
if(out.str() == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive);
else CORRADE_COMPARE(out.str(),
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0.83205,\n"
" 0, 0.5547)\n"

28
src/Magnum/Math/Test/Matrix4Test.cpp

@ -745,28 +745,34 @@ void Matrix4Test::rotationPartNotOrthogonal() {
Matrix4::shearingXY(1.5f, 0.0f).rotation();
Matrix4::scaling(Vector3::yScale(0.0f)).rotation();
#if defined(CORRADE_TARGET_APPLE) || (defined(CORRADE_TARGET_WINDOWS) && defined(__MINGW32__)) || defined(CORRADE_TARGET_ANDROID)
#ifdef CORRADE_TARGET_MSVC
CORRADE_COMPARE(out.str(),
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0, 0.83205,\n"
" 0, 1, 0,\n"
" 0, 0, 0.5547)\n"
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, nan, 0,\n"
" 0, nan, 0,\n"
" 0, nan, 1)\n");
#elif defined(CORRADE_TARGET_WINDOWS) && defined(_MSC_VER)
CORRADE_COMPARE(out.str(),
"Matrix(1, -nan(ind), 0,\n"
" 0, -nan(ind), 0,\n"
" 0, -nan(ind), 1)\n");
/* Linux, Emscripten, Android. Somehow Androids randomly differ between
printing positive and negative NaNs. Apple platforms and MinGW32 don't
print signed NaNs, but it doesn't make sense to have yet another branch
for those so they're handled here as well. */
#else
constexpr const char* expectedPositive =
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0, 0.83205,\n"
" 0, 1, 0,\n"
" 0, 0, 0.5547)\n"
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, -nan(ind), 0,\n"
" 0, -nan(ind), 0,\n"
" 0, -nan(ind), 1)\n");
#else
CORRADE_COMPARE(out.str(),
"Matrix(1, nan, 0,\n"
" 0, nan, 0,\n"
" 0, nan, 1)\n";
if(out.str() == expectedPositive)
CORRADE_COMPARE(out.str(), expectedPositive);
else CORRADE_COMPARE(out.str(),
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:\n"
"Matrix(1, 0, 0.83205,\n"
" 0, 1, 0,\n"

Loading…
Cancel
Save