From ec3d4bd1f176970bf8628d1cc83d88c292651f14 Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 5 Jul 2021 22:24:44 -0700 Subject: [PATCH] Automatic code cleanup. PiperOrigin-RevId: 383207440 --- .../android/ziputils/FakeFileSystem.java | 56 +++++++++---------- .../build/android/ziputils/ScanUtilTest.java | 17 ++++-- .../build/android/ziputils/ViewTest.java | 16 +++--- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/test/java/com/google/devtools/build/android/ziputils/FakeFileSystem.java b/src/test/java/com/google/devtools/build/android/ziputils/FakeFileSystem.java index 0d87710847a68f..d7a6473124f808 100644 --- a/src/test/java/com/google/devtools/build/android/ziputils/FakeFileSystem.java +++ b/src/test/java/com/google/devtools/build/android/ziputils/FakeFileSystem.java @@ -114,6 +114,19 @@ public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public int read(ByteBuffer dst, long position) throws IOException { + if (position < 0 || position >= data.length) { + throw new IOException("out of bounds"); + } + int remaining = data.length - (int) position; + if (dst.remaining() < remaining) { + remaining = dst.remaining(); + } + dst.put(data, (int) position, remaining); + return remaining; + } + @Override public int write(ByteBuffer src) throws IOException { throw new UnsupportedOperationException("Not supported yet."); @@ -124,6 +137,11 @@ public long write(ByteBuffer[] srcs, int offset, int length) throws IOException throw new UnsupportedOperationException("Not supported yet."); } + @Override + public int write(ByteBuffer src, long position) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override public long position() throws IOException { return position; @@ -162,24 +180,6 @@ public long transferFrom(ReadableByteChannel src, long position, long count) throw new UnsupportedOperationException("Not supported yet."); } - @Override - public int read(ByteBuffer dst, long position) throws IOException { - if (position < 0 || position >= data.length) { - throw new IOException("out of bounds"); - } - int remaining = data.length - (int) position; - if (dst.remaining() < remaining) { - remaining = dst.remaining(); - } - dst.put(data, (int) position, remaining); - return remaining; - } - - @Override - public int write(ByteBuffer src, long position) throws IOException { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public MappedByteBuffer map(FileChannel.MapMode mode, long position, long size) throws IOException { @@ -227,6 +227,11 @@ public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public int read(ByteBuffer dst, long position) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override public int write(ByteBuffer src) throws IOException { byte[] bytes = new byte[src.remaining()]; @@ -241,6 +246,11 @@ public long write(ByteBuffer[] srcs, int offset, int length) throws IOException throw new UnsupportedOperationException("Not supported yet."); } + @Override + public int write(ByteBuffer src, long position) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override public long position() throws IOException { return position; @@ -278,16 +288,6 @@ public long transferFrom(ReadableByteChannel src, long position, long count) throw new UnsupportedOperationException("Not supported yet."); } - @Override - public int read(ByteBuffer dst, long position) throws IOException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int write(ByteBuffer src, long position) throws IOException { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public MappedByteBuffer map(FileChannel.MapMode mode, long position, long size) throws IOException { diff --git a/src/test/java/com/google/devtools/build/android/ziputils/ScanUtilTest.java b/src/test/java/com/google/devtools/build/android/ziputils/ScanUtilTest.java index 20906c5d3269f0..0b7411bf143f8e 100644 --- a/src/test/java/com/google/devtools/build/android/ziputils/ScanUtilTest.java +++ b/src/test/java/com/google/devtools/build/android/ziputils/ScanUtilTest.java @@ -80,7 +80,8 @@ public void testScanBackwardsTo() { private void assertLocation(byte[] target, byte[] domain, int expected) { int pos = ScanUtil.scanTo(target, domain != null ? ByteBuffer.wrap(domain) : null); assertWithMessage("Position of " + Arrays.toString(target) + " in " + Arrays.toString(domain)) - .that(expected).isEqualTo(pos); + .that(pos) + .isEqualTo(expected); } private void assertBackwardsLocation(byte[] target, byte[] domain, int expected) { @@ -90,8 +91,16 @@ private void assertBackwardsLocation(byte[] target, byte[] domain, int expected) buf.position(buf.limit()); } int pos = ScanUtil.scanBackwardsTo(target, buf); - assertWithMessage("Position of " + Arrays.toString(target) + " in " + Arrays.toString(domain) - + ", " + buf.position() + ", " + buf.limit()) - .that(expected).isEqualTo(pos); + assertWithMessage( + "Position of " + + Arrays.toString(target) + + " in " + + Arrays.toString(domain) + + ", " + + buf.position() + + ", " + + buf.limit()) + .that(pos) + .isEqualTo(expected); } } diff --git a/src/test/java/com/google/devtools/build/android/ziputils/ViewTest.java b/src/test/java/com/google/devtools/build/android/ziputils/ViewTest.java index 186c485586cf28..b1d10b8eb73fe1 100644 --- a/src/test/java/com/google/devtools/build/android/ziputils/ViewTest.java +++ b/src/test/java/com/google/devtools/build/android/ziputils/ViewTest.java @@ -143,22 +143,22 @@ static class TestView extends View { super(buffer); } - // Will advance buffer position + // Will advance buffer position. public void putInt(int value) { buffer.putInt(value); } - // Will advance buffer position - public int getInt() { - return buffer.getInt(); - } - - // will not advance buffer position + // Will not advance buffer position. public void putInt(int index, int value) { buffer.putInt(index, value); } - // will not advance buffer position + // Will advance buffer position. + public int getInt() { + return buffer.getInt(); + } + + // Will not advance buffer position. public int getInt(int index) { return buffer.getInt(index); }