mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 04:25:29 -04:00
TMI-43: Made tests a little more robust to void false positives.
This commit is contained in:
parent
aacad8a575
commit
c3c23d0523
@ -513,9 +513,7 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
// Validate strip colors
|
// Validate strip colors
|
||||||
for (int i = 0; i < strip.getWidth() / 128; i++) {
|
for (int i = 0; i < strip.getWidth() / 128; i++) {
|
||||||
int actualRGB = strip.getRGB(i * 128, 4);
|
int actualRGB = strip.getRGB(i * 128, 4);
|
||||||
assertEquals((actualRGB >> 16) & 0xff, (expectedRGB[i] >> 16) & 0xff, 5);
|
assertRGBEquals(expectedRGB[i], actualRGB);
|
||||||
assertEquals((actualRGB >> 8) & 0xff, (expectedRGB[i] >> 8) & 0xff, 5);
|
|
||||||
assertEquals((actualRGB) & 0xff, (expectedRGB[i]) & 0xff, 5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,9 +541,7 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
// Validate strip colors
|
// Validate strip colors
|
||||||
for (int i = 0; i < thumbnail.getWidth() / 8; i++) {
|
for (int i = 0; i < thumbnail.getWidth() / 8; i++) {
|
||||||
int actualRGB = thumbnail.getRGB(i * 8, 4);
|
int actualRGB = thumbnail.getRGB(i * 8, 4);
|
||||||
assertEquals((actualRGB >> 16) & 0xff, (expectedRGB[i] >> 16) & 0xff, 5);
|
assertRGBEquals(expectedRGB[i], actualRGB);
|
||||||
assertEquals((actualRGB >> 8) & 0xff, (expectedRGB[i] >> 8) & 0xff, 5);
|
|
||||||
assertEquals((actualRGB) & 0xff, (expectedRGB[i]) & 0xff, 5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,12 +676,19 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
// Validate strip colors
|
// Validate strip colors
|
||||||
for (int i = 0; i < image.getWidth() / 10; i++) {
|
for (int i = 0; i < image.getWidth() / 10; i++) {
|
||||||
int actualRGB = image.getRGB(i * 10, 7);
|
int actualRGB = image.getRGB(i * 10, 7);
|
||||||
assertEquals((actualRGB >> 16) & 0xff, (expectedRGB[i] >> 16) & 0xff, 5);
|
assertRGBEquals(expectedRGB[i], actualRGB);
|
||||||
assertEquals((actualRGB >> 8) & 0xff, (expectedRGB[i] >> 8) & 0xff, 5);
|
|
||||||
assertEquals((actualRGB ) & 0xff, (expectedRGB[i] ) & 0xff, 5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slightly fuzzy RGB equals method. Tolerance +/-5 steps.
|
||||||
|
*/
|
||||||
|
private void assertRGBEquals(int expectedRGB, int actualRGB) {
|
||||||
|
assertEquals((expectedRGB >> 16) & 0xff, (actualRGB >> 16) & 0xff, 5);
|
||||||
|
assertEquals((expectedRGB >> 8) & 0xff, (actualRGB >> 8) & 0xff, 5);
|
||||||
|
assertEquals((expectedRGB ) & 0xff, (actualRGB ) & 0xff, 5);
|
||||||
|
}
|
||||||
|
|
||||||
// Regression: Test subsampling offset within of bounds
|
// Regression: Test subsampling offset within of bounds
|
||||||
// NOTE: These tests assumes the reader will read at least 1024 scanlines (if available) each iteration,
|
// NOTE: These tests assumes the reader will read at least 1024 scanlines (if available) each iteration,
|
||||||
// this might change in the future. If so, the tests will no longer test what tey are supposed to....
|
// this might change in the future. If so, the tests will no longer test what tey are supposed to....
|
||||||
@ -716,8 +719,8 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
assertNotNull(image);
|
assertNotNull(image);
|
||||||
|
|
||||||
// Make sure correct color is actually read, not just left empty
|
// Make sure correct color is actually read, not just left empty
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2));
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -733,8 +736,8 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
assertNotNull(image);
|
assertNotNull(image);
|
||||||
|
|
||||||
// Make sure correct color is actually read, not just left empty
|
// Make sure correct color is actually read, not just left empty
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2));
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -750,8 +753,8 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
assertNotNull(image);
|
assertNotNull(image);
|
||||||
|
|
||||||
// Make sure correct color is actually read, not just left empty
|
// Make sure correct color is actually read, not just left empty
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2));
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -781,8 +784,8 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
assertNotNull(image);
|
assertNotNull(image);
|
||||||
|
|
||||||
// Make sure correct color is actually read, not just left empty
|
// Make sure correct color is actually read, not just left empty
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2));
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -798,8 +801,8 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
assertNotNull(image);
|
assertNotNull(image);
|
||||||
|
|
||||||
// Make sure correct color is actually read, not just left empty
|
// Make sure correct color is actually read, not just left empty
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 2));
|
||||||
assertEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1) & 0xffffff);
|
assertRGBEquals(0xfefefd, image.getRGB(0, image.getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user