From a3617dd7a7bdd5229d78874142cd6928bad6fa1c Mon Sep 17 00:00:00 2001 From: Sean Dawson Date: Thu, 27 Jun 2024 21:29:22 +1000 Subject: [PATCH] refactor(test): compare pixels to avoid difference in libpng versions/platforms --- sirc-tiledit/libs/shared/tests/integration.test.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sirc-tiledit/libs/shared/tests/integration.test.cpp b/sirc-tiledit/libs/shared/tests/integration.test.cpp index 05c9961..b563f2b 100644 --- a/sirc-tiledit/libs/shared/tests/integration.test.cpp +++ b/sirc-tiledit/libs/shared/tests/integration.test.cpp @@ -25,9 +25,20 @@ void runIntegrationTest(const std::filesystem::path &inputPath, const auto quantizer = MedianCutQuantizer(); const auto quantizedImage = quantizer.quantize(sircImage, bpp); const auto outputImage = RgbaAdapter::sircImageToRgba(quantizedImage); + + // Save the data to a PNG for visual comparison when debugging ImageLoader::saveImageToPng(fullOutputPath.c_str(), outputImage); - REQUIRE(compare_files(fullReferencePath.string(), fullOutputPath.string())); + const auto referencePixelData = + ImageLoader::loadImageFromPng(fullReferencePath.c_str()); + + bool allPixelsMatch = true; + for (size_t y = 0; y < HEIGHT_PIXELS; y++) { + for (size_t x = 0; x < WIDTH_PIXELS; x++) { + allPixelsMatch &= (referencePixelData[x][y] == outputImage[x][y]); + } + } + REQUIRE(allPixelsMatch); } TEST_CASE("Quantizes a real test image correctly (pixel_art_background/2bpp)",