summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/testing.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/jpeg-xl/lib/jxl/testing.h
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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) \
{ \