summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/testing.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/testing.h')
-rw-r--r--third_party/jpeg-xl/lib/jxl/testing.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/testing.h b/third_party/jpeg-xl/lib/jxl/testing.h
index 5344399c4c..1fac352a78 100644
--- a/third_party/jpeg-xl/lib/jxl/testing.h
+++ b/third_party/jpeg-xl/lib/jxl/testing.h
@@ -6,15 +6,7 @@
#ifndef LIB_JXL_TESTING_H_
#define LIB_JXL_TESTING_H_
-// GTest/GMock specific macros / wrappers.
-
-// gmock unconditionally redefines those macros (to wrong values).
-// Lets include it only here and mitigate the problem.
-#pragma push_macro("PRIdS")
-#pragma push_macro("PRIuS")
-#include "gmock/gmock.h"
-#pragma pop_macro("PRIuS")
-#pragma pop_macro("PRIdS")
+// GTest specific macros / wrappers.
#include "gtest/gtest.h"
// JPEGXL_ENABLE_BOXES, JPEGXL_ENABLE_TRANSCODE_JPEG
@@ -60,9 +52,26 @@
// Ensures that we don't make our test bounds too lax, effectively disabling the
// tests.
-MATCHER_P(IsSlightlyBelow, max, "") {
- return max * 0.75 <= arg && arg <= max * 1.0;
-}
+#define EXPECT_SLIGHTLY_BELOW(A, E) \
+ { \
+ double _actual = (A); \
+ double _expected = (E); \
+ EXPECT_LE(_actual, _expected); \
+ EXPECT_GE(_actual, 0.75 * _expected); \
+ }
+
+#define EXPECT_ARRAY_NEAR(A, E, T) \
+ { \
+ const auto _actual = (A); \
+ const auto _expected = (E); \
+ const auto _tolerance = (T); \
+ size_t _n = _expected.size(); \
+ ASSERT_EQ(_actual.size(), _n); \
+ for (size_t _i = 0; _i < _n; ++_i) { \
+ EXPECT_NEAR(_actual[_i], _expected[_i], _tolerance) \
+ << "@" << _i << ": " << _actual[_i] << " !~= " << _expected[_i]; \
+ } \
+ }
#define JXL_EXPECT_OK(F) \
{ \