From 85526f893719c3267cbfe653cf0095fc1288f49d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 5 Nov 2012 21:36:43 +0100 Subject: [PATCH 1/1] Add a variant of expect_equal() for uint8s. --- test_util.cpp | 15 +++++++++++++++ test_util.h | 1 + 2 files changed, 16 insertions(+) diff --git a/test_util.cpp b/test_util.cpp index 3aecd54..cc02801 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -181,3 +181,18 @@ void expect_equal(const float *ref, const float *result, unsigned width, unsigne } } } + +void expect_equal(const unsigned char *ref, const unsigned char *result, unsigned width, unsigned height, unsigned largest_difference_limit, float rms_limit) +{ + float *ref_float = new float[width * height]; + float *result_float = new float[width * height]; + + for (unsigned y = 0; y < height; ++y) { + for (unsigned x = 0; x < width; ++x) { + ref_float[y * width + x] = ref[y * width + x]; + result_float[y * width + x] = result[y * width + x]; + } + } + + expect_equal(ref_float, result_float, width, height, largest_difference_limit, rms_limit); +} diff --git a/test_util.h b/test_util.h index 412acad..67e975d 100644 --- a/test_util.h +++ b/test_util.h @@ -27,5 +27,6 @@ private: }; void expect_equal(const float *ref, const float *result, unsigned width, unsigned height, float largest_difference_limit = 1.5 / 255.0, float rms_limit = 0.2 / 255.0); +void expect_equal(const unsigned char *ref, const unsigned char *result, unsigned width, unsigned height, unsigned largest_difference_limit = 1, float rms_limit = 0.2); #endif // !defined(_TEST_UTIL_H) -- 2.39.2