This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
The following commit(s) were added to refs/heads/master by this push: new 190b1bd4 Formatting "()->x" -> "() -> x" 190b1bd4 is described below commit 190b1bd47c36c562dea916aa99e597a41a1124a7 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri May 12 16:16:33 2023 -0400 Formatting "()->x" -> "() -> x" - Remove unused local var - Longer lines --- .../formats/tiff/TiffRasterDataIntTest.java | 12 ++++----- .../imaging/formats/tiff/TiffRasterDataTest.java | 21 ++++++++-------- .../formats/tiff/TiffRoundTripInt32Test.java | 29 +++++++++------------- .../formats/tiff/TiffShortIntRoundTripTest.java | 29 +++++++++------------- 4 files changed, 40 insertions(+), 51 deletions(-) diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataIntTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataIntTest.java index 1861abad..3a38285b 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataIntTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataIntTest.java @@ -56,13 +56,13 @@ public class TiffRasterDataIntTest { @Test public void testBadConstructor() { - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataInt(-1, 10), "Constructor did not detect bad width"); - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataInt(10, -1), "Constructor did not detect bad height"); - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataInt(1, 1, 0), "Constructor did not detect bad samplesPerPixel"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataInt(-1, 10), "Constructor did not detect bad width"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataInt(10, -1), "Constructor did not detect bad height"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataInt(1, 1, 0), "Constructor did not detect bad samplesPerPixel"); - final int []s = new int[10]; - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataInt(2, 10, s), "Constructor did not detect insufficient input array size"); - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataInt(2, 3, 2, s), "Constructor did not detect insufficient input array size"); + final int[] s = new int[10]; + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataInt(2, 10, s), "Constructor did not detect insufficient input array size"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataInt(2, 3, 2, s), "Constructor did not detect insufficient input array size"); } /** diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java index a5533fd7..7b729fd6 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java @@ -54,13 +54,13 @@ public class TiffRasterDataTest { */ @Test public void testBadConstructor() { - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataFloat(-1, 10), "Constructor did not detect bad width"); - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataFloat(10, -1), "Constructor did not detect bad height"); - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataFloat(1, 1, 0), "Constructor did not detect bad samplesPerPixel"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataFloat(-1, 10), "Constructor did not detect bad width"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataFloat(10, -1), "Constructor did not detect bad height"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataFloat(1, 1, 0), "Constructor did not detect bad samplesPerPixel"); - final float []f = new float[10]; - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataFloat(2, 10, f), "Constructor did not detect insufficient input array size"); - assertThrows(IllegalArgumentException.class, ()-> new TiffRasterDataFloat(2, 3, 2, f), "Constructor did not detect insufficient input array size"); + final float[] f = new float[10]; + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataFloat(2, 10, f), "Constructor did not detect insufficient input array size"); + assertThrows(IllegalArgumentException.class, () -> new TiffRasterDataFloat(2, 3, 2, f), "Constructor did not detect insufficient input array size"); } /** @@ -68,11 +68,11 @@ public class TiffRasterDataTest { */ @Test public void testBadCoordinates() { - final float []f = new float[100]; + final float[] f = new float[100]; final TiffRasterData instance = new TiffRasterDataFloat(10, 10, 1, f); - assertThrows(IllegalArgumentException.class, ()->instance.getValue(11, 11), "Access method getValue() did not detect bad coordinates"); - assertThrows(IllegalArgumentException.class, ()->instance.setValue(11, 11, 5.0f), "Access method setValue() did not detect bad coordinates"); - assertThrows(IllegalArgumentException.class, ()->instance.getValue(1, 1, 2), "Access method setValue() did not detect bad sample index"); + assertThrows(IllegalArgumentException.class, () -> instance.getValue(11, 11), "Access method getValue() did not detect bad coordinates"); + assertThrows(IllegalArgumentException.class, () -> instance.setValue(11, 11, 5.0f), "Access method setValue() did not detect bad coordinates"); + assertThrows(IllegalArgumentException.class, () -> instance.getValue(1, 1, 2), "Access method setValue() did not detect bad sample index"); } /** @@ -108,7 +108,6 @@ public class TiffRasterDataTest { */ @Test public void testGetIntData() { - final int[] result = raster.getIntData(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { final int index = y * width + x; diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java index 8a206942..f6fe5982 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java @@ -132,34 +132,29 @@ public class TiffRoundTripInt32Test extends TiffBaseTest { final String name = testFile[i].getName(); final ByteSourceFile byteSource = new ByteSourceFile(testFile[i]); final TiffReader tiffReader = new TiffReader(true); - final TiffContents contents = tiffReader.readDirectories( - byteSource, - true, // indicates that application should read image data, if present - FormatCompliance.getDefault()); + final TiffContents contents = tiffReader.readDirectories(byteSource, true, // indicates that application should read image data, if present + FormatCompliance.getDefault()); final TiffDirectory directory = contents.directories.get(0); final TiffRasterData rdInt = directory.getRasterData(null); - final int []test = rdInt.getIntData(); - for(int j=0; j<sample.length; j++){ - assertEquals(sample[j], test[j], - "Extracted data does not match original, test "+name+": " - + i + ", index " + j); + final int[] test = rdInt.getIntData(); + for (int j = 0; j < sample.length; j++) { + assertEquals(sample[j], test[j], "Extracted data does not match original, test " + name + ": " + i + ", index " + j); } final TiffImagingParameters params = new TiffImagingParameters(); - params.setSubImage(2, 2, width-4, height-4); + params.setSubImage(2, 2, width - 4, height - 4); final TiffRasterData rdSub = directory.getRasterData(params); - assertEquals(width-4, rdSub.getWidth(), "Invalid sub-image width"); - assertEquals(height-4, rdSub.getHeight(), "Invalid sub-image height"); - for(int x = 2; x<width-2; x++){ - for(int y=2; y<height-2; y++){ + assertEquals(width - 4, rdSub.getWidth(), "Invalid sub-image width"); + assertEquals(height - 4, rdSub.getHeight(), "Invalid sub-image height"); + for (int x = 2; x < width - 2; x++) { + for (int y = 2; y < height - 2; y++) { final int a = rdInt.getIntValue(x, y); - final int b = rdSub.getIntValue(x-2, y-2); + final int b = rdSub.getIntValue(x - 2, y - 2); assertEquals(a, b, "Sub Image test failed at (" + x + "," + y + ")"); } } final TiffImagingParameters xparams = new TiffImagingParameters(); xparams.setSubImage(2, 2, width, height); - assertThrows(ImageReadException.class, ()->directory.getRasterData(xparams), - "Failed to catch bad subimage for test "+name); + assertThrows(ImageReadException.class, () -> directory.getRasterData(xparams), "Failed to catch bad subimage for test " + name); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java index c4a9acf8..701df08c 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java @@ -128,34 +128,29 @@ public class TiffShortIntRoundTripTest extends TiffBaseTest { final String name = testFile[i].getName(); final ByteSourceFile byteSource = new ByteSourceFile(testFile[i]); final TiffReader tiffReader = new TiffReader(true); - final TiffContents contents = tiffReader.readDirectories( - byteSource, - true, // indicates that application should read image data, if present - FormatCompliance.getDefault()); + final TiffContents contents = tiffReader.readDirectories(byteSource, true, // indicates that application should read image data, if present + FormatCompliance.getDefault()); final TiffDirectory directory = contents.directories.get(0); final TiffRasterData rdInt = directory.getRasterData(null); - final int []test = rdInt.getIntData(); - for(int j=0; j<sample.length; j++){ - assertEquals(sample[j], test[j], - "Extracted data does not match original, test "+name+": " - + i + ", index " + j); + final int[] test = rdInt.getIntData(); + for (int j = 0; j < sample.length; j++) { + assertEquals(sample[j], test[j], "Extracted data does not match original, test " + name + ": " + i + ", index " + j); } final TiffImagingParameters params = new TiffImagingParameters(); - params.setSubImage(2, 2, width-4, height-4); + params.setSubImage(2, 2, width - 4, height - 4); final TiffRasterData rdSub = directory.getRasterData(params); - assertEquals(width-4, rdSub.getWidth(), "Invalid sub-image width"); - assertEquals(height-4, rdSub.getHeight(), "Invalid sub-image height"); - for(int x = 2; x<width-2; x++){ - for(int y=2; y<height-2; y++){ + assertEquals(width - 4, rdSub.getWidth(), "Invalid sub-image width"); + assertEquals(height - 4, rdSub.getHeight(), "Invalid sub-image height"); + for (int x = 2; x < width - 2; x++) { + for (int y = 2; y < height - 2; y++) { final int a = rdInt.getIntValue(x, y); - final int b = rdSub.getIntValue(x-2, y-2); + final int b = rdSub.getIntValue(x - 2, y - 2); assertEquals(a, b, "Sub Image test failed at (" + x + "," + y + ")"); } } final TiffImagingParameters xparams = new TiffImagingParameters(); xparams.setSubImage(2, 2, width, height); - assertThrows(ImageReadException.class, ()->directory.getRasterData(xparams), - "Failed to catch bad subimage for test "+name); + assertThrows(ImageReadException.class, () -> directory.getRasterData(xparams), "Failed to catch bad subimage for test " + name); } }