|
32 | 32 | import static org.junit.Assert.assertArrayEquals; |
33 | 33 | import static org.junit.Assert.assertEquals; |
34 | 34 | import static org.junit.Assert.assertFalse; |
| 35 | +import static org.junit.Assert.assertNull; |
35 | 36 | import static org.junit.Assert.assertTrue; |
36 | 37 | import static org.junit.Assert.fail; |
37 | 38 |
|
@@ -116,20 +117,20 @@ public void testConstructors() { |
116 | 117 |
|
117 | 118 | @Test |
118 | 119 | public void testConstructor_LowerCase() { |
119 | | - final Base16 Base16 = new Base16(true); |
120 | | - final byte[] encoded = Base16.encode(BaseNTestData.DECODED); |
| 120 | + final Base16 base16 = new Base16(true); |
| 121 | + final byte[] encoded = base16.encode(BaseNTestData.DECODED); |
121 | 122 | final String expectedResult = Base16TestData.ENCODED_UTF8_LOWERCASE; |
122 | 123 | final String result = StringUtils.newStringUtf8(encoded); |
123 | 124 | assertEquals("new Base16(true)", expectedResult, result); |
124 | 125 | } |
125 | 126 |
|
126 | 127 | @Test |
127 | 128 | public void testConstructor_LowerCase_DecodingPolicy() { |
128 | | - final Base16 Base16 = new Base16(false, CodecPolicy.STRICT); |
129 | | - final byte[] encoded = Base16.encode(BaseNTestData.DECODED); |
| 129 | + final Base16 base16 = new Base16(false, CodecPolicy.STRICT); |
| 130 | + final byte[] encoded = base16.encode(BaseNTestData.DECODED); |
130 | 131 | final String expectedResult = Base16TestData.ENCODED_UTF8_UPPERCASE; |
131 | 132 | final String result = StringUtils.newStringUtf8(encoded); |
132 | | - assertEquals("new Base16(false, CodecPolicy.STRICT)", result, expectedResult); |
| 133 | + assertEquals("new base16(false, CodecPolicy.STRICT)", result, expectedResult); |
133 | 134 | } |
134 | 135 |
|
135 | 136 | /** |
@@ -435,27 +436,27 @@ public void testTriplets() { |
435 | 436 |
|
436 | 437 | @Test |
437 | 438 | public void testByteToStringVariations() throws DecoderException { |
438 | | - final Base16 Base16 = new Base16(); |
| 439 | + final Base16 base16 = new Base16(); |
439 | 440 | final byte[] b1 = StringUtils.getBytesUtf8("Hello World"); |
440 | 441 | final byte[] b2 = new byte[0]; |
441 | 442 | final byte[] b3 = null; |
442 | 443 |
|
443 | | - assertEquals("byteToString Hello World", "48656C6C6F20576F726C64", Base16.encodeToString(b1)); |
| 444 | + assertEquals("byteToString Hello World", "48656C6C6F20576F726C64", base16.encodeToString(b1)); |
444 | 445 | assertEquals("byteToString static Hello World", "48656C6C6F20576F726C64", StringUtils.newStringUtf8(new Base16().encode(b1))); |
445 | | - assertEquals("byteToString \"\"", "", Base16.encodeToString(b2)); |
| 446 | + assertEquals("byteToString \"\"", "", base16.encodeToString(b2)); |
446 | 447 | assertEquals("byteToString static \"\"", "", StringUtils.newStringUtf8(new Base16().encode(b2))); |
447 | | - assertEquals("byteToString null", null, Base16.encodeToString(b3)); |
| 448 | + assertEquals("byteToString null", null, base16.encodeToString(b3)); |
448 | 449 | assertEquals("byteToString static null", null, StringUtils.newStringUtf8(new Base16().encode(b3))); |
449 | 450 | } |
450 | 451 |
|
451 | 452 | @Test |
452 | 453 | public void testStringToByteVariations() throws DecoderException { |
453 | | - final Base16 Base16 = new Base16(); |
| 454 | + final Base16 base16 = new Base16(); |
454 | 455 | final String s1 = "48656C6C6F20576F726C64"; |
455 | 456 | final String s2 = ""; |
456 | 457 | final String s3 = null; |
457 | 458 |
|
458 | | - assertEquals("StringToByte Hello World", "Hello World", StringUtils.newStringUtf8(Base16.decode(s1))); |
| 459 | + assertEquals("StringToByte Hello World", "Hello World", StringUtils.newStringUtf8(base16.decode(s1))); |
459 | 460 | assertEquals("StringToByte Hello World", "Hello World", |
460 | 461 | StringUtils.newStringUtf8((byte[]) new Base16().decode((Object) s1))); |
461 | 462 | assertEquals("StringToByte static Hello World", "Hello World", |
@@ -587,22 +588,23 @@ public void testDecodeSingleBytes() { |
587 | 588 | @Test |
588 | 589 | public void testDecodeSingleBytesOptimisation() { |
589 | 590 | final BaseNCodec.Context context = new BaseNCodec.Context(); |
590 | | - context.ibitWorkArea = 0; |
| 591 | + assertEquals(0, context.ibitWorkArea); |
| 592 | + assertNull(context.buffer); |
591 | 593 |
|
592 | 594 | final byte[] data = new byte[1]; |
593 | 595 |
|
594 | 596 | final Base16 b16 = new Base16(); |
595 | | - assertEquals(0, context.ibitWorkArea); |
596 | 597 |
|
597 | 598 | data[0] = (byte) 'E'; |
598 | 599 | b16.decode(data, 0, 1, context); |
599 | 600 | assertEquals(15, context.ibitWorkArea); |
| 601 | + assertNull(context.buffer); |
600 | 602 |
|
601 | 603 | data[0] = (byte) 'F'; |
602 | 604 | b16.decode(data, 0, 1, context); |
603 | 605 | assertEquals(0, context.ibitWorkArea); |
604 | 606 |
|
605 | | - assertEquals(-17, context.buffer[0]); |
| 607 | + assertEquals((byte)0xEF, context.buffer[0]); |
606 | 608 | } |
607 | 609 |
|
608 | 610 | @Test(expected=IllegalArgumentException.class) |
|
0 commit comments