X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=test%2Fnet%2Fjaekl%2Fcfb%2Futil%2FUtilTest.java;h=0f2e299f538706cea05276c64d26ea5a30660162;hp=f9a609a6c5860a0d3ddb883571367fedbbf24c67;hb=e39cfda923b6edce0fb80211cc927a7534abba10;hpb=327080b11e9161f059432b680a97c9341deb4a5c diff --git a/test/net/jaekl/cfb/util/UtilTest.java b/test/net/jaekl/cfb/util/UtilTest.java index f9a609a..0f2e299 100644 --- a/test/net/jaekl/cfb/util/UtilTest.java +++ b/test/net/jaekl/cfb/util/UtilTest.java @@ -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")); + } }