diff --git a/src/test/java/com/github/romankh3/image/comparison/ImageComparisonUnitTest.java b/src/test/java/com/github/romankh3/image/comparison/ImageComparisonUnitTest.java index 73b9c49..898481c 100644 --- a/src/test/java/com/github/romankh3/image/comparison/ImageComparisonUnitTest.java +++ b/src/test/java/com/github/romankh3/image/comparison/ImageComparisonUnitTest.java @@ -523,6 +523,44 @@ public void shouldProperlyCompareMisSizedImages() { assertTrue(differenceLessThan2); } + @DisplayName("Should properly compare in bug 211") + @Test + public void shouldProperlyCompareInBug211() { + //given + BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expected#211.png"); + BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actual#211.png"); + BufferedImage resultImage = readImageFromResources("result#211.png"); + + //when + ImageComparisonResult imageComparisonResult = + new ImageComparison(expectedImage, actualImage) + .setPixelToleranceLevel(0.0) + .compareImages(); + + //then + assertEquals(MISMATCH, imageComparisonResult.getImageComparisonState()); + assertImagesEqual(resultImage, imageComparisonResult.getResult()); + } + + @DisplayName("Should properly compare pure color in issue 211") + @Test + public void shouldProperlyComparePureColorIn211() { + //given + BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expectedColor#211.png"); + BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actualColor#211.png"); + BufferedImage resultImage = readImageFromResources("resultColor#211.png"); + + //when + ImageComparisonResult imageComparisonResult = + new ImageComparison(expectedImage, actualImage) + .setPixelToleranceLevel(0.079) + .compareImages(); + + //then + assertEquals(MISMATCH, imageComparisonResult.getImageComparisonState()); + assertImagesEqual(resultImage, imageComparisonResult.getResult()); + } + private void assertImagesEqual(BufferedImage expected, BufferedImage actual) { if (expected.getWidth() != actual.getWidth() || expected.getHeight() != actual.getHeight()) { fail("Images have different dimensions"); diff --git a/src/test/resources/actual#211.png b/src/test/resources/actual#211.png new file mode 100644 index 0000000..428697d Binary files /dev/null and b/src/test/resources/actual#211.png differ diff --git a/src/test/resources/actualColor#211.png b/src/test/resources/actualColor#211.png new file mode 100644 index 0000000..43615fa Binary files /dev/null and b/src/test/resources/actualColor#211.png differ diff --git a/src/test/resources/expected#211.png b/src/test/resources/expected#211.png new file mode 100644 index 0000000..645d305 Binary files /dev/null and b/src/test/resources/expected#211.png differ diff --git a/src/test/resources/expectedColor#211.png b/src/test/resources/expectedColor#211.png new file mode 100644 index 0000000..83070e8 Binary files /dev/null and b/src/test/resources/expectedColor#211.png differ diff --git a/src/test/resources/result#211.png b/src/test/resources/result#211.png new file mode 100644 index 0000000..65106e8 Binary files /dev/null and b/src/test/resources/result#211.png differ diff --git a/src/test/resources/resultColor#211.png b/src/test/resources/resultColor#211.png new file mode 100644 index 0000000..cbd608c Binary files /dev/null and b/src/test/resources/resultColor#211.png differ