Port to JUnit 4.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1185705 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b2fa6a727
commit
9506bec96f
|
@ -17,14 +17,18 @@
|
||||||
|
|
||||||
package org.apache.commons.lang3.builder;
|
package org.apache.commons.lang3.builder;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests {@link org.apache.commons.lang3.builder.HashCodeBuilder}.
|
* Unit tests {@link org.apache.commons.lang3.builder.HashCodeBuilder}.
|
||||||
*
|
*
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class HashCodeBuilderTest extends TestCase {
|
public class HashCodeBuilderTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reflection test fixture.
|
* A reflection test fixture.
|
||||||
|
@ -50,12 +54,9 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashCodeBuilderTest(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testConstructorEx1() {
|
public void testConstructorEx1() {
|
||||||
try {
|
try {
|
||||||
new HashCodeBuilder(0, 0);
|
new HashCodeBuilder(0, 0);
|
||||||
|
@ -66,6 +67,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testConstructorEx2() {
|
public void testConstructorEx2() {
|
||||||
try {
|
try {
|
||||||
new HashCodeBuilder(2, 2);
|
new HashCodeBuilder(2, 2);
|
||||||
|
@ -133,11 +135,13 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHashCode() {
|
public void testReflectionHashCode() {
|
||||||
assertEquals(17 * 37, HashCodeBuilder.reflectionHashCode(new TestObject(0)));
|
assertEquals(17 * 37, HashCodeBuilder.reflectionHashCode(new TestObject(0)));
|
||||||
assertEquals(17 * 37 + 123456, HashCodeBuilder.reflectionHashCode(new TestObject(123456)));
|
assertEquals(17 * 37 + 123456, HashCodeBuilder.reflectionHashCode(new TestObject(123456)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHierarchyHashCode() {
|
public void testReflectionHierarchyHashCode() {
|
||||||
assertEquals(17 * 37 * 37, HashCodeBuilder.reflectionHashCode(new TestSubObject(0, 0, 0)));
|
assertEquals(17 * 37 * 37, HashCodeBuilder.reflectionHashCode(new TestSubObject(0, 0, 0)));
|
||||||
assertEquals(17 * 37 * 37 * 37, HashCodeBuilder.reflectionHashCode(new TestSubObject(0, 0, 0), true));
|
assertEquals(17 * 37 * 37 * 37, HashCodeBuilder.reflectionHashCode(new TestSubObject(0, 0, 0), true));
|
||||||
|
@ -147,6 +151,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
123456, 7890, 0), true));
|
123456, 7890, 0), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHierarchyHashCodeEx1() {
|
public void testReflectionHierarchyHashCodeEx1() {
|
||||||
try {
|
try {
|
||||||
HashCodeBuilder.reflectionHashCode(0, 0, new TestSubObject(0, 0, 0), true);
|
HashCodeBuilder.reflectionHashCode(0, 0, new TestSubObject(0, 0, 0), true);
|
||||||
|
@ -156,6 +161,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHierarchyHashCodeEx2() {
|
public void testReflectionHierarchyHashCodeEx2() {
|
||||||
try {
|
try {
|
||||||
HashCodeBuilder.reflectionHashCode(2, 2, new TestSubObject(0, 0, 0), true);
|
HashCodeBuilder.reflectionHashCode(2, 2, new TestSubObject(0, 0, 0), true);
|
||||||
|
@ -165,6 +171,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHashCodeEx1() {
|
public void testReflectionHashCodeEx1() {
|
||||||
try {
|
try {
|
||||||
HashCodeBuilder.reflectionHashCode(0, 0, new TestObject(0), true);
|
HashCodeBuilder.reflectionHashCode(0, 0, new TestObject(0), true);
|
||||||
|
@ -174,6 +181,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHashCodeEx2() {
|
public void testReflectionHashCodeEx2() {
|
||||||
try {
|
try {
|
||||||
HashCodeBuilder.reflectionHashCode(2, 2, new TestObject(0), true);
|
HashCodeBuilder.reflectionHashCode(2, 2, new TestObject(0), true);
|
||||||
|
@ -183,6 +191,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHashCodeEx3() {
|
public void testReflectionHashCodeEx3() {
|
||||||
try {
|
try {
|
||||||
HashCodeBuilder.reflectionHashCode(13, 19, null, true);
|
HashCodeBuilder.reflectionHashCode(13, 19, null, true);
|
||||||
|
@ -192,12 +201,14 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSuper() {
|
public void testSuper() {
|
||||||
Object obj = new Object();
|
Object obj = new Object();
|
||||||
assertEquals(17 * 37 + (19 * 41 + obj.hashCode()), new HashCodeBuilder(17, 37).appendSuper(
|
assertEquals(17 * 37 + (19 * 41 + obj.hashCode()), new HashCodeBuilder(17, 37).appendSuper(
|
||||||
new HashCodeBuilder(19, 41).append(obj).toHashCode()).toHashCode());
|
new HashCodeBuilder(19, 41).append(obj).toHashCode()).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testObject() {
|
public void testObject() {
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
|
@ -205,6 +216,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testObjectBuild() {
|
public void testObjectBuild() {
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).build().intValue());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).build().intValue());
|
||||||
|
@ -212,6 +224,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).build().intValue());
|
assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).build().intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
||||||
public void testLong() {
|
public void testLong() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long) 0L).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long) 0L).toHashCode());
|
||||||
|
@ -219,27 +232,32 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
(long) 123456789L).toHashCode());
|
(long) 123456789L).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
||||||
public void testInt() {
|
public void testInt() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int) 0).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int) 0).toHashCode());
|
||||||
assertEquals(17 * 37 + 123456, new HashCodeBuilder(17, 37).append((int) 123456).toHashCode());
|
assertEquals(17 * 37 + 123456, new HashCodeBuilder(17, 37).append((int) 123456).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testShort() {
|
public void testShort() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short) 0).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short) 0).toHashCode());
|
||||||
assertEquals(17 * 37 + 12345, new HashCodeBuilder(17, 37).append((short) 12345).toHashCode());
|
assertEquals(17 * 37 + 12345, new HashCodeBuilder(17, 37).append((short) 12345).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testChar() {
|
public void testChar() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char) 0).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char) 0).toHashCode());
|
||||||
assertEquals(17 * 37 + 1234, new HashCodeBuilder(17, 37).append((char) 1234).toHashCode());
|
assertEquals(17 * 37 + 1234, new HashCodeBuilder(17, 37).append((char) 1234).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testByte() {
|
public void testByte() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte) 0).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte) 0).toHashCode());
|
||||||
assertEquals(17 * 37 + 123, new HashCodeBuilder(17, 37).append((byte) 123).toHashCode());
|
assertEquals(17 * 37 + 123, new HashCodeBuilder(17, 37).append((byte) 123).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
||||||
public void testDouble() {
|
public void testDouble() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double) 0d).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double) 0d).toHashCode());
|
||||||
|
@ -248,6 +266,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals(17 * 37 + (int) (l ^ (l >> 32)), new HashCodeBuilder(17, 37).append(d).toHashCode());
|
assertEquals(17 * 37 + (int) (l ^ (l >> 32)), new HashCodeBuilder(17, 37).append(d).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
||||||
public void testFloat() {
|
public void testFloat() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float) 0f).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float) 0f).toHashCode());
|
||||||
|
@ -256,11 +275,13 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals(17 * 37 + i, new HashCodeBuilder(17, 37).append(f).toHashCode());
|
assertEquals(17 * 37 + i, new HashCodeBuilder(17, 37).append(f).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBoolean() {
|
public void testBoolean() {
|
||||||
assertEquals(17 * 37 + 0, new HashCodeBuilder(17, 37).append(true).toHashCode());
|
assertEquals(17 * 37 + 0, new HashCodeBuilder(17, 37).append(true).toHashCode());
|
||||||
assertEquals(17 * 37 + 1, new HashCodeBuilder(17, 37).append(false).toHashCode());
|
assertEquals(17 * 37 + 1, new HashCodeBuilder(17, 37).append(false).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testObjectArray() {
|
public void testObjectArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((Object[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((Object[]) null).toHashCode());
|
||||||
Object[] obj = new Object[2];
|
Object[] obj = new Object[2];
|
||||||
|
@ -272,6 +293,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
.toHashCode());
|
.toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testObjectArrayAsObject() {
|
public void testObjectArrayAsObject() {
|
||||||
Object[] obj = new Object[2];
|
Object[] obj = new Object[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -282,6 +304,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
(Object) obj).toHashCode());
|
(Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLongArray() {
|
public void testLongArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long[]) null).toHashCode());
|
||||||
long[] obj = new long[2];
|
long[] obj = new long[2];
|
||||||
|
@ -294,6 +317,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLongArrayAsObject() {
|
public void testLongArrayAsObject() {
|
||||||
long[] obj = new long[2];
|
long[] obj = new long[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -305,6 +329,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testIntArray() {
|
public void testIntArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int[]) null).toHashCode());
|
||||||
int[] obj = new int[2];
|
int[] obj = new int[2];
|
||||||
|
@ -315,6 +340,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testIntArrayAsObject() {
|
public void testIntArrayAsObject() {
|
||||||
int[] obj = new int[2];
|
int[] obj = new int[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -324,6 +350,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testShortArray() {
|
public void testShortArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short[]) null).toHashCode());
|
||||||
short[] obj = new short[2];
|
short[] obj = new short[2];
|
||||||
|
@ -334,6 +361,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testShortArrayAsObject() {
|
public void testShortArrayAsObject() {
|
||||||
short[] obj = new short[2];
|
short[] obj = new short[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -343,6 +371,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCharArray() {
|
public void testCharArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char[]) null).toHashCode());
|
||||||
char[] obj = new char[2];
|
char[] obj = new char[2];
|
||||||
|
@ -353,6 +382,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCharArrayAsObject() {
|
public void testCharArrayAsObject() {
|
||||||
char[] obj = new char[2];
|
char[] obj = new char[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -362,6 +392,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testByteArray() {
|
public void testByteArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte[]) null).toHashCode());
|
||||||
byte[] obj = new byte[2];
|
byte[] obj = new byte[2];
|
||||||
|
@ -372,6 +403,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testByteArrayAsObject() {
|
public void testByteArrayAsObject() {
|
||||||
byte[] obj = new byte[2];
|
byte[] obj = new byte[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -381,6 +413,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + 5) * 37 + 6, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDoubleArray() {
|
public void testDoubleArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double[]) null).toHashCode());
|
||||||
double[] obj = new double[2];
|
double[] obj = new double[2];
|
||||||
|
@ -395,6 +428,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDoubleArrayAsObject() {
|
public void testDoubleArrayAsObject() {
|
||||||
double[] obj = new double[2];
|
double[] obj = new double[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -408,6 +442,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFloatArray() {
|
public void testFloatArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float[]) null).toHashCode());
|
||||||
float[] obj = new float[2];
|
float[] obj = new float[2];
|
||||||
|
@ -420,6 +455,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFloatArrayAsObject() {
|
public void testFloatArrayAsObject() {
|
||||||
float[] obj = new float[2];
|
float[] obj = new float[2];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -431,6 +467,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBooleanArray() {
|
public void testBooleanArray() {
|
||||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((boolean[]) null).toHashCode());
|
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((boolean[]) null).toHashCode());
|
||||||
boolean[] obj = new boolean[2];
|
boolean[] obj = new boolean[2];
|
||||||
|
@ -441,6 +478,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBooleanArrayAsObject() {
|
public void testBooleanArrayAsObject() {
|
||||||
boolean[] obj = new boolean[2];
|
boolean[] obj = new boolean[2];
|
||||||
assertEquals((17 * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
|
@ -450,6 +488,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
assertEquals((17 * 37 + 0) * 37 + 1, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBooleanMultiArray() {
|
public void testBooleanMultiArray() {
|
||||||
boolean[][] obj = new boolean[2][];
|
boolean[][] obj = new boolean[2][];
|
||||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
|
@ -465,6 +504,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
assertEquals((((17 * 37 + 0) * 37 + 1) * 37 + 1), new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
assertEquals((((17 * 37 + 0) * 37 + 1) * 37 + 1), new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testReflectionHashCodeExcludeFields() throws Exception {
|
public void testReflectionHashCodeExcludeFields() throws Exception {
|
||||||
TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
|
TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
|
||||||
|
|
||||||
|
@ -503,6 +543,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
/**
|
/**
|
||||||
* Test Objects pointing to each other.
|
* Test Objects pointing to each other.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReflectionObjectCycle() {
|
public void testReflectionObjectCycle() {
|
||||||
ReflectionTestCycleA a = new ReflectionTestCycleA();
|
ReflectionTestCycleA a = new ReflectionTestCycleA();
|
||||||
ReflectionTestCycleB b = new ReflectionTestCycleB();
|
ReflectionTestCycleB b = new ReflectionTestCycleB();
|
||||||
|
@ -535,6 +576,7 @@ public class HashCodeBuilderTest extends TestCase {
|
||||||
/**
|
/**
|
||||||
* Ensures LANG-520 remains true
|
* Ensures LANG-520 remains true
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testToHashCodeEqualsHashCode() {
|
public void testToHashCodeEqualsHashCode() {
|
||||||
HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
|
HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a');
|
||||||
assertEquals("hashCode() is no longer returning the same value as toHashCode() - see LANG-520",
|
assertEquals("hashCode() is no longer returning the same value as toHashCode() - see LANG-520",
|
||||||
|
|
Loading…
Reference in New Issue