Skip to content

Commit

Permalink
GH-4544 Openrewrite changes to the test classes. A few reverts regard…
Browse files Browse the repository at this point in the history
…ing pom changes.

Signed-off-by: Jerven Bolleman <[email protected]>
  • Loading branch information
JervenBolleman committed May 19, 2023
1 parent fca0822 commit a76d50d
Show file tree
Hide file tree
Showing 402 changed files with 3,611 additions and 3,303 deletions.
5 changes: 5 additions & 0 deletions core/common/io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@

import org.junit.jupiter.api.Test;

public class ByteArrayUtilTest {
class ByteArrayUtilTest {

@Test
public void testMatchesPattern() {
void testMatchesPattern() {
assertTrue(ByteArrayUtil.matchesPattern(new byte[] {}, new byte[] { 0, 32 }, new byte[] { 0, 16 }));
assertTrue(ByteArrayUtil.matchesPattern(new byte[] { 4 }, new byte[] { 0 }, new byte[] { 2 }));

assertFalse(ByteArrayUtil.matchesPattern(new byte[] { 2, 0 }, new byte[] { 2, 0 }, new byte[] { 0, 16 }));
}

@Test
public void testRegionMatches() {
void testRegionMatches() {
assertTrue(ByteArrayUtil.regionMatches(new byte[] {}, new byte[] { 1, 0 }, 0));
assertTrue(ByteArrayUtil.regionMatches(new byte[] { 2, 3, 4, 5 }, new byte[] { 1, 2, 3, 4, 5, 6 }, 1));

Expand All @@ -40,7 +40,7 @@ public void testRegionMatches() {
}

@Test
public void testCompareRegion() {
void testCompareRegion() {
assertEquals(0, ByteArrayUtil.compareRegion(new byte[] {}, 0, new byte[] {}, 0, 0));
assertEquals(0, ByteArrayUtil.compareRegion(new byte[] { 0, 2 }, 0, new byte[] { 0, 1 }, 0, 1));

Expand All @@ -49,7 +49,7 @@ public void testCompareRegion() {
}

@Test
public void testFind() {
void testFind() {
assertEquals(-1, ByteArrayUtil.find(new byte[] {}, 0, 1, (byte) 0));
assertEquals(-1, ByteArrayUtil.find(new byte[] { 0, 1, 2, 3, 4, 5, 6 }, 0, 20, (byte) 7));
assertEquals(-1, ByteArrayUtil.find(new byte[] { 0, 1, 2, 3, 4, 5, 6 }, -5, 20, (byte) 7));
Expand All @@ -59,7 +59,7 @@ public void testFind() {
}

@Test
public void testFindArray() {
void testFindArray() {
assertEquals(0, ByteArrayUtil.find(new byte[] {}, 0, 1, new byte[] {}));
assertEquals(2, ByteArrayUtil.find(new byte[] { 0, 1, 2, 3, 4, 5, 6 }, 0, 7, new byte[] { 2, 3 }));
assertEquals(2, ByteArrayUtil.find(new byte[] { 0, 1, 2, 3, 4, 5, 6 }, 0, 20, new byte[] { 2, 3 }));
Expand All @@ -69,7 +69,7 @@ public void testFindArray() {
}

@Test
public void testGetInt() {
void testGetInt() {
assertEquals(0, ByteArrayUtil.getInt(new byte[] { 0, 0, 0, 0, 0, 0 }, 0));
assertEquals((1 << 24) + (2 << 16) + (3 << 8) + 4, ByteArrayUtil.getInt(new byte[] { 1, 2, 3, 4 }, 0));
assertEquals((1 << 24) + (2 << 16) + (3 << 8) + 4, ByteArrayUtil.getInt(new byte[] { 10, 1, 2, 3, 4, 10 }, 1));
Expand All @@ -78,7 +78,7 @@ public void testGetInt() {
}

@Test
public void testGetLong() {
void testGetLong() {
assertEquals(0L, ByteArrayUtil.getLong(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0));
assertEquals(1L, ByteArrayUtil.getLong(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, 0));
assertEquals(1L << 56, ByteArrayUtil.getLong(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, 0));
Expand All @@ -88,15 +88,15 @@ public void testGetLong() {
}

@Test
public void testToBitSet() {
void testToBitSet() {
assertEquals(new BitSet(), ByteArrayUtil.toBitSet(new byte[] {}));

final BitSet bitSet = ByteArrayUtil.toBitSet(new byte[] { 1, 2, 3, 4 });
assertArrayEquals(new byte[] { -128, 64, -64, 32 }, bitSet.toByteArray());
}

@Test
public void testToByteArray() {
void testToByteArray() {
final BitSet bitSet = new BitSet();

assertArrayEquals(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, ByteArrayUtil.toByteArray(bitSet));
Expand All @@ -109,15 +109,15 @@ public void testToByteArray() {
}

@Test
public void testToHexString() {
void testToHexString() {
assertEquals("", ByteArrayUtil.toHexString(new byte[] {}));
assertEquals("1a", ByteArrayUtil.toHexString(new byte[] { 0x1A }));
assertEquals("1a2b3c", ByteArrayUtil.toHexString(new byte[] { 0x1A, 0x2B, 0x3C }));
assertEquals("010203", ByteArrayUtil.toHexString(new byte[] { 0x01, 0x02, 0x03 }));
}

@Test
public void testPutLong() {
void testPutLong() {
final byte[] byteArray = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

ByteArrayUtil.putLong(1L, byteArray, 0);
Expand All @@ -134,7 +134,7 @@ public void testPutLong() {
}

@Test
public void testPutInt() {
void testPutInt() {
final byte[] byteArray = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

ByteArrayUtil.putInt(1, byteArray, 0);
Expand All @@ -151,15 +151,15 @@ public void testPutInt() {
}

@Test
public void testGet() {
void testGet() {
assertArrayEquals(new byte[] {}, ByteArrayUtil.get(new byte[] {}, 0));
assertArrayEquals(new byte[] { 3, 4 }, ByteArrayUtil.get(new byte[] { 1, 2, 3, 4 }, 2));
assertArrayEquals(new byte[] { 3, 4, 5 }, ByteArrayUtil.get(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 2, 3));
assertArrayEquals(new byte[] {}, ByteArrayUtil.get(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 2, 0));
}

@Test
public void testPut() {
void testPut() {
final byte[] byteArray = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

ByteArrayUtil.put(new byte[] { 1, 2, 3, 4 }, byteArray, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ZipUtilTest {
public File dir;

@Test
public void testWriteEntryNormal() throws IOException {
void testWriteEntryNormal() throws IOException {
File f = new File(dir, "testok.zip");
f.createNewFile();

Expand All @@ -49,7 +49,7 @@ public void testWriteEntryNormal() throws IOException {
}

@Test
public void testWriteEntryPathTraversing() throws IOException {
void testWriteEntryPathTraversing() throws IOException {
File f = new File(dir, "testnotok.zip");
f.createNewFile();

Expand Down
Loading

0 comments on commit a76d50d

Please sign in to comment.