summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-31 21:50:57 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-31 21:50:57 +0200
commitd7aba3d722fbc4dacc94207e97098fd8e27933b4 (patch)
tree046992b6324602ca346b8dd3c800f7486d8b5ad7
parent943503be50e7bab4be68b7a81a0ce296dfeb4c40 (diff)
downloadJRummikub-d7aba3d722fbc4dacc94207e97098fd8e27933b4.tar
JRummikub-d7aba3d722fbc4dacc94207e97098fd8e27933b4.zip
Added tests for Pair class
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@363 72836036-5685-4462-b002-a69064685172
-rw-r--r--test/jrummikub/util/PairTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/jrummikub/util/PairTest.java b/test/jrummikub/util/PairTest.java
new file mode 100644
index 0000000..dd34d42
--- /dev/null
+++ b/test/jrummikub/util/PairTest.java
@@ -0,0 +1,32 @@
+package jrummikub.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+/** */
+public class PairTest {
+ /** */
+ @Test
+ public void testPairToString() {
+ assertEquals("Pair [first=1, second=Foobar]", new Pair<Integer, String>(1, "Foobar").toString());
+ }
+
+ /** */
+ @Test
+ public void testEqualsAndHash() {
+ assertFalse(new Pair<Integer, String>(1, "Foobar").equals(null));
+ assertFalse(new Pair<Integer, String>(1, "Foobar").equals("Foobar"));
+ assertTrue(new Pair<Integer, String>(1, null).equals(new Pair<Integer, String>(1, null)));
+ Set<Pair<Integer, String>> set = new HashSet<Pair<Integer, String>>();
+ set.add(new Pair<Integer, String>(1, "Foobar"));
+ set.add(new Pair<Integer, String>(2, "Baz"));
+ assertTrue(set.contains(new Pair<Integer, String>(1, "Foobar")));
+ assertFalse(set.contains(new Pair<Integer, String>(2, "Foobar")));
+ }
+}