Test all constructors
diff --git a/src/test/java/org/apache/commons/codec/binary/Base32Test.java b/src/test/java/org/apache/commons/codec/binary/Base32Test.java
index 41ee709..9e25bd5 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base32Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base32Test.java
@@ -240,6 +240,46 @@
assertNotNull(codec);
}
+ @Test
+ public void testConstructors() {
+ Base32 base32;
+ base32 = new Base32();
+ base32 = new Base32(-1);
+ base32 = new Base32(-1, new byte[] {});
+ base32 = new Base32(32, new byte[] {});
+ base32 = new Base32(32, new byte[] {}, false);
+ // This is different behaviour than Base64 which validates the separator
+ // even when line length is negative.
+ base32 = new Base32(-1, new byte[] { 'A' });
+ try {
+ base32 = new Base32(32, null);
+ fail("Should have rejected null line separator");
+ } catch (final IllegalArgumentException ignored) {
+ // Expected
+ }
+ try {
+ base32 = new Base32(32, new byte[] { 'A' });
+ fail("Should have rejected attempt to use 'A' as a line separator");
+ } catch (final IllegalArgumentException ignored) {
+ // Expected
+ }
+ try {
+ base32 = new Base32(32, new byte[] { '=' });
+ fail("Should have rejected attempt to use '=' as a line separator");
+ } catch (final IllegalArgumentException ignored) {
+ // Expected
+ }
+ base32 = new Base32(32, new byte[] { '$' }); // OK
+ try {
+ base32 = new Base32(32, new byte[] { 'A', '$' });
+ fail("Should have rejected attempt to use 'A$' as a line separator");
+ } catch (final IllegalArgumentException ignored) {
+ // Expected
+ }
+ base32 = new Base32(32, new byte[] { ' ', '$', '\n', '\r', '\t' }); // OK
+ assertNotNull(base32);
+ }
+
/**
* Test encode and decode of empty byte array.
*/