Skip to content

Commit

Permalink
refactor(test): compare pixels to avoid difference in libpng versions…
Browse files Browse the repository at this point in the history
…/platforms
  • Loading branch information
NoxHarmonium committed Jun 27, 2024
1 parent c8d4f95 commit a3617dd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sirc-tiledit/libs/shared/tests/integration.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down

0 comments on commit a3617dd

Please sign in to comment.