[New] added tests for the dmedia base32 encoding
Since Jason DeRose now put up some test vectors for the dmedia base32 encoding, i thought it wise to add these in a test
This commit is contained in:
parent
5ddb277773
commit
706d2413ac
|
@ -23,8 +23,10 @@ package ch.eitchnet.utils.helper;
|
|||
|
||||
import static ch.eitchnet.utils.helper.BaseDecoding.fromBase16;
|
||||
import static ch.eitchnet.utils.helper.BaseDecoding.fromBase32;
|
||||
import static ch.eitchnet.utils.helper.BaseDecoding.fromBase32Dmedia;
|
||||
import static ch.eitchnet.utils.helper.BaseDecoding.fromBase32Hex;
|
||||
import static ch.eitchnet.utils.helper.BaseDecoding.fromBase64;
|
||||
import static ch.eitchnet.utils.helper.BaseEncoding.toBase32Hex;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -104,6 +106,27 @@ public class BaseDecodingTest {
|
|||
logger.info("Decoding 200MB Base32Hex took " + StringHelper.formatNanoDuration(end - start));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBase32Dmedia() {
|
||||
|
||||
Assert.assertEquals("", new String(fromBase32Dmedia("".getBytes())));
|
||||
Assert.assertEquals("binary foo", new String(fromBase32Dmedia("FCNPVRELI7J9FUUI".getBytes())));
|
||||
Assert.assertEquals("f", new String(fromBase32Dmedia("FR======".getBytes())));
|
||||
Assert.assertEquals("fo", new String(fromBase32Dmedia("FSQJ====".getBytes())));
|
||||
Assert.assertEquals("foo", new String(fromBase32Dmedia("FSQPX===".getBytes())));
|
||||
Assert.assertEquals("foob", new String(fromBase32Dmedia("FSQPXRJ=".getBytes())));
|
||||
Assert.assertEquals("fooba", new String(fromBase32Dmedia("FSQPXRM4".getBytes())));
|
||||
Assert.assertEquals("foobar", new String(fromBase32Dmedia("FSQPXRM4HB======".getBytes())));
|
||||
|
||||
long start = System.nanoTime();
|
||||
byte[] bytes = new byte[1024 * 1024];
|
||||
for (int i = 0; i < 200; i++) {
|
||||
toBase32Hex(bytes);
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
logger.info("Encoding 200MB Base32Dmedia took " + StringHelper.formatNanoDuration(end - start));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBase16() {
|
||||
Assert.assertEquals("", new String(fromBase16("".getBytes())));
|
||||
|
|
|
@ -24,6 +24,7 @@ package ch.eitchnet.utils.helper;
|
|||
import static ch.eitchnet.utils.helper.BaseEncoding.toBase16;
|
||||
import static ch.eitchnet.utils.helper.BaseEncoding.toBase32;
|
||||
import static ch.eitchnet.utils.helper.BaseEncoding.toBase32Hex;
|
||||
import static ch.eitchnet.utils.helper.BaseEncoding.toBase32Dmedia;
|
||||
import static ch.eitchnet.utils.helper.BaseEncoding.toBase64;
|
||||
import junit.framework.Assert;
|
||||
|
||||
|
@ -95,6 +96,27 @@ public class BaseEncodingTest {
|
|||
long end = System.nanoTime();
|
||||
logger.info("Encoding 200MB Base32Hex took " + StringHelper.formatNanoDuration(end - start));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBase32Dmedia() {
|
||||
|
||||
Assert.assertEquals("", new String(toBase32Dmedia("".getBytes())));
|
||||
Assert.assertEquals("FCNPVRELI7J9FUUI", new String(toBase32Dmedia("binary foo".getBytes())));
|
||||
Assert.assertEquals("FR======", new String(toBase32Dmedia("f".getBytes())));
|
||||
Assert.assertEquals("FSQJ====", new String(toBase32Dmedia("fo".getBytes())));
|
||||
Assert.assertEquals("FSQPX===", new String(toBase32Dmedia("foo".getBytes())));
|
||||
Assert.assertEquals("FSQPXRJ=", new String(toBase32Dmedia("foob".getBytes())));
|
||||
Assert.assertEquals("FSQPXRM4", new String(toBase32Dmedia("fooba".getBytes())));
|
||||
Assert.assertEquals("FSQPXRM4HB======", new String(toBase32Dmedia("foobar".getBytes())));
|
||||
|
||||
long start = System.nanoTime();
|
||||
byte[] bytes = new byte[1024 * 1024];
|
||||
for (int i = 0; i < 200; i++) {
|
||||
toBase32Hex(bytes);
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
logger.info("Encoding 200MB Base32Dmedia took " + StringHelper.formatNanoDuration(end - start));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBase16() {
|
||||
|
|
Loading…
Reference in New Issue