diff options
author | Brian Vosburgh | 2015-10-16 21:08:20 +0000 |
---|---|---|
committer | Brian Vosburgh | 2015-10-16 21:08:20 +0000 |
commit | 806185961a09d34efb657ee8ec3938d9ee38818d (patch) | |
tree | 9b5447ff5e07534b2f59b9c2725a157caf8fb07e /common/tests | |
parent | aff96c7056f450e7a378fe7592c5fc343b0c8536 (diff) | |
download | webtools.dali-806185961a09d34efb657ee8ec3938d9ee38818d.tar.gz webtools.dali-806185961a09d34efb657ee8ec3938d9ee38818d.tar.xz webtools.dali-806185961a09d34efb657ee8ec3938d9ee38818d.zip |
rework IntReferences
Diffstat (limited to 'common/tests')
4 files changed, 90 insertions, 18 deletions
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/AbstractIntReferenceTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/AbstractIntReferenceTests.java new file mode 100644 index 0000000000..9926fb90a7 --- /dev/null +++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/AbstractIntReferenceTests.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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.reference; + +import org.eclipse.jpt.common.utility.internal.reference.AbstractIntReference; +import junit.framework.TestCase; + +@SuppressWarnings("nls") +public class AbstractIntReferenceTests + extends TestCase +{ + public AbstractIntReferenceTests(String name) { + super(name); + } + + public void testGetValue() { + LocalIntReference br = new LocalIntReference(); + assertEquals(42, br.getValue()); + } + + public void testEqualsInt() { + LocalIntReference br = new LocalIntReference(); + assertTrue(br.equals(42)); + assertFalse(br.equals(0)); + } + + public void testNotEqual() { + LocalIntReference br = new LocalIntReference(); + assertFalse(br.notEqual(42)); + assertTrue(br.notEqual(0)); + } + + public void testIsZero() { + LocalIntReference br = new LocalIntReference(); + assertFalse(br.isZero()); + } + + public void testIsNotZero() { + LocalIntReference br = new LocalIntReference(); + assertTrue(br.isNotZero()); + } + + public void testEquals() { + LocalIntReference br1 = new LocalIntReference(); + LocalIntReference br2 = new LocalIntReference(); + assertTrue(br1.equals(br1)); + assertFalse(br1.equals(br2)); + } + + public void testHashCode() { + LocalIntReference br = new LocalIntReference(); + assertEquals(br.hashCode(), br.hashCode()); + } + + public void testToString() { + LocalIntReference br = new LocalIntReference(); + assertEquals("[42]", br.toString()); + } + + private class LocalIntReference + extends AbstractIntReference + { + LocalIntReference() { + super(); + } + public int getValue() { + return 42; + } + } +} diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/JptCommonUtilityReferenceTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/JptCommonUtilityReferenceTests.java index 719d0195f7..08fbd16f7a 100644 --- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/JptCommonUtilityReferenceTests.java +++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/JptCommonUtilityReferenceTests.java @@ -21,6 +21,7 @@ public class JptCommonUtilityReferenceTests { TestSuite suite = new TestSuite(JptCommonUtilityReferenceTests.class.getPackage().getName()); suite.addTestSuite(AbstractBooleanReferenceTests.class); + suite.addTestSuite(AbstractIntReferenceTests.class); suite.addTestSuite(SimpleBooleanReferenceTests.class); suite.addTestSuite(SimpleIntReferenceTests.class); suite.addTestSuite(SimpleObjectReferenceTests.class); diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SimpleIntReferenceTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SimpleIntReferenceTests.java index 84fcab0352..f85d7cd6c3 100644 --- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SimpleIntReferenceTests.java +++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SimpleIntReferenceTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 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. @@ -14,8 +14,9 @@ import org.eclipse.jpt.common.utility.internal.reference.SimpleIntReference; import org.eclipse.jpt.common.utility.tests.internal.TestTools; @SuppressWarnings("nls") -public class SimpleIntReferenceTests extends TestCase { - +public class SimpleIntReferenceTests + extends TestCase +{ public SimpleIntReferenceTests(String name) { super(name); } @@ -173,11 +174,11 @@ public class SimpleIntReferenceTests extends TestCase { SimpleIntReference ir; ir = new SimpleIntReference(-3); assertEquals(-3, ir.getValue()); - assertEquals(3, ir.neg()); + assertEquals(3, ir.negate()); ir.setValue(3); assertEquals(3, ir.getValue()); - assertEquals(-3, ir.neg()); + assertEquals(-3, ir.negate()); } public void testSetZero() { @@ -264,7 +265,8 @@ public class SimpleIntReferenceTests extends TestCase { ir = new SimpleIntReference(25); assertEquals(25, ir.getValue()); assertEquals(3, ir.min(3)); - assertEquals(25, ir.min(33)); + assertEquals(3, ir.getValue()); + assertEquals(3, ir.min(33)); } public void testMaxInt() { @@ -275,13 +277,6 @@ public class SimpleIntReferenceTests extends TestCase { assertEquals(30, ir.max(30)); } - public void testPowInt() { - SimpleIntReference ir; - ir = new SimpleIntReference(5); - assertEquals(5, ir.getValue()); - assertTrue(ir.pow(2) == 25L); - } - public void testCompareToIntReference() { SimpleIntReference ir1 = new SimpleIntReference(44); SimpleIntReference ir2 = new SimpleIntReference(44); @@ -311,5 +306,4 @@ public class SimpleIntReferenceTests extends TestCase { ir = new SimpleIntReference(5); assertEquals("[5]", ir.toString()); } - } diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SynchronizedIntTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SynchronizedIntTests.java index 2d1c825adc..df921544c6 100644 --- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SynchronizedIntTests.java +++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/reference/SynchronizedIntTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Oracle. All rights reserved. + * Copyright (c) 2009, 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. @@ -161,12 +161,12 @@ public class SynchronizedIntTests } public void testNeg() throws Exception { - assertEquals(0, this.si.neg()); + assertEquals(0, this.si.negate()); assertEquals(0, this.si.getValue()); this.si.setValue(this.value); - assertEquals(-this.value, this.si.neg()); + assertEquals(-this.value, this.si.negate()); this.si.setValue(-this.value); - assertEquals(this.value, this.si.neg()); + assertEquals(this.value, this.si.negate()); } public void testSetZero() throws Exception { |