This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
JRummikub/test/jrummikub/util/PairTest.java

33 lines
1,013 B
Java
Raw Permalink Normal View History

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")));
}
}