Skip to content

Commit 3bae4fa

Browse files
committed
Fix ParenPad
1 parent b4f1c80 commit 3bae4fa

File tree

4 files changed

+124
-125
lines changed

4 files changed

+124
-125
lines changed

src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public static IOFileFilter sizeFileFilter(final long threshold, final boolean ac
669669
* @see SizeFileFilter
670670
* @since 1.3
671671
*/
672-
public static IOFileFilter sizeRangeFileFilter(final long minSizeInclusive, final long maxSizeInclusive ) {
672+
public static IOFileFilter sizeRangeFileFilter(final long minSizeInclusive, final long maxSizeInclusive) {
673673
final IOFileFilter minimumFilter = new SizeFileFilter(minSizeInclusive, true);
674674
final IOFileFilter maximumFilter = new SizeFileFilter(maxSizeInclusive + 1L, false);
675675
return minimumFilter.and(maximumFilter);

src/test/java/org/apache/commons/io/EndianUtilsTest.java

Lines changed: 118 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/**
3030
* Tests {@link EndianUtils}.
3131
*/
32-
public class EndianUtilsTest {
32+
public class EndianUtilsTest {
3333

3434
@Test
3535
public void testCtor() {
@@ -60,147 +60,146 @@ public void testInvalidOffset() throws IOException {
6060
@Test
6161
public void testReadSwappedDouble() throws IOException {
6262
final byte[] bytes = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
63-
final double d1 = Double.longBitsToDouble( 0x0102030405060708L );
64-
final double d2 = EndianUtils.readSwappedDouble( bytes, 0 );
65-
assertEquals( d1, d2, 0.0 );
63+
final double d1 = Double.longBitsToDouble(0x0102030405060708L);
64+
final double d2 = EndianUtils.readSwappedDouble(bytes, 0);
65+
assertEquals(d1, d2, 0.0);
6666

6767
final ByteArrayInputStream input = new ByteArrayInputStream(bytes);
68-
assertEquals( d1, EndianUtils.readSwappedDouble( input ), 0.0 );
68+
assertEquals(d1, EndianUtils.readSwappedDouble(input), 0.0);
6969
}
7070

7171
@Test
7272
public void testReadSwappedFloat() throws IOException {
7373
final byte[] bytes = { 0x04, 0x03, 0x02, 0x01 };
74-
final float f1 = Float.intBitsToFloat( 0x01020304 );
75-
final float f2 = EndianUtils.readSwappedFloat( bytes, 0 );
76-
assertEquals( f1, f2, 0.0 );
74+
final float f1 = Float.intBitsToFloat(0x01020304);
75+
final float f2 = EndianUtils.readSwappedFloat(bytes, 0);
76+
assertEquals(f1, f2, 0.0);
7777

7878
final ByteArrayInputStream input = new ByteArrayInputStream(bytes);
79-
assertEquals( f1, EndianUtils.readSwappedFloat( input ), 0.0 );
79+
assertEquals(f1, EndianUtils.readSwappedFloat(input), 0.0);
8080
}
8181

8282
@Test
8383
public void testReadSwappedInteger() throws IOException {
8484
final byte[] bytes = { 0x04, 0x03, 0x02, 0x01 };
85-
assertEquals( 0x01020304, EndianUtils.readSwappedInteger( bytes, 0 ) );
85+
assertEquals(0x01020304, EndianUtils.readSwappedInteger(bytes, 0));
8686

8787
final ByteArrayInputStream input = new ByteArrayInputStream(bytes);
88-
assertEquals( 0x01020304, EndianUtils.readSwappedInteger( input ) );
88+
assertEquals(0x01020304, EndianUtils.readSwappedInteger(input));
8989
}
9090

9191
@Test
9292
public void testReadSwappedLong() throws IOException {
9393
final byte[] bytes = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
94-
assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( bytes, 0 ) );
94+
assertEquals(0x0102030405060708L, EndianUtils.readSwappedLong(bytes, 0));
9595

9696
final ByteArrayInputStream input = new ByteArrayInputStream(bytes);
97-
assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( input ) );
97+
assertEquals(0x0102030405060708L, EndianUtils.readSwappedLong(input));
9898
}
9999

100100
@Test
101101
public void testReadSwappedShort() throws IOException {
102102
final byte[] bytes = { 0x02, 0x01 };
103-
assertEquals( 0x0102, EndianUtils.readSwappedShort( bytes, 0 ) );
103+
assertEquals(0x0102, EndianUtils.readSwappedShort(bytes, 0));
104104

105105
final ByteArrayInputStream input = new ByteArrayInputStream(bytes);
106-
assertEquals( 0x0102, EndianUtils.readSwappedShort( input ) );
106+
assertEquals(0x0102, EndianUtils.readSwappedShort(input));
107107
}
108108

109109
@Test
110110
public void testReadSwappedUnsignedInteger() throws IOException {
111111
final byte[] bytes = { 0x04, 0x03, 0x02, 0x01 };
112-
assertEquals( 0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger( bytes, 0 ) );
112+
assertEquals(0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger(bytes, 0));
113113

114114
final ByteArrayInputStream input = new ByteArrayInputStream(bytes);
115-
assertEquals( 0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger( input ) );
115+
assertEquals(0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger(input));
116116
}
117117

118118
@Test
119119
public void testReadSwappedUnsignedShort() throws IOException {
120120
final byte[] bytes = { 0x02, 0x01 };
121-
assertEquals( 0x00000102, EndianUtils.readSwappedUnsignedShort( bytes, 0 ) );
121+
assertEquals(0x00000102, EndianUtils.readSwappedUnsignedShort(bytes, 0));
122122

123123
final ByteArrayInputStream input = new ByteArrayInputStream(bytes);
124-
assertEquals( 0x00000102, EndianUtils.readSwappedUnsignedShort( input ) );
124+
assertEquals(0x00000102, EndianUtils.readSwappedUnsignedShort(input));
125125
}
126126

127127
@Test
128128
public void testSwapDouble() {
129-
assertEquals( 0.0, EndianUtils.swapDouble( 0.0 ), 0.0 );
130-
final double d1 = Double.longBitsToDouble( 0x0102030405060708L );
131-
final double d2 = Double.longBitsToDouble( 0x0807060504030201L );
132-
assertEquals( d2, EndianUtils.swapDouble( d1 ), 0.0 );
129+
assertEquals(0.0, EndianUtils.swapDouble(0.0), 0.0);
130+
final double d1 = Double.longBitsToDouble(0x0102030405060708L);
131+
final double d2 = Double.longBitsToDouble(0x0807060504030201L);
132+
assertEquals(d2, EndianUtils.swapDouble(d1), 0.0);
133133
}
134134

135135
@Test
136136
public void testSwapFloat() {
137-
assertEquals( 0.0f, EndianUtils.swapFloat( 0.0f ), 0.0 );
138-
final float f1 = Float.intBitsToFloat( 0x01020304 );
139-
final float f2 = Float.intBitsToFloat( 0x04030201 );
140-
assertEquals( f2, EndianUtils.swapFloat( f1 ), 0.0 );
137+
assertEquals(0.0f, EndianUtils.swapFloat(0.0f), 0.0);
138+
final float f1 = Float.intBitsToFloat(0x01020304);
139+
final float f2 = Float.intBitsToFloat(0x04030201);
140+
assertEquals(f2, EndianUtils.swapFloat(f1), 0.0);
141141
}
142142

143143
@Test
144144
public void testSwapInteger() {
145-
assertEquals( 0, EndianUtils.swapInteger( 0 ) );
146-
assertEquals( 0x04030201, EndianUtils.swapInteger( 0x01020304 ) );
147-
assertEquals( 0x01000000, EndianUtils.swapInteger( 0x00000001 ) );
148-
assertEquals( 0x00000001, EndianUtils.swapInteger( 0x01000000 ) );
149-
assertEquals( 0x11111111, EndianUtils.swapInteger( 0x11111111 ) );
150-
assertEquals( 0xabcdef10, EndianUtils.swapInteger( 0x10efcdab ) );
151-
assertEquals( 0xab, EndianUtils.swapInteger( 0xab000000 ) );
145+
assertEquals(0, EndianUtils.swapInteger(0));
146+
assertEquals(0x04030201, EndianUtils.swapInteger(0x01020304));
147+
assertEquals(0x01000000, EndianUtils.swapInteger(0x00000001));
148+
assertEquals(0x00000001, EndianUtils.swapInteger(0x01000000));
149+
assertEquals(0x11111111, EndianUtils.swapInteger(0x11111111));
150+
assertEquals(0xabcdef10, EndianUtils.swapInteger(0x10efcdab));
151+
assertEquals(0xab, EndianUtils.swapInteger(0xab000000));
152152
}
153153

154154
@Test
155155
public void testSwapLong() {
156-
assertEquals( 0, EndianUtils.swapLong( 0 ) );
157-
assertEquals( 0x0807060504030201L, EndianUtils.swapLong( 0x0102030405060708L ) );
158-
assertEquals( 0xffffffffffffffffL, EndianUtils.swapLong( 0xffffffffffffffffL ) );
159-
assertEquals( 0xab, EndianUtils.swapLong( 0xab00000000000000L ) );
156+
assertEquals(0, EndianUtils.swapLong(0));
157+
assertEquals(0x0807060504030201L, EndianUtils.swapLong(0x0102030405060708L));
158+
assertEquals(0xffffffffffffffffL, EndianUtils.swapLong(0xffffffffffffffffL));
159+
assertEquals(0xab, EndianUtils.swapLong(0xab00000000000000L));
160160
}
161161

162162
@Test
163163
public void testSwapShort() {
164-
assertEquals( (short) 0, EndianUtils.swapShort( (short) 0 ) );
165-
assertEquals( (short) 0x0201, EndianUtils.swapShort( (short) 0x0102 ) );
166-
assertEquals( (short) 0xffff, EndianUtils.swapShort( (short) 0xffff ) );
167-
assertEquals( (short) 0x0102, EndianUtils.swapShort( (short) 0x0201 ) );
164+
assertEquals((short) 0, EndianUtils.swapShort((short) 0));
165+
assertEquals((short) 0x0201, EndianUtils.swapShort((short) 0x0102));
166+
assertEquals((short) 0xffff, EndianUtils.swapShort((short) 0xffff));
167+
assertEquals((short) 0x0102, EndianUtils.swapShort((short) 0x0201));
168168
}
169169

170170
/**
171-
* Tests all swapXxxx methods for symmetry when going from one endian
172-
* to another and back again.
171+
* Tests all swapXxxx methods for symmetry when going from one endian to another and back again.
173172
*/
174173
@Test
175174
public void testSymmetry() {
176-
assertEquals( (short) 0x0102, EndianUtils.swapShort( EndianUtils.swapShort( (short) 0x0102 ) ) );
177-
assertEquals( 0x01020304, EndianUtils.swapInteger( EndianUtils.swapInteger( 0x01020304 ) ) );
178-
assertEquals( 0x0102030405060708L, EndianUtils.swapLong( EndianUtils.swapLong( 0x0102030405060708L ) ) );
179-
final float f1 = Float.intBitsToFloat( 0x01020304 );
180-
assertEquals( f1, EndianUtils.swapFloat( EndianUtils.swapFloat( f1 ) ), 0.0 );
181-
final double d1 = Double.longBitsToDouble( 0x0102030405060708L );
182-
assertEquals( d1, EndianUtils.swapDouble( EndianUtils.swapDouble( d1 ) ), 0.0 );
175+
assertEquals((short) 0x0102, EndianUtils.swapShort(EndianUtils.swapShort((short) 0x0102)));
176+
assertEquals(0x01020304, EndianUtils.swapInteger(EndianUtils.swapInteger(0x01020304)));
177+
assertEquals(0x0102030405060708L, EndianUtils.swapLong(EndianUtils.swapLong(0x0102030405060708L)));
178+
final float f1 = Float.intBitsToFloat(0x01020304);
179+
assertEquals(f1, EndianUtils.swapFloat(EndianUtils.swapFloat(f1)), 0.0);
180+
final double d1 = Double.longBitsToDouble(0x0102030405060708L);
181+
assertEquals(d1, EndianUtils.swapDouble(EndianUtils.swapDouble(d1)), 0.0);
183182
}
184183

185184
// tests #IO-101
186185
@Test
187186
public void testSymmetryOfLong() {
188187

189-
final double[] tests = {34.345, -345.5645, 545.12, 10.043, 7.123456789123};
188+
final double[] tests = { 34.345, -345.5645, 545.12, 10.043, 7.123456789123 };
190189
for (final double test : tests) {
191190

192191
// testing the real problem
193192
byte[] buffer = new byte[8];
194-
final long ln1 = Double.doubleToLongBits( test );
193+
final long ln1 = Double.doubleToLongBits(test);
195194
EndianUtils.writeSwappedLong(buffer, 0, ln1);
196195
final long ln2 = EndianUtils.readSwappedLong(buffer, 0);
197-
assertEquals( ln1, ln2 );
196+
assertEquals(ln1, ln2);
198197

199198
// testing the bug report
200199
buffer = new byte[8];
201200
EndianUtils.writeSwappedDouble(buffer, 0, test);
202201
final double val = EndianUtils.readSwappedDouble(buffer, 0);
203-
assertEquals( test, val, 0 );
202+
assertEquals(test, val, 0);
204203
}
205204
}
206205

@@ -221,105 +220,105 @@ public void testUnsignedOverrun() throws Exception {
221220
@Test
222221
public void testWriteSwappedDouble() throws IOException {
223222
byte[] bytes = new byte[8];
224-
final double d1 = Double.longBitsToDouble( 0x0102030405060708L );
225-
EndianUtils.writeSwappedDouble( bytes, 0, d1 );
226-
assertEquals( 0x08, bytes[0] );
227-
assertEquals( 0x07, bytes[1] );
228-
assertEquals( 0x06, bytes[2] );
229-
assertEquals( 0x05, bytes[3] );
230-
assertEquals( 0x04, bytes[4] );
231-
assertEquals( 0x03, bytes[5] );
232-
assertEquals( 0x02, bytes[6] );
233-
assertEquals( 0x01, bytes[7] );
223+
final double d1 = Double.longBitsToDouble(0x0102030405060708L);
224+
EndianUtils.writeSwappedDouble(bytes, 0, d1);
225+
assertEquals(0x08, bytes[0]);
226+
assertEquals(0x07, bytes[1]);
227+
assertEquals(0x06, bytes[2]);
228+
assertEquals(0x05, bytes[3]);
229+
assertEquals(0x04, bytes[4]);
230+
assertEquals(0x03, bytes[5]);
231+
assertEquals(0x02, bytes[6]);
232+
assertEquals(0x01, bytes[7]);
234233

235234
final ByteArrayOutputStream baos = new ByteArrayOutputStream(8);
236-
EndianUtils.writeSwappedDouble( baos, d1 );
235+
EndianUtils.writeSwappedDouble(baos, d1);
237236
bytes = baos.toByteArray();
238-
assertEquals( 0x08, bytes[0] );
239-
assertEquals( 0x07, bytes[1] );
240-
assertEquals( 0x06, bytes[2] );
241-
assertEquals( 0x05, bytes[3] );
242-
assertEquals( 0x04, bytes[4] );
243-
assertEquals( 0x03, bytes[5] );
244-
assertEquals( 0x02, bytes[6] );
245-
assertEquals( 0x01, bytes[7] );
237+
assertEquals(0x08, bytes[0]);
238+
assertEquals(0x07, bytes[1]);
239+
assertEquals(0x06, bytes[2]);
240+
assertEquals(0x05, bytes[3]);
241+
assertEquals(0x04, bytes[4]);
242+
assertEquals(0x03, bytes[5]);
243+
assertEquals(0x02, bytes[6]);
244+
assertEquals(0x01, bytes[7]);
246245
}
247246

248247
@Test
249248
public void testWriteSwappedFloat() throws IOException {
250249
byte[] bytes = new byte[4];
251-
final float f1 = Float.intBitsToFloat( 0x01020304 );
252-
EndianUtils.writeSwappedFloat( bytes, 0, f1 );
253-
assertEquals( 0x04, bytes[0] );
254-
assertEquals( 0x03, bytes[1] );
255-
assertEquals( 0x02, bytes[2] );
256-
assertEquals( 0x01, bytes[3] );
250+
final float f1 = Float.intBitsToFloat(0x01020304);
251+
EndianUtils.writeSwappedFloat(bytes, 0, f1);
252+
assertEquals(0x04, bytes[0]);
253+
assertEquals(0x03, bytes[1]);
254+
assertEquals(0x02, bytes[2]);
255+
assertEquals(0x01, bytes[3]);
257256

258257
final ByteArrayOutputStream baos = new ByteArrayOutputStream(4);
259-
EndianUtils.writeSwappedFloat( baos, f1 );
258+
EndianUtils.writeSwappedFloat(baos, f1);
260259
bytes = baos.toByteArray();
261-
assertEquals( 0x04, bytes[0] );
262-
assertEquals( 0x03, bytes[1] );
263-
assertEquals( 0x02, bytes[2] );
264-
assertEquals( 0x01, bytes[3] );
260+
assertEquals(0x04, bytes[0]);
261+
assertEquals(0x03, bytes[1]);
262+
assertEquals(0x02, bytes[2]);
263+
assertEquals(0x01, bytes[3]);
265264
}
266265

267266
@Test
268267
public void testWriteSwappedInteger() throws IOException {
269268
byte[] bytes = new byte[4];
270-
EndianUtils.writeSwappedInteger( bytes, 0, 0x01020304 );
271-
assertEquals( 0x04, bytes[0] );
272-
assertEquals( 0x03, bytes[1] );
273-
assertEquals( 0x02, bytes[2] );
274-
assertEquals( 0x01, bytes[3] );
269+
EndianUtils.writeSwappedInteger(bytes, 0, 0x01020304);
270+
assertEquals(0x04, bytes[0]);
271+
assertEquals(0x03, bytes[1]);
272+
assertEquals(0x02, bytes[2]);
273+
assertEquals(0x01, bytes[3]);
275274

276275
final ByteArrayOutputStream baos = new ByteArrayOutputStream(4);
277-
EndianUtils.writeSwappedInteger( baos, 0x01020304 );
276+
EndianUtils.writeSwappedInteger(baos, 0x01020304);
278277
bytes = baos.toByteArray();
279-
assertEquals( 0x04, bytes[0] );
280-
assertEquals( 0x03, bytes[1] );
281-
assertEquals( 0x02, bytes[2] );
282-
assertEquals( 0x01, bytes[3] );
278+
assertEquals(0x04, bytes[0]);
279+
assertEquals(0x03, bytes[1]);
280+
assertEquals(0x02, bytes[2]);
281+
assertEquals(0x01, bytes[3]);
283282
}
284283

285284
@Test
286285
public void testWriteSwappedLong() throws IOException {
287286
byte[] bytes = new byte[8];
288-
EndianUtils.writeSwappedLong( bytes, 0, 0x0102030405060708L );
289-
assertEquals( 0x08, bytes[0] );
290-
assertEquals( 0x07, bytes[1] );
291-
assertEquals( 0x06, bytes[2] );
292-
assertEquals( 0x05, bytes[3] );
293-
assertEquals( 0x04, bytes[4] );
294-
assertEquals( 0x03, bytes[5] );
295-
assertEquals( 0x02, bytes[6] );
296-
assertEquals( 0x01, bytes[7] );
287+
EndianUtils.writeSwappedLong(bytes, 0, 0x0102030405060708L);
288+
assertEquals(0x08, bytes[0]);
289+
assertEquals(0x07, bytes[1]);
290+
assertEquals(0x06, bytes[2]);
291+
assertEquals(0x05, bytes[3]);
292+
assertEquals(0x04, bytes[4]);
293+
assertEquals(0x03, bytes[5]);
294+
assertEquals(0x02, bytes[6]);
295+
assertEquals(0x01, bytes[7]);
297296

298297
final ByteArrayOutputStream baos = new ByteArrayOutputStream(8);
299-
EndianUtils.writeSwappedLong( baos, 0x0102030405060708L );
298+
EndianUtils.writeSwappedLong(baos, 0x0102030405060708L);
300299
bytes = baos.toByteArray();
301-
assertEquals( 0x08, bytes[0] );
302-
assertEquals( 0x07, bytes[1] );
303-
assertEquals( 0x06, bytes[2] );
304-
assertEquals( 0x05, bytes[3] );
305-
assertEquals( 0x04, bytes[4] );
306-
assertEquals( 0x03, bytes[5] );
307-
assertEquals( 0x02, bytes[6] );
308-
assertEquals( 0x01, bytes[7] );
300+
assertEquals(0x08, bytes[0]);
301+
assertEquals(0x07, bytes[1]);
302+
assertEquals(0x06, bytes[2]);
303+
assertEquals(0x05, bytes[3]);
304+
assertEquals(0x04, bytes[4]);
305+
assertEquals(0x03, bytes[5]);
306+
assertEquals(0x02, bytes[6]);
307+
assertEquals(0x01, bytes[7]);
309308
}
310309

311310
@Test
312311
public void testWriteSwappedShort() throws IOException {
313312
byte[] bytes = new byte[2];
314-
EndianUtils.writeSwappedShort( bytes, 0, (short) 0x0102 );
315-
assertEquals( 0x02, bytes[0] );
316-
assertEquals( 0x01, bytes[1] );
313+
EndianUtils.writeSwappedShort(bytes, 0, (short) 0x0102);
314+
assertEquals(0x02, bytes[0]);
315+
assertEquals(0x01, bytes[1]);
317316

318317
final ByteArrayOutputStream baos = new ByteArrayOutputStream(2);
319-
EndianUtils.writeSwappedShort( baos, (short) 0x0102 );
318+
EndianUtils.writeSwappedShort(baos, (short) 0x0102);
320319
bytes = baos.toByteArray();
321-
assertEquals( 0x02, bytes[0] );
322-
assertEquals( 0x01, bytes[1] );
320+
assertEquals(0x02, bytes[0]);
321+
assertEquals(0x01, bytes[1]);
323322
}
324323

325324
}

0 commit comments

Comments
 (0)