Skip to content

Commit

Permalink
Use compact array initialization
Browse files Browse the repository at this point in the history
Simplify boolean expressions
  • Loading branch information
garydgregory committed Jul 23, 2023
1 parent b3293e6 commit 034a27e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void testAYT() throws Exception {
assertNotNull(tr);
final boolean res1 = ANSI.client.sendAYT(Duration.ofSeconds(2));

if (res1 == true) {
if (res1) {
ayt_true_ok = true;
}

Expand All @@ -245,7 +245,7 @@ public void testAYT() throws Exception {

final boolean res2 = ANSI.client.sendAYT(Duration.ofSeconds(2));

if (res2 == false) {
if (!res2) {
ayt_false_ok = true;
}

Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/apache/commons/net/util/Base64Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testBase64IntByteArrayBoolean() {

@Test
public void testDecodeBase64ByteArray() {
final byte[] base64Data = new byte[] {'b', 'G', 'l', 'n', 'a', 'H', 'Q', 'g', 'd', 'w', '=', '='};
final byte[] base64Data = {'b', 'G', 'l', 'n', 'a', 'H', 'Q', 'g', 'd', 'w', '=', '='};
final byte[] decoded = Base64.decodeBase64(base64Data);
assertEquals("light w", new String(decoded, StandardCharsets.UTF_8));
}
Expand All @@ -89,14 +89,14 @@ public void testDecodeBase64String() {

@Test
public void testDecodeByteArray() {
final byte[] base64Data = new byte[] {'Z', 'm', '9', 'v', 'Y', 'm', 'F', 'y'};
final byte[] base64Data = {'Z', 'm', '9', 'v', 'Y', 'm', 'F', 'y'};
final byte[] decoded = new Base64().decode(base64Data);
assertEquals("foobar", new String(decoded, StandardCharsets.UTF_8));
}

@Test
public void testDecodeByteArrayEmpty() {
final byte[] base64Data = new byte[] {};
final byte[] base64Data = {};
final byte[] decoded = new Base64().decode(base64Data);
assertArrayEquals(base64Data, decoded);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ public void testEncodeBase64ByteArrayBooleanBooleanInt() {

@Test
public void testEncodeBase64Chunked() {
final byte[] bytesToEncode = new byte[] {'f', 'o', 'o', 'b', 'a', 'r'};
final byte[] bytesToEncode = {'f', 'o', 'o', 'b', 'a', 'r'};
final byte[] encodedData = Base64.encodeBase64Chunked(bytesToEncode);
assertEquals("Zm9vYmFy\r\n", new String(encodedData, StandardCharsets.UTF_8));
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public void testEncodeObject() {
@Test
public void testEncodeToString() {
final Base64 base64 = new Base64();
final byte[] bytesToEncode = new byte[] {'l', 'i', 'g', 'h', 't', ' ', 'w', 'o', 'r'};
final byte[] bytesToEncode = {'l', 'i', 'g', 'h', 't', ' ', 'w', 'o', 'r'};
assertEquals("bGlnaHQgd29y\r\n", base64.encodeToString(bytesToEncode));
}

Expand Down

0 comments on commit 034a27e

Please sign in to comment.