diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/jpeg-xl/lib/jxl/testing.h | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/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.h | 33 |
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) \ { \ |