Added tests for Pair class
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@363 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
943503be50
commit
d7aba3d722
1 changed files with 32 additions and 0 deletions
32
test/jrummikub/util/PairTest.java
Normal file
32
test/jrummikub/util/PairTest.java
Normal file
|
@ -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")));
|
||||
}
|
||||
}
|
Reference in a new issue