Work toward improving solidity. Add a few more unit tests, and some toString()
[cfb.git] / test / net / jaekl / cfb / util / UtilTest.java
diff --git a/test/net/jaekl/cfb/util/UtilTest.java b/test/net/jaekl/cfb/util/UtilTest.java
new file mode 100644 (file)
index 0000000..beaa926
--- /dev/null
@@ -0,0 +1,69 @@
+package net.jaekl.cfb.util;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+public class UtilTest {
+       @Test
+       public void testListsAreEqual()
+       {
+               Object[][][] equal = {
+                               {
+                                       null,
+                                       null
+                               },
+                               {
+                                       { "one", "two", "three" },
+                                       { "one", "two", "three" }
+                               },
+                               {
+                                       { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) },
+                                       { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) }
+                               }
+               };
+               Object[][][] unequal = {
+                               {
+                                       null,
+                                       { "one", "two", "three" }
+                               },
+                               {
+                                       { "1", "1", "2" },
+                                       { "1", "2", "1" }
+                               },
+                               {
+                                       { "1", "1", "2" },
+                                       { "1", "2", "2" }
+                               },
+                               {
+                                       { "1", "1", "2" },
+                                       { "1", "2" }
+                               },
+                               {
+                                       { "1", "2", "3" },
+                                       { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) }
+                               },
+                               {
+                                       { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) },
+                                       { Integer.valueOf(1), Integer.valueOf(2048), Long.valueOf(3) }
+                               }
+               };
+
+               for (Object[][] lists : equal) {
+                       List<?> a = (null == lists[0]) ? null : Arrays.asList(lists[0]);
+                       List<?> b = (null == lists[1]) ? null : Arrays.asList(lists[1]);
+                       boolean result = Util.listsAreEqual(a, b);
+                       assertTrue(result);
+               }
+               
+               for (Object[][] lists : unequal) {
+                       List<?> a = (null == lists[0]) ? null : Arrays.asList(lists[0]);
+                       List<?> b = (null == lists[1]) ? null : Arrays.asList(lists[1]);
+                       boolean result = Util.listsAreEqual(a, b);
+                       assertFalse(result);
+               }
+       }
+}