Skip to content

Commit 5365879

Browse files
committed
Test the codec policy property
1 parent 4c542d7 commit 5365879

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/test/java/org/apache/commons/codec/binary/Base16Test.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ public void testStrictDecoding() {
587587
final String encoded = "aabbccdde"; // Note the trailing `e` which does not make up a hex-pair and so is only 1/2 byte
588588

589589
final Base16 b16 = new Base16(true, CodecPolicy.STRICT);
590+
assertEquals(CodecPolicy.STRICT, b16.getCodecPolicy());
590591
b16.decode(StringUtils.getBytesUtf8(encoded));
591592
}
592593

@@ -595,6 +596,7 @@ public void testLenientDecoding() {
595596
final String encoded = "aabbccdde"; // Note the trailing `e` which does not make up a hex-pair and so is only 1/2 byte
596597

597598
final Base16 b16 = new Base16(true, CodecPolicy.LENIENT);
599+
assertEquals(CodecPolicy.LENIENT, b16.getCodecPolicy());
598600

599601
final byte[] decoded = b16.decode(StringUtils.getBytesUtf8(encoded));
600602
assertArrayEquals(new byte[] {(byte)0xaa, (byte)0xbb, (byte)0xcc, (byte)0xdd}, decoded);

src/test/java/org/apache/commons/codec/binary/Base32Test.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,11 @@ private static void assertBase32DecodingOfTrailingBits(final int nbits) {
367367
// Requires strict decoding
368368
final Base32 codec = new Base32(0, null, false, BaseNCodec.PAD_DEFAULT, CodecPolicy.STRICT);
369369
assertTrue(codec.isStrictDecoding());
370+
assertEquals(CodecPolicy.STRICT, codec.getCodecPolicy());
370371
// A lenient decoder should not re-encode to the same bytes
371372
final Base32 defaultCodec = new Base32();
372373
assertFalse(defaultCodec.isStrictDecoding());
374+
assertEquals(CodecPolicy.LENIENT, defaultCodec.getCodecPolicy());
373375

374376
// Create the encoded bytes. The first characters must be valid so fill with 'zero'
375377
// then pad to the block size.

src/test/java/org/apache/commons/codec/binary/Base64Test.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,9 +1363,11 @@ private static void assertBase64DecodingOfTrailingBits(final int nbits) {
13631363
final Base64 codec = new Base64(0, null, false, CodecPolicy.STRICT);
13641364
// Requires strict decoding
13651365
assertTrue(codec.isStrictDecoding());
1366+
assertEquals(CodecPolicy.STRICT, codec.getCodecPolicy());
13661367
// A lenient decoder should not re-encode to the same bytes
13671368
final Base64 defaultCodec = new Base64();
13681369
assertFalse(defaultCodec.isStrictDecoding());
1370+
assertEquals(CodecPolicy.LENIENT, defaultCodec.getCodecPolicy());
13691371

13701372
// Create the encoded bytes. The first characters must be valid so fill with 'zero'
13711373
// then pad to the block size.

0 commit comments

Comments
 (0)