|
From: <pe...@us...> - 2004-02-19 15:39:45
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16429/src/test/org/neuclear/commons/crypto Modified Files: Base32Tests.java Log Message: Various cleanups and corrections Index: Base32Tests.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/Base32Tests.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Base32Tests.java 18 Feb 2004 00:13:42 -0000 1.5 --- Base32Tests.java 19 Feb 2004 15:29:13 -0000 1.6 *************** *** 23,26 **** --- 23,29 ---- $Id$ $Log$ + Revision 1.6 2004/02/19 15:29:13 pelle + Various cleanups and corrections + Revision 1.5 2004/02/18 00:13:42 pelle Many, many clean ups. I've readded Targets in a new method. *************** *** 49,53 **** * Time: 9:52:41 PM */ ! public class Base32Tests extends TestCase{ public Base32Tests(String string) { super(string); --- 52,56 ---- * Time: 9:52:41 PM */ ! public class Base32Tests extends TestCase { public Base32Tests(String string) { super(string); *************** *** 55,79 **** public void testLength() throws CryptoException { ! assertEquals(32,Base32.encode(CryptoTools.digest("hello")).length()); ! assertEquals(8,Base32.encode("hello").length()); ! assertEquals(10,Base32.encode("hello1").length()); ! assertEquals(12,Base32.encode("hello12").length()); ! assertEquals(13,Base32.encode("hello123").length()); ! assertEquals(15,Base32.encode("hello1234").length()); ! assertEquals(16,Base32.encode("hello12345").length()); ! assertEquals(18,Base32.encode("hello123456").length()); } public void testBase32Codec() throws CryptoException { ! for (int i=0;i<TESTSTRINGS.length;i++){ // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); final String encoded = Base32.encode(TESTSTRINGS[i]); ! System.out.println(" ->"+encoded); ! assertEquals("TESTSTRINGS["+i+"]",TESTSTRINGS[i].getBytes(),Base32.decode(encoded)); } } ! public void testSHABase32() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); --- 58,83 ---- public void testLength() throws CryptoException { ! assertEquals(32, Base32.encode(CryptoTools.digest("hello")).length()); ! assertEquals(8, Base32.encode("hello").length()); ! assertEquals(10, Base32.encode("hello1").length()); ! assertEquals(12, Base32.encode("hello12").length()); ! assertEquals(13, Base32.encode("hello123").length()); ! assertEquals(15, Base32.encode("hello1234").length()); ! assertEquals(16, Base32.encode("hello12345").length()); ! assertEquals(18, Base32.encode("hello123456").length()); } + public void testBase32Codec() throws CryptoException { ! for (int i = 0; i < TESTSTRINGS.length; i++) { // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); final String encoded = Base32.encode(TESTSTRINGS[i]); ! System.out.println(" ->" + encoded); ! assertEquals("TESTSTRINGS[" + i + "]", TESTSTRINGS[i].getBytes(), Base32.decode(encoded)); } } ! /* public void testSHABase32() throws CryptoException { for (int i=0;i<TESTSTRINGS.length;i++){ // System.out.print("Encoding: "+TESTSTRINGS[i]+" ..."); *************** *** 114,138 **** } } ! public void assertEquals(String description,byte a[],byte b[]) { ! assertEquals(description+" length",a.length,b.length); ! for (int i=0;i<a.length;i++) ! assertEquals(description+"["+i+"]",a[i],b[i]); } ! static final String TESTSTRINGS[] =new String[]{ ! "", ! "0", ! "01", ! "012", ! "0123", ! "01234", ! "012345", ! "0123456", ! "01234567", ! "012345678", ! "0123456789", ! "0123456789A", ! "0123456789A0123456789As0123456789A", ! new String(CryptoTools.digest("0123456")) }; --- 118,144 ---- } } ! */ ! public void assertEquals(String description, byte a[], byte b[]) { ! assertEquals(description + " length", a.length, b.length); ! for (int i = 0; i < a.length; i++) ! assertEquals(description + "[" + i + "]", a[i], b[i]); } ! ! static final String TESTSTRINGS[] = new String[]{ ! "", ! "0", ! "01", ! "012", ! "0123", ! "01234", ! "012345", ! "0123456", ! "01234567", ! "012345678", ! "0123456789", ! "0123456789A", ! "0123456789A0123456789As0123456789A", ! new String(CryptoTools.digest("0123456")) }; |