Skip to content

Commit

Permalink
Update expects in antialiased tests
Browse files Browse the repository at this point in the history
Previously, when `outputDiffMask` was `false`, `diffOutput` was assign
the same value as `img1`. This wasn't deep copy, so both variables were
pointing to the same image data. This was usually OK, because we don't
look back at pixels that were already compared. The exception is the
case of `antialiasing = true`. In this case we do look back at
previously compared pixels and since they were modified, this changed
the result of comparison.

This was fixed in previous commit so that `diffOutput` is always a copy
of input image. This is why the expects were changed as well.
  • Loading branch information
serpent7776 committed Oct 14, 2024
1 parent 385e6c5 commit 1234cd7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/Test_Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ let test_antialiasing () =
let diffPixels, diffPercentage, _ =
PNG_Diff.compare img1 img2 ~antialiasing:true ()
in
check int "diffPixels" 46 diffPixels;
check (float 0.001) "diffPercentage" 0.115 diffPercentage
check int "diffPixels" 38 diffPixels;
check (float 0.001) "diffPercentage" 0.095 diffPercentage

let test_different_sized_aa_images () =
let img1 = Png.IO.loadImage "test-images/aa/antialiasing-on.png" in
let img2 = Png.IO.loadImage "test-images/aa/antialiasing-off-small.png" in
let diffPixels, diffPercentage, _ =
PNG_Diff.compare img1 img2 ~antialiasing:true ()
in
check int "diffPixels" 417 diffPixels;
check (float 0.01) "diffPercentage" 1.0425 diffPercentage
check int "diffPixels" 0 diffPixels;
check (float 0.01) "diffPercentage" 0.0 diffPercentage

let test_threshold () =
let img1 = Png.IO.loadImage "test-images/png/orange.png" in
Expand Down

0 comments on commit 1234cd7

Please sign in to comment.