Further unit tests: Util and Delta.
[cfb.git] / test / net / jaekl / cfb / util / UtilTest.java
index f9a609a6c5860a0d3ddb883571367fedbbf24c67..0f2e299f538706cea05276c64d26ea5a30660162 100644 (file)
@@ -2,6 +2,7 @@ package net.jaekl.cfb.util;
 
 import static org.junit.Assert.*;
 
+import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.List;
 
@@ -16,6 +17,10 @@ public class UtilTest {
                                        null,
                                        null
                                },
+                               {
+                                       {},
+                                       {},
+                               },
                                {
                                        { "one", "two", "three" },
                                        { "one", "two", "three" }
@@ -34,6 +39,10 @@ public class UtilTest {
                                        null,
                                        { "one", "two", "three" }
                                },
+                               {
+                                       { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) },
+                                       null
+                               },
                                {
                                        { "1", "1", "2" },
                                        { "1", "2", "1" }
@@ -49,6 +58,18 @@ public class UtilTest {
                                {
                                        { "1", "2", "3" },
                                        { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) }
+                               },
+                               { 
+                                       {},
+                                       { "1", "2", "3"}
+                               },
+                               {
+                                       { "1", "2", "3"},
+                                       {}
+                               },
+                               {
+                                       { "alpha", "beta" },
+                                       { "a", "b" }
                                }
                };
 
@@ -66,4 +87,38 @@ public class UtilTest {
                        assertFalse(result);
                }
        }
+       
+       @Test
+       public void testObjHashCode()
+       {
+               Object[] data = {
+                               Integer.valueOf(12),
+                               "arma virumque cano, Troiae qui primus ab oris",
+                               new String[] { null, null, null },
+                               new Util()
+               };
+               
+               int code = 0;
+               
+               code = Util.objHashCode(null);
+               assertEquals(1, code);
+               
+               for (Object datum : data) {
+                       code = Util.objHashCode(datum);
+                       assertEquals(datum.hashCode(), code);
+               }
+       }
+       
+       @Test
+       public void testStringify() 
+       {
+               final String msg = "Foo bar baz bat bam";
+               SQLException exc = new SQLException(msg);
+               String actual = Util.stringify(exc);
+               
+               assertNotNull(actual);
+               assertTrue(actual.contains(msg));
+               assertTrue(actual.contains("SQLException"));
+               assertTrue(actual.contains("testStringify"));
+       }
 }