Skip to content

Commit

Permalink
Rename compareImages to areImagesEqual
Browse files Browse the repository at this point in the history
compareImages is ambiguous. Does it return true when images equal?
The name areImagesEqual clearly conveys the intended return values,
one doesn't need to look into its code to understand what's expected.
Thus, the return values in the method are reversed, and the condition
of the test is negated.
  • Loading branch information
aivanov-jdk committed Jan 8, 2024
1 parent 8e85480 commit 1788ef6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/jdk/java/awt/color/NonICCFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static ColorSpace createCS(ColorSpaceSelector selector) {
};
}

private static boolean compareImages(BufferedImage destTest, BufferedImage destGold) {
private static boolean areImagesEqual(BufferedImage destTest, BufferedImage destGold) {
for (int x = 0; x < destTest.getWidth(); x++) {
for (int y = 0; y < destTest.getHeight(); y++) {
int rgb1 = destTest.getRGB(x, y);
Expand All @@ -113,11 +113,11 @@ private static boolean compareImages(BufferedImage destTest, BufferedImage destG
System.err.println("x = " + x + ", y = " + y);
System.err.println("rgb1 = " + Integer.toHexString(rgb1));
System.err.println("rgb2 = " + Integer.toHexString(rgb2));
return true;
return false;
}
}
}
return false;
return true;
}

public static void main(String[] args) {
Expand All @@ -134,7 +134,7 @@ public static void main(String[] args) {
ColorConvertOp gold = new ColorConvertOp(mid, null);
gold.filter(srcGold, destGold);

if (compareImages(destTest, destGold)) {
if (!areImagesEqual(destTest, destGold)) {
throw new RuntimeException("Test failed");
}
}
Expand Down

0 comments on commit 1788ef6

Please sign in to comment.