improve portability of unit test code for windows compilers

This commit is contained in:
Axel Kohlmeyer
2021-11-03 10:54:21 -04:00
parent 50f39cd752
commit 1ad982aa85
2 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,11 @@
#include "fmtlib_format.cpp" #include "fmtlib_format.cpp"
#include "fmtlib_os.cpp" #include "fmtlib_os.cpp"
// Windows may define this as a macro
#if defined(max)
#undef max
#endif
TEST(ErrorStats, test) TEST(ErrorStats, test)
{ {
ErrorStats stats; ErrorStats stats;

View File

@ -48,7 +48,7 @@ inline static bool SimilarVec(Vector a, Vector b, int n, Scalar eps = 1.0e-06,
Scalar ratio = 1.0e-06, Scalar ratio_denom = 1.0) Scalar ratio = 1.0e-06, Scalar ratio_denom = 1.0)
{ {
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
if (not Similar(a[i], b[i], eps, ratio, ratio_denom)) return false; if (! Similar(a[i], b[i], eps, ratio, ratio_denom)) return false;
return true; return true;
} }
@ -61,7 +61,7 @@ inline static bool SimilarVecUnsigned(Vector a, Vector b, int n, Scalar eps = 1.
return true; return true;
else { else {
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
if (not Similar(a[i], -b[i], eps, ratio, ratio_denom)) return false; if (! Similar(a[i], -b[i], eps, ratio, ratio_denom)) return false;
return true; return true;
} }
} }