Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2015-11-16 10:40:48 -0500
committerBrian Vosburgh2015-11-16 10:40:48 -0500
commit654167632bddf5155fdb8cb1422b998fbb38944a (patch)
treed1c2643cd2a13dd00f1332e90d39d27abab3767e
parent9593579176fc5188682deceea39b899496efe5c3 (diff)
downloadwebtools.dali-654167632bddf5155fdb8cb1422b998fbb38944a.tar.gz
webtools.dali-654167632bddf5155fdb8cb1422b998fbb38944a.tar.xz
webtools.dali-654167632bddf5155fdb8cb1422b998fbb38944a.zip
add AbstractPairTests
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/AbstractPairTests.java120
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java1
2 files changed, 121 insertions, 0 deletions
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/AbstractPairTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/AbstractPairTests.java
new file mode 100644
index 0000000000..41fb2efd64
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/AbstractPairTests.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.tests.internal;
+
+import org.eclipse.jpt.common.utility.Pair;
+import org.eclipse.jpt.common.utility.internal.AbstractPair;
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
+public class AbstractPairTests
+ extends TestCase
+{
+ public AbstractPairTests(String name) {
+ super(name);
+ }
+
+ public void testEquals1() {
+ Pair<String, String> pair1 = new LocalPair("foo", "bar");
+ Pair<String, String> pair2 = new LocalPair("foo", "bar");
+ assertEquals(pair1, pair2);
+ }
+
+ public void testEquals1a() {
+ Pair<String, String> pair1 = new LocalPair("foo", null);
+ Pair<String, String> pair2 = new LocalPair("foo", null);
+ assertEquals(pair1, pair2);
+ }
+
+ public void testEquals1b() {
+ Pair<String, String> pair1 = new LocalPair(null, "bar");
+ Pair<String, String> pair2 = new LocalPair(null, "bar");
+ assertEquals(pair1, pair2);
+ }
+
+ public void testEquals2() {
+ Pair<String, String> pair = new LocalPair("foo", "bar");
+ assertFalse(pair.equals("foo"));
+ }
+
+ public void testEquals3() {
+ Pair<String, String> pair1 = new LocalPair("foo", "bar");
+ Pair<String, String> pair2 = new LocalPair("bar", "foo");
+ assertFalse(pair1.equals(pair2));
+ }
+
+ public void testEquals4() {
+ Pair<String, String> pair1 = new LocalPair("foo", "bar");
+ Pair<String, String> pair2 = new LocalPair("foo", "foo");
+ assertFalse(pair1.equals(pair2));
+ }
+
+ public void testEquals5() {
+ Pair<String, String> pair1 = new LocalPair("foo", "bar");
+ Pair<String, String> pair2 = new LocalPair(null, "bar");
+ assertFalse(pair1.equals(pair2));
+ }
+
+ public void testEquals6() {
+ Pair<String, String> pair1 = new LocalPair("foo", "bar");
+ Pair<String, String> pair2 = new LocalPair("foo", null);
+ assertFalse(pair1.equals(pair2));
+ }
+
+ public void testEquals7() {
+ Pair<String, String> pair1 = new LocalPair(null, "bar");
+ Pair<String, String> pair2 = new LocalPair("foo", "bar");
+ assertFalse(pair1.equals(pair2));
+ }
+
+ public void testEquals8() {
+ Pair<String, String> pair1 = new LocalPair("foo", null);
+ Pair<String, String> pair2 = new LocalPair("foo", "bar");
+ assertFalse(pair1.equals(pair2));
+ }
+
+ public void testToHashCode1() {
+ Pair<String, String> pair = new LocalPair("foo", "bar");
+ assertEquals("foo".hashCode() ^ "bar".hashCode(), pair.hashCode());
+ }
+
+ public void testToHashCode2() {
+ Pair<String, String> pair = new LocalPair(null, "bar");
+ assertEquals(0 ^ "bar".hashCode(), pair.hashCode());
+ }
+
+ public void testToHashCode3() {
+ Pair<String, String> pair = new LocalPair("foo", null);
+ assertEquals("foo".hashCode() ^ 0, pair.hashCode());
+ }
+
+ public void testToString() {
+ Pair<String, String> pair = new LocalPair("foo", "bar");
+ assertEquals("foo|bar", pair.toString());
+ }
+
+ public static class LocalPair
+ extends AbstractPair<String, String>
+ {
+ private final String left;
+ private final String right;
+ public LocalPair(String left, String right) {
+ super();
+ this.left = left;
+ this.right = right;
+ }
+ public String getLeft() {
+ return this.left;
+ }
+ public String getRight() {
+ return this.right;
+ }
+ }
+}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java
index 28e0f2a141..ab7b8c52ec 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java
@@ -57,6 +57,7 @@ public class JptCommonUtilityTests {
suite.addTest(JptCommonUtilityStackTests.suite());
suite.addTest(JptCommonUtilityTransformerTests.suite());
+ suite.addTestSuite(AbstractPairTests.class);
suite.addTestSuite(ArrayToolsTests.class);
suite.addTestSuite(BitToolsTests.class);
suite.addTestSuite(BooleanToolsTests.class);

Back to the top