From 3609993fb588017c77fc1781d697dcf1717cd73a Mon Sep 17 00:00:00 2001 From: Allon Mureinik Date: Sat, 13 Oct 2018 20:05:40 +0300 Subject: [PATCH] Clean up assertions (closes #376) Use built-in assertion methods provides by org.junit.jupiter.api.Assertions instead of reimplementing the same logic with assertTrue and assertFalse. Note that JUnit Jupiter 5.3.1 does not support deltas of 0 for assertEquals(double, double, double) and assertEquals(float, float, float), so these usages of assertTrue were left untouched, and will be addressed when JUnit Jupiter 5.4, that addresses this isssue, will be available (see https://github.com/junit-team/junit5/pull/1613 for details). --- .../commons/lang3/AnnotationUtilsTest.java | 9 +- .../commons/lang3/ArrayUtilsInsertTest.java | 20 +- .../apache/commons/lang3/ArrayUtilsTest.java | 32 +- .../commons/lang3/BooleanUtilsTest.java | 4 +- .../apache/commons/lang3/CharRangeTest.java | 39 +- .../org/apache/commons/lang3/CharSetTest.java | 27 +- .../apache/commons/lang3/CharUtilsTest.java | 7 +- .../apache/commons/lang3/ClassUtilsTest.java | 2 +- .../org/apache/commons/lang3/RangeTest.java | 13 +- .../lang3/StringUtilsEqualsIndexOfTest.java | 20 +- .../apache/commons/lang3/StringUtilsTest.java | 22 +- .../lang3/builder/CompareToBuilderTest.java | 190 +++--- .../lang3/builder/DiffBuilderTest.java | 17 +- .../commons/lang3/builder/DiffResultTest.java | 2 +- .../lang3/builder/EqualsBuilderTest.java | 15 +- .../concurrent/BasicThreadFactoryTest.java | 2 +- .../concurrent/ConstantInitializerTest.java | 4 +- .../AbstractExceptionContextTest.java | 17 +- .../exception/ContextedExceptionTest.java | 3 +- .../ContextedRuntimeExceptionTest.java | 3 +- .../commons/lang3/math/FractionTest.java | 42 +- .../commons/lang3/math/NumberUtilsTest.java | 595 ++++++++---------- .../lang3/mutable/MutableBooleanTest.java | 21 +- .../lang3/mutable/MutableByteTest.java | 27 +- .../lang3/mutable/MutableDoubleTest.java | 27 +- .../lang3/mutable/MutableFloatTest.java | 27 +- .../commons/lang3/mutable/MutableIntTest.java | 27 +- .../lang3/mutable/MutableLongTest.java | 27 +- .../lang3/mutable/MutableShortTest.java | 27 +- .../lang3/text/ExtendedMessageFormatTest.java | 22 +- .../commons/lang3/text/StrBuilderTest.java | 27 +- .../commons/lang3/text/StrTokenizerTest.java | 11 +- .../lang3/time/DateUtilsRoundingTest.java | 18 +- .../lang3/time/DurationFormatUtilsTest.java | 11 +- .../lang3/time/FastDateFormatTest.java | 17 +- .../lang3/time/FastDateParserTest.java | 5 +- .../lang3/time/FastDatePrinterTest.java | 4 +- .../commons/lang3/time/StopWatchTest.java | 2 +- .../lang3/tuple/ImmutablePairTest.java | 11 +- .../lang3/tuple/ImmutableTripleTest.java | 11 +- .../commons/lang3/tuple/MutablePairTest.java | 11 +- .../lang3/tuple/MutableTripleTest.java | 13 +- .../apache/commons/lang3/tuple/PairTest.java | 11 +- .../commons/lang3/tuple/TripleTest.java | 16 +- 44 files changed, 712 insertions(+), 746 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java index fb129d01c..f4ed2a05e 100644 --- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java @@ -24,6 +24,7 @@ import static org.apache.commons.lang3.AnnotationUtilsTest.Stooge.SHEMP; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -484,16 +485,16 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg final Test generated = (Test) Proxy.newProxyInstance(Thread.currentThread() .getContextClassLoader(), new Class[]{Test.class}, generatedTestInvocationHandler); - assertTrue(real.equals(generated)); - assertFalse(generated.equals(real)); + assertEquals(real, generated); + assertNotEquals(generated, real); assertTrue(AnnotationUtils.equals(generated, real)); assertTrue(AnnotationUtils.equals(real, generated)); final Test generated2 = (Test) Proxy.newProxyInstance(Thread.currentThread() .getContextClassLoader(), new Class[]{Test.class}, generatedTestInvocationHandler); - assertFalse(generated.equals(generated2)); - assertFalse(generated2.equals(generated)); + assertNotEquals(generated, generated2); + assertNotEquals(generated2, generated); assertTrue(AnnotationUtils.equals(generated, generated2)); assertTrue(AnnotationUtils.equals(generated2, generated)); }); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java index 63b63866d..689e79d69 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java @@ -18,7 +18,7 @@ package org.apache.commons.lang3; import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -36,7 +36,7 @@ public void testInsertBooleans() { final boolean[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new boolean[0], ArrayUtils.insert(0, new boolean[0], null)); @@ -61,7 +61,7 @@ public void testInsertBytes() { final byte[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new byte[0], ArrayUtils.insert(0, new byte[0], null)); @@ -85,7 +85,7 @@ public void testInsertChars() { final char[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new char[0], ArrayUtils.insert(0, new char[0], null)); @@ -110,7 +110,7 @@ public void testInsertDoubles() { final double[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new double[0], ArrayUtils.insert(0, new double[0], null), delta); @@ -135,7 +135,7 @@ public void testInsertFloats() { final float[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new float[0], ArrayUtils.insert(0, new float[0], null), delta); @@ -159,7 +159,7 @@ public void testInsertInts() { final int[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new int[0], ArrayUtils.insert(0, new int[0], null)); @@ -184,7 +184,7 @@ public void testInsertLongs() { final long[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new long[0], ArrayUtils.insert(0, new long[0], null)); @@ -209,7 +209,7 @@ public void testInsertShorts() { final short[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new short[0], ArrayUtils.insert(0, new short[0], null)); @@ -234,7 +234,7 @@ public void testInsertGenericArray() { final String[] result = ArrayUtils.insert(42, array, (String[]) null); assertArrayEquals(array, result); - assertFalse(array == result); + assertNotSame(array, result); assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new String[0], ArrayUtils.insert(0, new String[0], (String[]) null)); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java index 97658f8fd..c5044094b 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java @@ -77,17 +77,17 @@ public void testToString() { public void testHashCode() { final long[][] array1 = new long[][]{{2, 5}, {4, 5}}; final long[][] array2 = new long[][]{{2, 5}, {4, 6}}; - assertTrue(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array1)); + assertEquals(ArrayUtils.hashCode(array1), ArrayUtils.hashCode(array1)); assertFalse(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array2)); final Object[] array3 = new Object[]{new String(new char[]{'A', 'B'})}; final Object[] array4 = new Object[]{"AB"}; - assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array3)); - assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array4)); + assertEquals(ArrayUtils.hashCode(array3), ArrayUtils.hashCode(array3)); + assertEquals(ArrayUtils.hashCode(array3), ArrayUtils.hashCode(array4)); final Object[] arrayA = new Object[]{new boolean[]{true, false}, new int[]{6, 7}}; final Object[] arrayB = new Object[]{new boolean[]{true, false}, new int[]{6, 7}}; - assertTrue(ArrayUtils.hashCode(arrayB) == ArrayUtils.hashCode(arrayA)); + assertEquals(ArrayUtils.hashCode(arrayB), ArrayUtils.hashCode(arrayA)); } //----------------------------------------------------------------------- @@ -272,13 +272,13 @@ public void testClone() { Object[] original1 = new Object[0]; Object[] cloned1 = ArrayUtils.clone(original1); assertTrue(Arrays.equals(original1, cloned1)); - assertTrue(original1 != cloned1); + assertNotSame(original1, cloned1); final StringBuilder builder = new StringBuilder("pick"); original1 = new Object[]{builder, "a", new String[]{"stick"}}; cloned1 = ArrayUtils.clone(original1); assertTrue(Arrays.equals(original1, cloned1)); - assertTrue(original1 != cloned1); + assertNotSame(original1, cloned1); assertSame(original1[0], cloned1[0]); assertSame(original1[1], cloned1[1]); assertSame(original1[2], cloned1[2]); @@ -290,7 +290,7 @@ public void testCloneBoolean() { final boolean[] original = new boolean[]{true, false}; final boolean[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } @Test @@ -299,7 +299,7 @@ public void testCloneLong() { final long[] original = new long[]{0L, 1L}; final long[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } @Test @@ -308,7 +308,7 @@ public void testCloneInt() { final int[] original = new int[]{5, 8}; final int[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } @Test @@ -317,7 +317,7 @@ public void testCloneShort() { final short[] original = new short[]{1, 4}; final short[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } @Test @@ -326,7 +326,7 @@ public void testCloneChar() { final char[] original = new char[]{'a', '4'}; final char[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } @Test @@ -335,7 +335,7 @@ public void testCloneByte() { final byte[] original = new byte[]{1, 6}; final byte[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } @Test @@ -344,7 +344,7 @@ public void testCloneDouble() { final double[] original = new double[]{2.4d, 5.7d}; final double[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } @Test @@ -353,7 +353,7 @@ public void testCloneFloat() { final float[] original = new float[]{2.6f, 6.4f}; final float[] cloned = ArrayUtils.clone(original); assertTrue(Arrays.equals(original, cloned)); - assertTrue(original != cloned); + assertNotSame(original, cloned); } //----------------------------------------------------------------------- @@ -365,8 +365,8 @@ private class TestClass { public void testNullToEmptyGenericNull() { final TestClass[] output = ArrayUtils.nullToEmpty(null, TestClass[].class); - assertTrue(output != null); - assertTrue(output.length == 0); + assertNotNull(output); + assertEquals(0, output.length); } @Test diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java index bea660d5d..dddb416d3 100644 --- a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java @@ -1009,8 +1009,8 @@ public void testOr_object_validInput_3items() { @Test public void testCompare(){ assertTrue(BooleanUtils.compare(true, false) > 0); - assertTrue(BooleanUtils.compare(true, true) == 0); - assertTrue(BooleanUtils.compare(false, false) == 0); + assertEquals(0, BooleanUtils.compare(true, true)); + assertEquals(0, BooleanUtils.compare(false, false)); assertTrue(BooleanUtils.compare(false, true) < 0); } diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java index 9704dfef3..5e9c01905 100644 --- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java +++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -123,21 +124,21 @@ public void testEquals_Object() { final CharRange rangeae = CharRange.isIn('a', 'e'); final CharRange rangenotbf = CharRange.isIn('b', 'f'); - assertFalse(rangea.equals(null)); + assertNotEquals(null, rangea); - assertTrue(rangea.equals(rangea)); - assertTrue(rangea.equals(CharRange.is('a'))); - assertTrue(rangeae.equals(rangeae)); - assertTrue(rangeae.equals(CharRange.isIn('a', 'e'))); - assertTrue(rangenotbf.equals(rangenotbf)); - assertTrue(rangenotbf.equals(CharRange.isIn('b', 'f'))); + assertEquals(rangea, rangea); + assertEquals(rangea, CharRange.is('a')); + assertEquals(rangeae, rangeae); + assertEquals(rangeae, CharRange.isIn('a', 'e')); + assertEquals(rangenotbf, rangenotbf); + assertEquals(rangenotbf, CharRange.isIn('b', 'f')); - assertFalse(rangea.equals(rangeae)); - assertFalse(rangea.equals(rangenotbf)); - assertFalse(rangeae.equals(rangea)); - assertFalse(rangeae.equals(rangenotbf)); - assertFalse(rangenotbf.equals(rangea)); - assertFalse(rangenotbf.equals(rangeae)); + assertNotEquals(rangea, rangeae); + assertNotEquals(rangea, rangenotbf); + assertNotEquals(rangeae, rangea); + assertNotEquals(rangeae, rangenotbf); + assertNotEquals(rangenotbf, rangea); + assertNotEquals(rangenotbf, rangeae); } @Test @@ -146,12 +147,12 @@ public void testHashCode() { final CharRange rangeae = CharRange.isIn('a', 'e'); final CharRange rangenotbf = CharRange.isIn('b', 'f'); - assertTrue(rangea.hashCode() == rangea.hashCode()); - assertTrue(rangea.hashCode() == CharRange.is('a').hashCode()); - assertTrue(rangeae.hashCode() == rangeae.hashCode()); - assertTrue(rangeae.hashCode() == CharRange.isIn('a', 'e').hashCode()); - assertTrue(rangenotbf.hashCode() == rangenotbf.hashCode()); - assertTrue(rangenotbf.hashCode() == CharRange.isIn('b', 'f').hashCode()); + assertEquals(rangea.hashCode(), rangea.hashCode()); + assertEquals(rangea.hashCode(), CharRange.is('a').hashCode()); + assertEquals(rangeae.hashCode(), rangeae.hashCode()); + assertEquals(rangeae.hashCode(), CharRange.isIn('a', 'e').hashCode()); + assertEquals(rangenotbf.hashCode(), rangenotbf.hashCode()); + assertEquals(rangenotbf.hashCode(), CharRange.isIn('b', 'f').hashCode()); assertFalse(rangea.hashCode() == rangeae.hashCode()); assertFalse(rangea.hashCode() == rangenotbf.hashCode()); diff --git a/src/test/java/org/apache/commons/lang3/CharSetTest.java b/src/test/java/org/apache/commons/lang3/CharSetTest.java index 50683f965..e0f318d39 100644 --- a/src/test/java/org/apache/commons/lang3/CharSetTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSetTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -349,22 +350,22 @@ public void testEquals_Object() { final CharSet notatoc = CharSet.getInstance("^a-c"); final CharSet notatoc2 = CharSet.getInstance("^a-c"); - assertFalse(abc.equals(null)); + assertNotEquals(null, abc); - assertTrue(abc.equals(abc)); - assertTrue(abc.equals(abc2)); - assertFalse(abc.equals(atoc)); - assertFalse(abc.equals(notatoc)); + assertEquals(abc, abc); + assertEquals(abc, abc2); + assertNotEquals(abc, atoc); + assertNotEquals(abc, notatoc); - assertFalse(atoc.equals(abc)); - assertTrue(atoc.equals(atoc)); - assertTrue(atoc.equals(atoc2)); - assertFalse(atoc.equals(notatoc)); + assertNotEquals(atoc, abc); + assertEquals(atoc, atoc); + assertEquals(atoc, atoc2); + assertNotEquals(atoc, notatoc); - assertFalse(notatoc.equals(abc)); - assertFalse(notatoc.equals(atoc)); - assertTrue(notatoc.equals(notatoc)); - assertTrue(notatoc.equals(notatoc2)); + assertNotEquals(notatoc, abc); + assertNotEquals(notatoc, atoc); + assertEquals(notatoc, notatoc); + assertEquals(notatoc, notatoc2); } @Test diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java index 5d4d69a74..d4ba3e62d 100644 --- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -41,7 +42,7 @@ public class CharUtilsTest { @Test public void testCompare() { assertTrue(CharUtils.compare('a', 'b') < 0); - assertTrue(CharUtils.compare('c', 'c') == 0); + assertEquals(0, CharUtils.compare('c', 'c')); assertTrue(CharUtils.compare('c', 'a') > 0); } @@ -241,7 +242,7 @@ public void testToCharacterObject_char() { final Character ch = CharUtils.toCharacterObject((char) i); final Character ch2 = CharUtils.toCharacterObject((char) i); assertEquals(ch, ch2); - assertTrue(ch != ch2); + assertNotSame(ch, ch2); assertEquals(i, ch.charValue()); assertEquals(i, ch2.charValue()); } @@ -311,7 +312,7 @@ public void testToString_char() { final String str = CharUtils.toString((char) i); final String str2 = CharUtils.toString((char) i); assertEquals(str, str2); - assertTrue(str != str2); + assertNotSame(str, str2); assertEquals(1, str.length()); assertEquals(i, str.charAt(0)); assertEquals(1, str2.length()); diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java index 219f0b856..59c9dad64 100644 --- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java @@ -663,7 +663,7 @@ public void test_getSimpleName_Object_String() { assertEquals("Inner", ClassUtils.getSimpleName(new Inner(), "")); assertEquals("String", ClassUtils.getSimpleName("hello", "")); assertEquals("", ClassUtils.getSimpleName(null, "")); - assertEquals(null, ClassUtils.getSimpleName(null, null)); + assertNull(ClassUtils.getSimpleName(null, null)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/RangeTest.java b/src/test/java/org/apache/commons/lang3/RangeTest.java index 32173c867..3c2cd48fc 100644 --- a/src/test/java/org/apache/commons/lang3/RangeTest.java +++ b/src/test/java/org/apache/commons/lang3/RangeTest.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -147,12 +148,12 @@ public void testEqualsObject() { assertEquals(byteRange, byteRange); assertEquals(byteRange, byteRange2); assertEquals(byteRange2, byteRange2); - assertTrue(byteRange.equals(byteRange)); - assertTrue(byteRange2.equals(byteRange2)); - assertTrue(byteRange3.equals(byteRange3)); - assertFalse(byteRange2.equals(byteRange3)); - assertFalse(byteRange2.equals(null)); - assertFalse(byteRange2.equals("Ni!")); + assertEquals(byteRange, byteRange); + assertEquals(byteRange2, byteRange2); + assertEquals(byteRange3, byteRange3); + assertNotEquals(byteRange2, byteRange3); + assertNotEquals(null, byteRange2); + assertNotEquals("Ni!", byteRange2); } @Test diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java index c9a9fd15e..070fe90e4 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java @@ -200,10 +200,10 @@ public void testEqualsAnyIgnoreCase() { //----------------------------------------------------------------------- @Test public void testCompare_StringString() { - assertTrue(StringUtils.compare(null, null) == 0); + assertEquals(0, StringUtils.compare(null, null)); assertTrue(StringUtils.compare(null, "a") < 0); assertTrue(StringUtils.compare("a", null) > 0); - assertTrue(StringUtils.compare("abc", "abc") == 0); + assertEquals(0, StringUtils.compare("abc", "abc")); assertTrue(StringUtils.compare("a", "b") < 0); assertTrue(StringUtils.compare("b", "a") > 0); assertTrue(StringUtils.compare("a", "B") > 0); @@ -215,12 +215,12 @@ public void testCompare_StringString() { @Test public void testCompare_StringStringBoolean() { - assertTrue(StringUtils.compare(null, null, false) == 0); + assertEquals(0, StringUtils.compare(null, null, false)); assertTrue(StringUtils.compare(null, "a", true) < 0); assertTrue(StringUtils.compare(null, "a", false) > 0); assertTrue(StringUtils.compare("a", null, true) > 0); assertTrue(StringUtils.compare("a", null, false) < 0); - assertTrue(StringUtils.compare("abc", "abc", false) == 0); + assertEquals(0, StringUtils.compare("abc", "abc", false)); assertTrue(StringUtils.compare("a", "b", false) < 0); assertTrue(StringUtils.compare("b", "a", false) > 0); assertTrue(StringUtils.compare("a", "B", false) > 0); @@ -232,11 +232,11 @@ public void testCompare_StringStringBoolean() { @Test public void testCompareIgnoreCase_StringString() { - assertTrue(StringUtils.compareIgnoreCase(null, null) == 0); + assertEquals(0, StringUtils.compareIgnoreCase(null, null)); assertTrue(StringUtils.compareIgnoreCase(null, "a") < 0); assertTrue(StringUtils.compareIgnoreCase("a", null) > 0); - assertTrue(StringUtils.compareIgnoreCase("abc", "abc") == 0); - assertTrue(StringUtils.compareIgnoreCase("abc", "ABC") == 0); + assertEquals(0, StringUtils.compareIgnoreCase("abc", "abc")); + assertEquals(0, StringUtils.compareIgnoreCase("abc", "ABC")); assertTrue(StringUtils.compareIgnoreCase("a", "b") < 0); assertTrue(StringUtils.compareIgnoreCase("b", "a") > 0); assertTrue(StringUtils.compareIgnoreCase("a", "B") < 0); @@ -249,13 +249,13 @@ public void testCompareIgnoreCase_StringString() { @Test public void testCompareIgnoreCase_StringStringBoolean() { - assertTrue(StringUtils.compareIgnoreCase(null, null, false) == 0); + assertEquals(0, StringUtils.compareIgnoreCase(null, null, false)); assertTrue(StringUtils.compareIgnoreCase(null, "a", true) < 0); assertTrue(StringUtils.compareIgnoreCase(null, "a", false) > 0); assertTrue(StringUtils.compareIgnoreCase("a", null, true) > 0); assertTrue(StringUtils.compareIgnoreCase("a", null, false) < 0); - assertTrue(StringUtils.compareIgnoreCase("abc", "abc", false) == 0); - assertTrue(StringUtils.compareIgnoreCase("abc", "ABC", false) == 0); + assertEquals(0, StringUtils.compareIgnoreCase("abc", "abc", false)); + assertEquals(0, StringUtils.compareIgnoreCase("abc", "ABC", false)); assertTrue(StringUtils.compareIgnoreCase("a", "b", false) < 0); assertTrue(StringUtils.compareIgnoreCase("b", "a", false) > 0); assertTrue(StringUtils.compareIgnoreCase("a", "B", false) < 0); diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 4da5f0bf0..afcd6b2f9 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -1653,9 +1653,9 @@ public void testChomp() { assertEquals("", StringUtils.chomp("", "foo"), "chomp(String, String) failed"); assertEquals("", StringUtils.chomp("", null), "chomp(String, String) failed"); assertEquals("", StringUtils.chomp("", ""), "chomp(String, String) failed"); - assertEquals(null, StringUtils.chomp(null, "foo"), "chomp(String, String) failed"); - assertEquals(null, StringUtils.chomp(null, null), "chomp(String, String) failed"); - assertEquals(null, StringUtils.chomp(null, ""), "chomp(String, String) failed"); + assertNull(StringUtils.chomp(null, "foo"), "chomp(String, String) failed"); + assertNull(StringUtils.chomp(null, null), "chomp(String, String) failed"); + assertNull(StringUtils.chomp(null, ""), "chomp(String, String) failed"); assertEquals("", StringUtils.chomp("foo", "foo"), "chomp(String, String) failed"); assertEquals(" ", StringUtils.chomp(" foo", "foo"), "chomp(String, String) failed"); assertEquals("foo ", StringUtils.chomp("foo ", "foo"), "chomp(String, String) failed"); @@ -2920,14 +2920,14 @@ public void testUnescapeSurrogatePairs() { */ @Test public void testAppendIfMissing() { - assertEquals(null, StringUtils.appendIfMissing(null, null), "appendIfMissing(null,null)"); + assertNull(StringUtils.appendIfMissing(null, null), "appendIfMissing(null,null)"); assertEquals("abc", StringUtils.appendIfMissing("abc", null), "appendIfMissing(abc,null)"); assertEquals("xyz", StringUtils.appendIfMissing("", "xyz"), "appendIfMissing(\"\",xyz)"); assertEquals("abcxyz", StringUtils.appendIfMissing("abc", "xyz"), "appendIfMissing(abc,xyz)"); assertEquals("abcxyz", StringUtils.appendIfMissing("abcxyz", "xyz"), "appendIfMissing(abcxyz,xyz)"); assertEquals("aXYZxyz", StringUtils.appendIfMissing("aXYZ", "xyz"), "appendIfMissing(aXYZ,xyz)"); - assertEquals(null, StringUtils.appendIfMissing(null, null, (CharSequence[]) null), "appendIfMissing(null,null,null)"); + assertNull(StringUtils.appendIfMissing(null, null, (CharSequence[]) null), "appendIfMissing(null,null,null)"); assertEquals("abc", StringUtils.appendIfMissing("abc", null, (CharSequence[]) null), "appendIfMissing(abc,null,null)"); assertEquals("xyz", StringUtils.appendIfMissing("", "xyz", (CharSequence[]) null), "appendIfMissing(\"\",xyz,null))"); assertEquals("abcxyz", StringUtils.appendIfMissing("abc", "xyz", new CharSequence[]{null}), "appendIfMissing(abc,xyz,{null})"); @@ -2944,14 +2944,14 @@ public void testAppendIfMissing() { */ @Test public void testAppendIfMissingIgnoreCase() { - assertEquals(null, StringUtils.appendIfMissingIgnoreCase(null, null), "appendIfMissingIgnoreCase(null,null)"); + assertNull(StringUtils.appendIfMissingIgnoreCase(null, null), "appendIfMissingIgnoreCase(null,null)"); assertEquals("abc", StringUtils.appendIfMissingIgnoreCase("abc", null), "appendIfMissingIgnoreCase(abc,null)"); assertEquals("xyz", StringUtils.appendIfMissingIgnoreCase("", "xyz"), "appendIfMissingIgnoreCase(\"\",xyz)"); assertEquals("abcxyz", StringUtils.appendIfMissingIgnoreCase("abc", "xyz"), "appendIfMissingIgnoreCase(abc,xyz)"); assertEquals("abcxyz", StringUtils.appendIfMissingIgnoreCase("abcxyz", "xyz"), "appendIfMissingIgnoreCase(abcxyz,xyz)"); assertEquals("abcXYZ", StringUtils.appendIfMissingIgnoreCase("abcXYZ", "xyz"), "appendIfMissingIgnoreCase(abcXYZ,xyz)"); - assertEquals(null, StringUtils.appendIfMissingIgnoreCase(null, null, (CharSequence[]) null), "appendIfMissingIgnoreCase(null,null,null)"); + assertNull(StringUtils.appendIfMissingIgnoreCase(null, null, (CharSequence[]) null), "appendIfMissingIgnoreCase(null,null,null)"); assertEquals("abc", StringUtils.appendIfMissingIgnoreCase("abc", null, (CharSequence[]) null), "appendIfMissingIgnoreCase(abc,null,null)"); assertEquals("xyz", StringUtils.appendIfMissingIgnoreCase("", "xyz", (CharSequence[]) null), "appendIfMissingIgnoreCase(\"\",xyz,null)"); assertEquals("abcxyz", StringUtils.appendIfMissingIgnoreCase("abc", "xyz", new CharSequence[]{null}), "appendIfMissingIgnoreCase(abc,xyz,{null})"); @@ -2968,14 +2968,14 @@ public void testAppendIfMissingIgnoreCase() { */ @Test public void testPrependIfMissing() { - assertEquals(null, StringUtils.prependIfMissing(null, null), "prependIfMissing(null,null)"); + assertNull(StringUtils.prependIfMissing(null, null), "prependIfMissing(null,null)"); assertEquals("abc", StringUtils.prependIfMissing("abc", null), "prependIfMissing(abc,null)"); assertEquals("xyz", StringUtils.prependIfMissing("", "xyz"), "prependIfMissing(\"\",xyz)"); assertEquals("xyzabc", StringUtils.prependIfMissing("abc", "xyz"), "prependIfMissing(abc,xyz)"); assertEquals("xyzabc", StringUtils.prependIfMissing("xyzabc", "xyz"), "prependIfMissing(xyzabc,xyz)"); assertEquals("xyzXYZabc", StringUtils.prependIfMissing("XYZabc", "xyz"), "prependIfMissing(XYZabc,xyz)"); - assertEquals(null, StringUtils.prependIfMissing(null, null, (CharSequence[]) null), "prependIfMissing(null,null null)"); + assertNull(StringUtils.prependIfMissing(null, null, (CharSequence[]) null), "prependIfMissing(null,null null)"); assertEquals("abc", StringUtils.prependIfMissing("abc", null, (CharSequence[]) null), "prependIfMissing(abc,null,null)"); assertEquals("xyz", StringUtils.prependIfMissing("", "xyz", (CharSequence[]) null), "prependIfMissing(\"\",xyz,null)"); assertEquals("xyzabc", StringUtils.prependIfMissing("abc", "xyz", new CharSequence[]{null}), "prependIfMissing(abc,xyz,{null})"); @@ -2992,14 +2992,14 @@ public void testPrependIfMissing() { */ @Test public void testPrependIfMissingIgnoreCase() { - assertEquals(null, StringUtils.prependIfMissingIgnoreCase(null, null), "prependIfMissingIgnoreCase(null,null)"); + assertNull(StringUtils.prependIfMissingIgnoreCase(null, null), "prependIfMissingIgnoreCase(null,null)"); assertEquals("abc", StringUtils.prependIfMissingIgnoreCase("abc", null), "prependIfMissingIgnoreCase(abc,null)"); assertEquals("xyz", StringUtils.prependIfMissingIgnoreCase("", "xyz"), "prependIfMissingIgnoreCase(\"\",xyz)"); assertEquals("xyzabc", StringUtils.prependIfMissingIgnoreCase("abc", "xyz"), "prependIfMissingIgnoreCase(abc,xyz)"); assertEquals("xyzabc", StringUtils.prependIfMissingIgnoreCase("xyzabc", "xyz"), "prependIfMissingIgnoreCase(xyzabc,xyz)"); assertEquals("XYZabc", StringUtils.prependIfMissingIgnoreCase("XYZabc", "xyz"), "prependIfMissingIgnoreCase(XYZabc,xyz)"); - assertEquals(null, StringUtils.prependIfMissingIgnoreCase(null, null, (CharSequence[]) null), "prependIfMissingIgnoreCase(null,null null)"); + assertNull(StringUtils.prependIfMissingIgnoreCase(null, null, (CharSequence[]) null), "prependIfMissingIgnoreCase(null,null null)"); assertEquals("abc", StringUtils.prependIfMissingIgnoreCase("abc", null, (CharSequence[]) null), "prependIfMissingIgnoreCase(abc,null,null)"); assertEquals("xyz", StringUtils.prependIfMissingIgnoreCase("", "xyz", (CharSequence[]) null), "prependIfMissingIgnoreCase(\"\",xyz,null)"); assertEquals("xyzabc", StringUtils.prependIfMissingIgnoreCase("abc", "xyz", new CharSequence[]{null}), "prependIfMissingIgnoreCase(abc,xyz,{null})"); diff --git a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java index 86372b63b..ef3b7c534 100644 --- a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java @@ -101,8 +101,8 @@ static class TestTransientSubObject extends TestObject { public void testReflectionCompare() { final TestObject o1 = new TestObject(4); final TestObject o2 = new TestObject(4); - assertTrue(CompareToBuilder.reflectionCompare(o1, o1) == 0); - assertTrue(CompareToBuilder.reflectionCompare(o1, o2) == 0); + assertEquals(0, CompareToBuilder.reflectionCompare(o1, o1)); + assertEquals(0, CompareToBuilder.reflectionCompare(o1, o2)); o2.setA(5); assertTrue(CompareToBuilder.reflectionCompare(o1, o2) < 0); assertTrue(CompareToBuilder.reflectionCompare(o2, o1) > 0); @@ -166,9 +166,9 @@ public void testReflectionHierarchyCompareTransients() { } private void assertXYZCompareOrder(final Object x, final Object y, final Object z, final boolean testTransients, final String[] excludeFields) { - assertTrue(0 == CompareToBuilder.reflectionCompare(x, x, testTransients, null, excludeFields)); - assertTrue(0 == CompareToBuilder.reflectionCompare(y, y, testTransients, null, excludeFields)); - assertTrue(0 == CompareToBuilder.reflectionCompare(z, z, testTransients, null, excludeFields)); + assertEquals(0, CompareToBuilder.reflectionCompare(x, x, testTransients, null, excludeFields)); + assertEquals(0, CompareToBuilder.reflectionCompare(y, y, testTransients, null, excludeFields)); + assertEquals(0, CompareToBuilder.reflectionCompare(z, z, testTransients, null, excludeFields)); assertTrue(0 > CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields)); assertTrue(0 > CompareToBuilder.reflectionCompare(x, z, testTransients, null, excludeFields)); @@ -214,7 +214,7 @@ private void testReflectionHierarchyCompare(final boolean testTransients, final private void assertReflectionCompareContract(final Object x, final Object y, final Object z, final boolean testTransients, final String[] excludeFields) { // signum - assertTrue(reflectionCompareSignum(x, y, testTransients, excludeFields) == -reflectionCompareSignum(y, x, testTransients, excludeFields)); + assertEquals(reflectionCompareSignum(x, y, testTransients, excludeFields), -reflectionCompareSignum(y, x, testTransients, excludeFields)); // transitive if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) > 0 @@ -224,7 +224,7 @@ private void assertReflectionCompareContract(final Object x, final Object y, fin // un-named if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) == 0) { - assertTrue(reflectionCompareSignum(x, z, testTransients, excludeFields) == -reflectionCompareSignum(y, z, testTransients, excludeFields)); + assertEquals(reflectionCompareSignum(x, z, testTransients, excludeFields), -reflectionCompareSignum(y, z, testTransients, excludeFields)); } // strongly recommended but not strictly required @@ -249,7 +249,7 @@ private int reflectionCompareSignum(final Object lhs, final Object rhs, final bo public void testAppendSuper() { final TestObject o1 = new TestObject(4); final TestObject o2 = new TestObject(5); - assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().appendSuper(0).append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().appendSuper(0).append(o2, o1).toComparison() > 0); @@ -264,14 +264,14 @@ public void testAppendSuper() { public void testObject() { final TestObject o1 = new TestObject(4); final TestObject o2 = new TestObject(4); - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(o1, o2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); + assertEquals(0, new CompareToBuilder().append(o1, o2).toComparison()); o2.setA(5); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((Object) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((Object) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, o1).toComparison() < 0); } @@ -301,17 +301,17 @@ public void testObjectEx2() { public void testObjectComparator() { final String o1 = "Fred"; String o2 = "Fred"; - assertTrue(new CompareToBuilder().append(o1, o1, String.CASE_INSENSITIVE_ORDER).toComparison() == 0); - assertTrue(new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1, String.CASE_INSENSITIVE_ORDER).toComparison()); + assertEquals(0, new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison()); o2 = "FRED"; - assertTrue(new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison() == 0); - assertTrue(new CompareToBuilder().append(o2, o1, String.CASE_INSENSITIVE_ORDER).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison()); + assertEquals(0, new CompareToBuilder().append(o2, o1, String.CASE_INSENSITIVE_ORDER).toComparison()); o2 = "FREDA"; assertTrue(new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1, String.CASE_INSENSITIVE_ORDER).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, null, String.CASE_INSENSITIVE_ORDER).toComparison() > 0); - assertTrue(new CompareToBuilder().append(null, null, String.CASE_INSENSITIVE_ORDER).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(null, null, String.CASE_INSENSITIVE_ORDER).toComparison()); assertTrue(new CompareToBuilder().append(null, o1, String.CASE_INSENSITIVE_ORDER).toComparison() < 0); } @@ -319,14 +319,14 @@ public void testObjectComparator() { public void testObjectComparatorNull() { final String o1 = "Fred"; String o2 = "Fred"; - assertTrue(new CompareToBuilder().append(o1, o1, null).toComparison() == 0); - assertTrue(new CompareToBuilder().append(o1, o2, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1, null).toComparison()); + assertEquals(0, new CompareToBuilder().append(o1, o2, null).toComparison()); o2 = "Zebra"; assertTrue(new CompareToBuilder().append(o1, o2, null).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1, null).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, null, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append(null, null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(null, null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, o1, null).toComparison() < 0); } @@ -334,7 +334,7 @@ public void testObjectComparatorNull() { public void testLong() { final long o1 = 1L; final long o2 = 2L; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Long.MAX_VALUE).toComparison() < 0); @@ -347,7 +347,7 @@ public void testLong() { public void testInt() { final int o1 = 1; final int o2 = 2; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Integer.MAX_VALUE).toComparison() < 0); @@ -360,7 +360,7 @@ public void testInt() { public void testShort() { final short o1 = 1; final short o2 = 2; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Short.MAX_VALUE).toComparison() < 0); @@ -373,7 +373,7 @@ public void testShort() { public void testChar() { final char o1 = 1; final char o2 = 2; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Character.MAX_VALUE).toComparison() < 0); @@ -386,7 +386,7 @@ public void testChar() { public void testByte() { final byte o1 = 1; final byte o2 = 2; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Byte.MAX_VALUE).toComparison() < 0); @@ -399,14 +399,14 @@ public void testByte() { public void testDouble() { final double o1 = 1; final double o2 = 2; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Double.MAX_VALUE).toComparison() < 0); assertTrue(new CompareToBuilder().append(Double.MAX_VALUE, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Double.MIN_VALUE).toComparison() > 0); assertTrue(new CompareToBuilder().append(Double.MIN_VALUE, o1).toComparison() < 0); - assertTrue(new CompareToBuilder().append(Double.NaN, Double.NaN).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(Double.NaN, Double.NaN).toComparison()); assertTrue(new CompareToBuilder().append(Double.NaN, Double.MAX_VALUE).toComparison() > 0); assertTrue(new CompareToBuilder().append(Double.POSITIVE_INFINITY, Double.MAX_VALUE).toComparison() > 0); assertTrue(new CompareToBuilder().append(Double.NEGATIVE_INFINITY, Double.MIN_VALUE).toComparison() < 0); @@ -420,14 +420,14 @@ public void testDouble() { public void testFloat() { final float o1 = 1; final float o2 = 2; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Float.MAX_VALUE).toComparison() < 0); assertTrue(new CompareToBuilder().append(Float.MAX_VALUE, o1).toComparison() > 0); assertTrue(new CompareToBuilder().append(o1, Float.MIN_VALUE).toComparison() > 0); assertTrue(new CompareToBuilder().append(Float.MIN_VALUE, o1).toComparison() < 0); - assertTrue(new CompareToBuilder().append(Float.NaN, Float.NaN).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(Float.NaN, Float.NaN).toComparison()); assertTrue(new CompareToBuilder().append(Float.NaN, Float.MAX_VALUE).toComparison() > 0); assertTrue(new CompareToBuilder().append(Float.POSITIVE_INFINITY, Float.MAX_VALUE).toComparison() > 0); assertTrue(new CompareToBuilder().append(Float.NEGATIVE_INFINITY, Float.MIN_VALUE).toComparison() < 0); @@ -441,8 +441,8 @@ public void testFloat() { public void testBoolean() { final boolean o1 = true; final boolean o2 = false; - assertTrue(new CompareToBuilder().append(o1, o1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(o2, o2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(o1, o1).toComparison()); + assertEquals(0, new CompareToBuilder().append(o2, o2).toComparison()); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() > 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() < 0); } @@ -460,8 +460,8 @@ public void testObjectArray() { obj3[1] = new TestObject(5); obj3[2] = new TestObject(6); - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -470,7 +470,7 @@ public void testObjectArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((Object[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((Object[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -487,8 +487,8 @@ public void testLongArray() { obj3[1] = 6L; obj3[2] = 7L; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -497,7 +497,7 @@ public void testLongArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((long[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((long[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -514,8 +514,8 @@ public void testIntArray() { obj3[1] = 6; obj3[2] = 7; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -524,7 +524,7 @@ public void testIntArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((int[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((int[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -541,8 +541,8 @@ public void testShortArray() { obj3[1] = 6; obj3[2] = 7; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -551,7 +551,7 @@ public void testShortArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((short[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((short[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -568,8 +568,8 @@ public void testCharArray() { obj3[1] = 6; obj3[2] = 7; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -578,7 +578,7 @@ public void testCharArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((char[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((char[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -595,8 +595,8 @@ public void testByteArray() { obj3[1] = 6; obj3[2] = 7; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -605,7 +605,7 @@ public void testByteArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((byte[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((byte[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -622,8 +622,8 @@ public void testDoubleArray() { obj3[1] = 6; obj3[2] = 7; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -632,7 +632,7 @@ public void testDoubleArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((double[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((double[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -649,8 +649,8 @@ public void testFloatArray() { obj3[1] = 6; obj3[2] = 7; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -659,7 +659,7 @@ public void testFloatArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((float[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((float[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -676,8 +676,8 @@ public void testBooleanArray() { obj3[1] = false; obj3[2] = true; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -686,7 +686,7 @@ public void testBooleanArray() { assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj1, null).toComparison() > 0); - assertTrue(new CompareToBuilder().append((boolean[]) null, null).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append((boolean[]) null, null).toComparison()); assertTrue(new CompareToBuilder().append(null, obj1).toComparison() < 0); } @@ -705,8 +705,8 @@ public void testMultiLongArray() { array3[1][2] = 100; array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 200; @@ -729,8 +729,8 @@ public void testMultiIntArray() { array3[1][2] = 100; array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 200; @@ -753,8 +753,8 @@ public void testMultiShortArray() { array3[1][2] = 100; array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 200; @@ -777,8 +777,8 @@ public void testMultiCharArray() { array3[1][2] = 100; array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 200; @@ -801,8 +801,8 @@ public void testMultiByteArray() { array3[1][2] = 100; array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 127; @@ -825,8 +825,8 @@ public void testMultiFloatArray() { array3[1][2] = 100; array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 127; @@ -849,8 +849,8 @@ public void testMultiDoubleArray() { array3[1][2] = 100; array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 127; @@ -873,8 +873,8 @@ public void testMultiBooleanArray() { array3[1][2] = false; array3[1][2] = false; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = true; @@ -901,8 +901,8 @@ public void testRaggedArray() { array3[1][2] = 100; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); array1[1][1] = 200; @@ -927,8 +927,8 @@ public void testMixedArray() { } ((long[]) array3[0])[2] = 1; ((long[]) array3[1])[2] = 1; - assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(array1, array1).toComparison()); + assertEquals(0, new CompareToBuilder().append(array1, array2).toComparison()); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); assertTrue(new CompareToBuilder().append(array3, array1).toComparison() > 0); ((long[]) array1[1])[1] = 200; @@ -953,8 +953,8 @@ public void testObjectArrayHiddenByObject() { final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -978,8 +978,8 @@ public void testLongArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -1003,8 +1003,8 @@ public void testIntArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -1028,8 +1028,8 @@ public void testShortArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -1053,8 +1053,8 @@ public void testCharArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -1078,8 +1078,8 @@ public void testByteArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -1103,8 +1103,8 @@ public void testDoubleArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -1128,8 +1128,8 @@ public void testFloatArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); @@ -1153,8 +1153,8 @@ public void testBooleanArrayHiddenByObject() { final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); - assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); + assertEquals(0, new CompareToBuilder().append(obj1, obj1).toComparison()); + assertEquals(0, new CompareToBuilder().append(obj1, obj2).toComparison()); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java index d5b443e54..6fd77825d 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java @@ -20,9 +20,10 @@ import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.commons.lang3.ArrayUtils; import org.hamcrest.Matcher; @@ -333,8 +334,8 @@ public void testObjectsSameAndEqual() { left.objectField = sameObject; final TypeTestClass right = new TypeTestClass(); right.objectField = sameObject; - assertTrue(left.objectField == right.objectField); - assertTrue(left.objectField.equals(right.objectField)); + assertSame(left.objectField, right.objectField); + assertEquals(left.objectField, right.objectField); final DiffResult list = left.diff(right); assertEquals(0, list.getNumberOfDiffs()); @@ -349,8 +350,8 @@ public void testObjectsNotSameButEqual() { left.objectField = new Integer(1); final TypeTestClass right = new TypeTestClass(); right.objectField = new Integer(1); - assertFalse(left.objectField == right.objectField); - assertTrue(left.objectField.equals(right.objectField)); + assertNotSame(left.objectField, right.objectField); + assertEquals(left.objectField, right.objectField); final DiffResult list = left.diff(right); assertEquals(0, list.getNumberOfDiffs()); @@ -365,8 +366,8 @@ public void testObjectsNotSameNorEqual() { left.objectField = 4; final TypeTestClass right = new TypeTestClass(); right.objectField = 100; - assertFalse(left.objectField == right.objectField); - assertFalse(left.objectField.equals(right.objectField)); + assertNotSame(left.objectField, right.objectField); + assertNotEquals(left.objectField, right.objectField); final DiffResult list = left.diff(right); assertEquals(1, list.getNumberOfDiffs()); diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java index 3e5a4ae21..e32145264 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java @@ -99,7 +99,7 @@ public void testToStringOutput() { @Test public void testToStringSpecifyStyleOutput() { final DiffResult list = SIMPLE_FALSE.diff(SIMPLE_TRUE); - assertTrue(list.getToStringStyle().equals(SHORT_STYLE)); + assertEquals(list.getToStringStyle(), SHORT_STYLE); final String lhsString = new ToStringBuilder(SIMPLE_FALSE, ToStringStyle.MULTI_LINE_STYLE).append( diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java index dd725edf4..64bd28346 100644 --- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java @@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -1198,10 +1199,10 @@ public void testUnrelatedClasses() { assertTrue(Arrays.equals(x, y)); assertTrue(Arrays.equals(y, x)); // real tests: - assertTrue(x[0].equals(x[0])); - assertTrue(y[0].equals(y[0])); - assertTrue(x[0].equals(y[0])); - assertTrue(y[0].equals(x[0])); + assertEquals(x[0], x[0]); + assertEquals(y[0], y[0]); + assertEquals(x[0], y[0]); + assertEquals(y[0], x[0]); assertTrue(new EqualsBuilder().append(x, x).isEquals()); assertTrue(new EqualsBuilder().append(y, y).isEquals()); assertTrue(new EqualsBuilder().append(x, y).isEquals()); @@ -1282,11 +1283,11 @@ public void testCyclicalObjectReferences() { x3.setObjectReference(refX3); refX3.setObjectReference(x3); - assertTrue(x1.equals(x2)); + assertEquals(x1, x2); assertNull(EqualsBuilder.getRegistry()); - assertFalse(x1.equals(x3)); + assertNotEquals(x1, x3); assertNull(EqualsBuilder.getRegistry()); - assertFalse(x2.equals(x3)); + assertNotEquals(x2, x3); assertNull(EqualsBuilder.getRegistry()); } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java b/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java index 9d481f5d2..6cc083f9e 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java @@ -175,7 +175,7 @@ private void checkDaemonFlag(final boolean flag) { final BasicThreadFactory factory = builder.wrappedFactory(wrapped).daemon( flag).build(); assertSame(t, factory.newThread(r), "Wrong thread"); - assertTrue(flag == t.isDaemon(), "Wrong daemon flag"); + assertEquals(flag, t.isDaemon(), "Wrong daemon flag"); EasyMock.verify(wrapped, r); } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java index 7e7055a27..59164e752 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/ConstantInitializerTest.java @@ -46,9 +46,9 @@ public void setUp() { * @param expected the expected result */ private void checkEquals(final Object obj, final boolean expected) { - assertTrue(expected == init.equals(obj), "Wrong result of equals"); + assertEquals(expected, init.equals(obj), "Wrong result of equals"); if (obj != null) { - assertTrue(expected == obj.equals(init), "Not symmetric"); + assertEquals(expected, obj.equals(init), "Not symmetric"); if (expected) { assertEquals(init.hashCode(), obj.hashCode(), "Different hash codes"); } diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java index b9808d4e1..81b367360 100644 --- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.Serializable; @@ -72,8 +73,8 @@ public void testAddContextValue() { assertTrue(message.contains("some value")); assertTrue(message.contains("5")); - assertTrue(exceptionContext.getFirstContextValue("test1") == null); - assertTrue(exceptionContext.getFirstContextValue("test2").equals("some value")); + assertNull(exceptionContext.getFirstContextValue("test1")); + assertEquals("some value", exceptionContext.getFirstContextValue("test2")); assertEquals(5, exceptionContext.getContextLabels().size()); assertTrue(exceptionContext.getContextLabels().contains("test1")); @@ -99,7 +100,7 @@ public void testSetContextValue() { assertTrue(message.contains("test Poorly written obj")); assertTrue(message.contains("Crap")); - assertTrue(exceptionContext.getFirstContextValue("crap") == null); + assertNull(exceptionContext.getFirstContextValue("crap")); assertTrue(exceptionContext.getFirstContextValue("test Poorly written obj") instanceof ObjectWithFaultyToString); assertEquals(7, exceptionContext.getContextEntries().size()); @@ -126,13 +127,13 @@ public void testSetContextValue() { public void testGetFirstContextValue() { exceptionContext.addContextValue("test2", "different value"); - assertTrue(exceptionContext.getFirstContextValue("test1") == null); - assertTrue(exceptionContext.getFirstContextValue("test2").equals("some value")); - assertTrue(exceptionContext.getFirstContextValue("crap") == null); + assertNull(exceptionContext.getFirstContextValue("test1")); + assertEquals("some value", exceptionContext.getFirstContextValue("test2")); + assertNull(exceptionContext.getFirstContextValue("crap")); exceptionContext.setContextValue("test2", "another"); - assertTrue(exceptionContext.getFirstContextValue("test2").equals("another")); + assertEquals("another", exceptionContext.getFirstContextValue("test2")); } @Test @@ -144,7 +145,7 @@ public void testGetContextValues() { exceptionContext.setContextValue("test2", "another"); - assertTrue(exceptionContext.getFirstContextValue("test2").equals("another")); + assertEquals("another", exceptionContext.getFirstContextValue("test2")); } @Test diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java index 199e09e3c..27b70323a 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java @@ -17,6 +17,7 @@ package org.apache.commons.lang3.exception; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -98,7 +99,7 @@ public void testNullExceptionPassing() { .addContextValue("test Poorly written obj", new ObjectWithFaultyToString()); final String message = exceptionContext.getMessage(); - assertTrue(message != null); + assertNotNull(message); } @Test diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java index 2794b76f3..16d36bf67 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java @@ -17,6 +17,7 @@ package org.apache.commons.lang3.exception; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -100,7 +101,7 @@ public void testNullExceptionPassing() { .addContextValue("test Poorly written obj", new ObjectWithFaultyToString()); final String message = exceptionContext.getMessage(); - assertTrue(message != null); + assertNotNull(message); } @Test diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java b/src/test/java/org/apache/commons/lang3/math/FractionTest.java index 416c16bc9..59a17b9dd 100644 --- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java +++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java @@ -19,7 +19,7 @@ package org.apache.commons.lang3.math; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -621,7 +621,7 @@ public void testPow() { f = Fraction.getFraction(6, 10); assertEquals(f, f.pow(1)); - assertFalse(f.pow(1).equals(Fraction.getFraction(3,5))); + assertNotEquals(f.pow(1), Fraction.getFraction(3, 5)); f = Fraction.getFraction(6, 10); f = f.pow(2); @@ -646,11 +646,11 @@ public void testPow() { // zero to any positive power is still zero. f = Fraction.getFraction(0, 1231); f = f.pow(1); - assertTrue(0==f.compareTo(Fraction.ZERO)); + assertEquals(0, f.compareTo(Fraction.ZERO)); assertEquals(0, f.getNumerator()); assertEquals(1231, f.getDenominator()); f = f.pow(2); - assertTrue(0==f.compareTo(Fraction.ZERO)); + assertEquals(0, f.compareTo(Fraction.ZERO)); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); @@ -994,21 +994,21 @@ public void testEquals() { Fraction f2 = null; f1 = Fraction.getFraction(3, 5); - assertFalse(f1.equals(null)); - assertFalse(f1.equals(new Object())); - assertFalse(f1.equals(Integer.valueOf(6))); + assertNotEquals(null, f1); + assertNotEquals(f1, new Object()); + assertNotEquals(f1, Integer.valueOf(6)); f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); - assertFalse(f1.equals(f2)); - assertTrue(f1.equals(f1)); - assertTrue(f2.equals(f2)); + assertNotEquals(f1, f2); + assertEquals(f1, f1); + assertEquals(f2, f2); f2 = Fraction.getFraction(3, 5); - assertTrue(f1.equals(f2)); + assertEquals(f1, f2); f2 = Fraction.getFraction(6, 10); - assertFalse(f1.equals(f2)); + assertNotEquals(f1, f2); } @Test @@ -1016,7 +1016,7 @@ public void testHashCode() { final Fraction f1 = Fraction.getFraction(3, 5); Fraction f2 = Fraction.getFraction(3, 5); - assertTrue(f1.hashCode() == f2.hashCode()); + assertEquals(f1.hashCode(), f2.hashCode()); f2 = Fraction.getFraction(2, 5); assertTrue(f1.hashCode() != f2.hashCode()); @@ -1031,30 +1031,30 @@ public void testCompareTo() { Fraction f2 = null; f1 = Fraction.getFraction(3, 5); - assertTrue(f1.compareTo(f1) == 0); + assertEquals(0, f1.compareTo(f1)); final Fraction fr = f1; assertThrows(NullPointerException.class, () -> fr.compareTo(null)); f2 = Fraction.getFraction(2, 5); assertTrue(f1.compareTo(f2) > 0); - assertTrue(f2.compareTo(f2) == 0); + assertEquals(0, f2.compareTo(f2)); f2 = Fraction.getFraction(4, 5); assertTrue(f1.compareTo(f2) < 0); - assertTrue(f2.compareTo(f2) == 0); + assertEquals(0, f2.compareTo(f2)); f2 = Fraction.getFraction(3, 5); - assertTrue(f1.compareTo(f2) == 0); - assertTrue(f2.compareTo(f2) == 0); + assertEquals(0, f1.compareTo(f2)); + assertEquals(0, f2.compareTo(f2)); f2 = Fraction.getFraction(6, 10); - assertTrue(f1.compareTo(f2) == 0); - assertTrue(f2.compareTo(f2) == 0); + assertEquals(0, f1.compareTo(f2)); + assertEquals(0, f2.compareTo(f2)); f2 = Fraction.getFraction(-1, 1, Integer.MAX_VALUE); assertTrue(f1.compareTo(f2) > 0); - assertTrue(f2.compareTo(f2) == 0); + assertEquals(0, f2.compareTo(f2)); } diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java index a819c3da6..58569d0fe 100644 --- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -53,10 +54,10 @@ public void testConstructor() { */ @Test public void testToIntString() { - assertTrue(NumberUtils.toInt("12345") == 12345, "toInt(String) 1 failed"); - assertTrue(NumberUtils.toInt("abc") == 0, "toInt(String) 2 failed"); - assertTrue(NumberUtils.toInt("") == 0, "toInt(empty) failed"); - assertTrue(NumberUtils.toInt(null) == 0, "toInt(null) failed"); + assertEquals(12345, NumberUtils.toInt("12345"), "toInt(String) 1 failed"); + assertEquals(0, NumberUtils.toInt("abc"), "toInt(String) 2 failed"); + assertEquals(0, NumberUtils.toInt(""), "toInt(empty) failed"); + assertEquals(0, NumberUtils.toInt(null), "toInt(null) failed"); } /** @@ -64,8 +65,8 @@ public void testToIntString() { */ @Test public void testToIntStringI() { - assertTrue(NumberUtils.toInt("12345", 5) == 12345, "toInt(String,int) 1 failed"); - assertTrue(NumberUtils.toInt("1234.5", 5) == 5, "toInt(String,int) 2 failed"); + assertEquals(12345, NumberUtils.toInt("12345", 5), "toInt(String,int) 1 failed"); + assertEquals(5, NumberUtils.toInt("1234.5", 5), "toInt(String,int) 2 failed"); } /** @@ -73,14 +74,14 @@ public void testToIntStringI() { */ @Test public void testToLongString() { - assertTrue(NumberUtils.toLong("12345") == 12345L, "toLong(String) 1 failed"); - assertTrue(NumberUtils.toLong("abc") == 0L, "toLong(String) 2 failed"); - assertTrue(NumberUtils.toLong("1L") == 0L, "toLong(String) 3 failed"); - assertTrue(NumberUtils.toLong("1l") == 0L, "toLong(String) 4 failed"); - assertTrue(NumberUtils.toLong(Long.MAX_VALUE+"") == Long.MAX_VALUE, "toLong(Long.MAX_VALUE) failed"); - assertTrue(NumberUtils.toLong(Long.MIN_VALUE+"") == Long.MIN_VALUE, "toLong(Long.MIN_VALUE) failed"); - assertTrue(NumberUtils.toLong("") == 0L, "toLong(empty) failed"); - assertTrue(NumberUtils.toLong(null) == 0L, "toLong(null) failed"); + assertEquals(12345L, NumberUtils.toLong("12345"), "toLong(String) 1 failed"); + assertEquals(0L, NumberUtils.toLong("abc"), "toLong(String) 2 failed"); + assertEquals(0L, NumberUtils.toLong("1L"), "toLong(String) 3 failed"); + assertEquals(0L, NumberUtils.toLong("1l"), "toLong(String) 4 failed"); + assertEquals(NumberUtils.toLong(Long.MAX_VALUE + ""), Long.MAX_VALUE, "toLong(Long.MAX_VALUE) failed"); + assertEquals(NumberUtils.toLong(Long.MIN_VALUE + ""), Long.MIN_VALUE, "toLong(Long.MIN_VALUE) failed"); + assertEquals(0L, NumberUtils.toLong(""), "toLong(empty) failed"); + assertEquals(0L, NumberUtils.toLong(null), "toLong(null) failed"); } /** @@ -88,8 +89,8 @@ public void testToLongString() { */ @Test public void testToLongStringL() { - assertTrue(NumberUtils.toLong("12345", 5L) == 12345L, "toLong(String,long) 1 failed"); - assertTrue(NumberUtils.toLong("1234.5", 5L) == 5L, "toLong(String,long) 2 failed"); + assertEquals(12345L, NumberUtils.toLong("12345", 5L), "toLong(String,long) 1 failed"); + assertEquals(5L, NumberUtils.toLong("1234.5", 5L), "toLong(String,long) 2 failed"); } /** @@ -204,10 +205,10 @@ public void testBigIntegerToDoubleBigIntegerD() { */ @Test public void testToByteString() { - assertTrue(NumberUtils.toByte("123") == 123, "toByte(String) 1 failed"); - assertTrue(NumberUtils.toByte("abc") == 0, "toByte(String) 2 failed"); - assertTrue(NumberUtils.toByte("") == 0, "toByte(empty) failed"); - assertTrue(NumberUtils.toByte(null) == 0, "toByte(null) failed"); + assertEquals(123, NumberUtils.toByte("123"), "toByte(String) 1 failed"); + assertEquals(0, NumberUtils.toByte("abc"), "toByte(String) 2 failed"); + assertEquals(0, NumberUtils.toByte(""), "toByte(empty) failed"); + assertEquals(0, NumberUtils.toByte(null), "toByte(null) failed"); } /** @@ -215,8 +216,8 @@ public void testToByteString() { */ @Test public void testToByteStringI() { - assertTrue(NumberUtils.toByte("123", (byte) 5) == 123, "toByte(String,byte) 1 failed"); - assertTrue(NumberUtils.toByte("12.3", (byte) 5) == 5, "toByte(String,byte) 2 failed"); + assertEquals(123, NumberUtils.toByte("123", (byte) 5), "toByte(String,byte) 1 failed"); + assertEquals(5, NumberUtils.toByte("12.3", (byte) 5), "toByte(String,byte) 2 failed"); } /** @@ -224,10 +225,10 @@ public void testToByteStringI() { */ @Test public void testToShortString() { - assertTrue(NumberUtils.toShort("12345") == 12345, "toShort(String) 1 failed"); - assertTrue(NumberUtils.toShort("abc") == 0, "toShort(String) 2 failed"); - assertTrue(NumberUtils.toShort("") == 0, "toShort(empty) failed"); - assertTrue(NumberUtils.toShort(null) == 0, "toShort(null) failed"); + assertEquals(12345, NumberUtils.toShort("12345"), "toShort(String) 1 failed"); + assertEquals(0, NumberUtils.toShort("abc"), "toShort(String) 2 failed"); + assertEquals(0, NumberUtils.toShort(""), "toShort(empty) failed"); + assertEquals(0, NumberUtils.toShort(null), "toShort(null) failed"); } /** @@ -235,8 +236,8 @@ public void testToShortString() { */ @Test public void testToShortStringI() { - assertTrue(NumberUtils.toShort("12345", (short) 5) == 12345, "toShort(String,short) 1 failed"); - assertTrue(NumberUtils.toShort("1234.5", (short) 5) == 5, "toShort(String,short) 2 failed"); + assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String,short) 1 failed"); + assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String,short) 2 failed"); } /** @@ -244,19 +245,13 @@ public void testToShortStringI() { */ @Test public void testToScaledBigDecimalBigDecimal() { - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(123.456)).equals(BigDecimal.valueOf(123.46)), - "toScaledBigDecimal(BigDecimal) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(123.456)), BigDecimal.valueOf(123.46), "toScaledBigDecimal(BigDecimal) 1 failed"); // Test RoudingMode.HALF_EVEN default rounding. - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.515)).equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(BigDecimal) 2 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.525)).equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(BigDecimal) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.525)) - .multiply(BigDecimal.valueOf(100)).toString() - .equals("2352.00"), - "toScaledBigDecimal(BigDecimal) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((BigDecimal) null).equals(BigDecimal.ZERO), - "toScaledBigDecimal(BigDecimal) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.515)), BigDecimal.valueOf(23.52), "toScaledBigDecimal(BigDecimal) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.525)), BigDecimal.valueOf(23.52), "toScaledBigDecimal(BigDecimal) 3 failed"); + assertEquals("2352.00", NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.525)) + .multiply(BigDecimal.valueOf(100)).toString(), "toScaledBigDecimal(BigDecimal) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((BigDecimal) null), BigDecimal.ZERO, "toScaledBigDecimal(BigDecimal) 5 failed"); } /** @@ -264,19 +259,13 @@ public void testToScaledBigDecimalBigDecimal() { */ @Test public void testToScaledBigDecimalBigDecimalIRM() { - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(123.456), 1, RoundingMode.CEILING).equals(BigDecimal.valueOf(123.5)), - "toScaledBigDecimal(BigDecimal, int, RoudingMode) 1 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.5159), 3, RoundingMode.FLOOR).equals(BigDecimal.valueOf(23.515)), - "toScaledBigDecimal(BigDecimal, int, RoudingMode) 2 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.525), 2, RoundingMode.HALF_UP).equals(BigDecimal.valueOf(23.53)), - "toScaledBigDecimal(BigDecimal, int, RoudingMode) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.521), 4, RoundingMode.HALF_EVEN) - .multiply(BigDecimal.valueOf(1000)) - .toString() - .equals("23521.0000"), - "toScaledBigDecimal(BigDecimal, int, RoudingMode) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((BigDecimal) null, 2, RoundingMode.HALF_UP).equals(BigDecimal.ZERO), - "toScaledBigDecimal(BigDecimal, int, RoudingMode) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(123.456), 1, RoundingMode.CEILING), BigDecimal.valueOf(123.5), "toScaledBigDecimal(BigDecimal, int, RoudingMode) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.5159), 3, RoundingMode.FLOOR), BigDecimal.valueOf(23.515), "toScaledBigDecimal(BigDecimal, int, RoudingMode) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.525), 2, RoundingMode.HALF_UP), BigDecimal.valueOf(23.53), "toScaledBigDecimal(BigDecimal, int, RoudingMode) 3 failed"); + assertEquals("23521.0000", NumberUtils.toScaledBigDecimal(BigDecimal.valueOf(23.521), 4, RoundingMode.HALF_EVEN) + .multiply(BigDecimal.valueOf(1000)) + .toString(), "toScaledBigDecimal(BigDecimal, int, RoudingMode) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((BigDecimal) null, 2, RoundingMode.HALF_UP), BigDecimal.ZERO, "toScaledBigDecimal(BigDecimal, int, RoudingMode) 5 failed"); } /** @@ -284,21 +273,15 @@ public void testToScaledBigDecimalBigDecimalIRM() { */ @Test public void testToScaledBigDecimalFloat() { - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(123.456f)).equals(BigDecimal.valueOf(123.46)), - "toScaledBigDecimal(Float) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Float.valueOf(123.456f)), BigDecimal.valueOf(123.46), "toScaledBigDecimal(Float) 1 failed"); // Test RoudingMode.HALF_EVEN default rounding. - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(23.515f)).equals(BigDecimal.valueOf(23.51)), - "toScaledBigDecimal(Float) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Float.valueOf(23.515f)), BigDecimal.valueOf(23.51), "toScaledBigDecimal(Float) 2 failed"); // Note. NumberUtils.toScaledBigDecimal(Float.valueOf(23.515f)).equals(BigDecimal.valueOf(23.51)) // because of roundoff error. It is ok. - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(23.525f)).equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(Float) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(23.525f)) - .multiply(BigDecimal.valueOf(100)).toString() - .equals("2352.00"), - "toScaledBigDecimal(Float) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((Float) null).equals(BigDecimal.ZERO), - "toScaledBigDecimal(Float) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Float.valueOf(23.525f)), BigDecimal.valueOf(23.52), "toScaledBigDecimal(Float) 3 failed"); + assertEquals("2352.00", NumberUtils.toScaledBigDecimal(Float.valueOf(23.525f)) + .multiply(BigDecimal.valueOf(100)).toString(), "toScaledBigDecimal(Float) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((Float) null), BigDecimal.ZERO, "toScaledBigDecimal(Float) 5 failed"); } /** @@ -306,20 +289,14 @@ public void testToScaledBigDecimalFloat() { */ @Test public void testToScaledBigDecimalFloatIRM() { - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(123.456f), 1, RoundingMode.CEILING).equals(BigDecimal.valueOf(123.5)), - "toScaledBigDecimal(Float, int, RoudingMode) 1 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(23.5159f), 3, RoundingMode.FLOOR).equals(BigDecimal.valueOf(23.515)), - "toScaledBigDecimal(Float, int, RoudingMode) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Float.valueOf(123.456f), 1, RoundingMode.CEILING), BigDecimal.valueOf(123.5), "toScaledBigDecimal(Float, int, RoudingMode) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Float.valueOf(23.5159f), 3, RoundingMode.FLOOR), BigDecimal.valueOf(23.515), "toScaledBigDecimal(Float, int, RoudingMode) 2 failed"); // The following happens due to roundoff error. We're ok with this. - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(23.525f), 2, RoundingMode.HALF_UP).equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(Float, int, RoudingMode) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Float.valueOf(23.521f), 4, RoundingMode.HALF_EVEN) - .multiply(BigDecimal.valueOf(1000)) - .toString() - .equals("23521.0000"), - "toScaledBigDecimal(Float, int, RoudingMode) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((Float) null, 2, RoundingMode.HALF_UP).equals(BigDecimal.ZERO), - "toScaledBigDecimal(Float, int, RoudingMode) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Float.valueOf(23.525f), 2, RoundingMode.HALF_UP), BigDecimal.valueOf(23.52), "toScaledBigDecimal(Float, int, RoudingMode) 3 failed"); + assertEquals("23521.0000", NumberUtils.toScaledBigDecimal(Float.valueOf(23.521f), 4, RoundingMode.HALF_EVEN) + .multiply(BigDecimal.valueOf(1000)) + .toString(), "toScaledBigDecimal(Float, int, RoudingMode) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((Float) null, 2, RoundingMode.HALF_UP), BigDecimal.ZERO, "toScaledBigDecimal(Float, int, RoudingMode) 5 failed"); } /** @@ -327,19 +304,13 @@ public void testToScaledBigDecimalFloatIRM() { */ @Test public void testToScaledBigDecimalDouble() { - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(123.456d)).equals(BigDecimal.valueOf(123.46)), - "toScaledBigDecimal(Double) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Double.valueOf(123.456d)), BigDecimal.valueOf(123.46), "toScaledBigDecimal(Double) 1 failed"); // Test RoudingMode.HALF_EVEN default rounding. - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(23.515d)).equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(Double) 2 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(23.525d)).equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(Double) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(23.525d)) - .multiply(BigDecimal.valueOf(100)).toString() - .equals("2352.00"), - "toScaledBigDecimal(Double) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((Double) null).equals(BigDecimal.ZERO), - "toScaledBigDecimal(Double) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Double.valueOf(23.515d)), BigDecimal.valueOf(23.52), "toScaledBigDecimal(Double) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Double.valueOf(23.525d)), BigDecimal.valueOf(23.52), "toScaledBigDecimal(Double) 3 failed"); + assertEquals("2352.00", NumberUtils.toScaledBigDecimal(Double.valueOf(23.525d)) + .multiply(BigDecimal.valueOf(100)).toString(), "toScaledBigDecimal(Double) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((Double) null), BigDecimal.ZERO, "toScaledBigDecimal(Double) 5 failed"); } /** @@ -347,19 +318,13 @@ public void testToScaledBigDecimalDouble() { */ @Test public void testToScaledBigDecimalDoubleIRM() { - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(123.456d), 1, RoundingMode.CEILING).equals(BigDecimal.valueOf(123.5)), - "toScaledBigDecimal(Double, int, RoudingMode) 1 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(23.5159d), 3, RoundingMode.FLOOR).equals(BigDecimal.valueOf(23.515)), - "toScaledBigDecimal(Double, int, RoudingMode) 2 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(23.525d), 2, RoundingMode.HALF_UP).equals(BigDecimal.valueOf(23.53)), - "toScaledBigDecimal(Double, int, RoudingMode) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal(Double.valueOf(23.521d), 4, RoundingMode.HALF_EVEN) - .multiply(BigDecimal.valueOf(1000)) - .toString() - .equals("23521.0000"), - "toScaledBigDecimal(Double, int, RoudingMode) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((Double) null, 2, RoundingMode.HALF_UP).equals(BigDecimal.ZERO), - "toScaledBigDecimal(Double, int, RoudingMode) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Double.valueOf(123.456d), 1, RoundingMode.CEILING), BigDecimal.valueOf(123.5), "toScaledBigDecimal(Double, int, RoudingMode) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Double.valueOf(23.5159d), 3, RoundingMode.FLOOR), BigDecimal.valueOf(23.515), "toScaledBigDecimal(Double, int, RoudingMode) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal(Double.valueOf(23.525d), 2, RoundingMode.HALF_UP), BigDecimal.valueOf(23.53), "toScaledBigDecimal(Double, int, RoudingMode) 3 failed"); + assertEquals("23521.0000", NumberUtils.toScaledBigDecimal(Double.valueOf(23.521d), 4, RoundingMode.HALF_EVEN) + .multiply(BigDecimal.valueOf(1000)) + .toString(), "toScaledBigDecimal(Double, int, RoudingMode) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((Double) null, 2, RoundingMode.HALF_UP), BigDecimal.ZERO, "toScaledBigDecimal(Double, int, RoudingMode) 5 failed"); } /** @@ -367,19 +332,13 @@ public void testToScaledBigDecimalDoubleIRM() { */ @Test public void testToScaledBigDecimalString() { - assertTrue(NumberUtils.toScaledBigDecimal("123.456").equals(BigDecimal.valueOf(123.46)), - "toScaledBigDecimal(String) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal("123.456"), BigDecimal.valueOf(123.46), "toScaledBigDecimal(String) 1 failed"); // Test RoudingMode.HALF_EVEN default rounding. - assertTrue(NumberUtils.toScaledBigDecimal("23.515").equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(String) 2 failed"); - assertTrue(NumberUtils.toScaledBigDecimal("23.525").equals(BigDecimal.valueOf(23.52)), - "toScaledBigDecimal(String) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal("23.525") - .multiply(BigDecimal.valueOf(100)).toString() - .equals("2352.00"), - "toScaledBigDecimal(String) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((String) null).equals(BigDecimal.ZERO), - "toScaledBigDecimal(String) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal("23.515"), BigDecimal.valueOf(23.52), "toScaledBigDecimal(String) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal("23.525"), BigDecimal.valueOf(23.52), "toScaledBigDecimal(String) 3 failed"); + assertEquals("2352.00", NumberUtils.toScaledBigDecimal("23.525") + .multiply(BigDecimal.valueOf(100)).toString(), "toScaledBigDecimal(String) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((String) null), BigDecimal.ZERO, "toScaledBigDecimal(String) 5 failed"); } /** @@ -387,19 +346,13 @@ public void testToScaledBigDecimalString() { */ @Test public void testToScaledBigDecimalStringIRM() { - assertTrue(NumberUtils.toScaledBigDecimal("123.456", 1, RoundingMode.CEILING).equals(BigDecimal.valueOf(123.5)), - "toScaledBigDecimal(String, int, RoudingMode) 1 failed"); - assertTrue(NumberUtils.toScaledBigDecimal("23.5159", 3, RoundingMode.FLOOR).equals(BigDecimal.valueOf(23.515)), - "toScaledBigDecimal(String, int, RoudingMode) 2 failed"); - assertTrue(NumberUtils.toScaledBigDecimal("23.525", 2, RoundingMode.HALF_UP).equals(BigDecimal.valueOf(23.53)), - "toScaledBigDecimal(String, int, RoudingMode) 3 failed"); - assertTrue(NumberUtils.toScaledBigDecimal("23.521", 4, RoundingMode.HALF_EVEN) - .multiply(BigDecimal.valueOf(1000)) - .toString() - .equals("23521.0000"), - "toScaledBigDecimal(String, int, RoudingMode) 4 failed"); - assertTrue(NumberUtils.toScaledBigDecimal((String) null, 2, RoundingMode.HALF_UP).equals(BigDecimal.ZERO), - "toScaledBigDecimal(String, int, RoudingMode) 5 failed"); + assertEquals(NumberUtils.toScaledBigDecimal("123.456", 1, RoundingMode.CEILING), BigDecimal.valueOf(123.5), "toScaledBigDecimal(String, int, RoudingMode) 1 failed"); + assertEquals(NumberUtils.toScaledBigDecimal("23.5159", 3, RoundingMode.FLOOR), BigDecimal.valueOf(23.515), "toScaledBigDecimal(String, int, RoudingMode) 2 failed"); + assertEquals(NumberUtils.toScaledBigDecimal("23.525", 2, RoundingMode.HALF_UP), BigDecimal.valueOf(23.53), "toScaledBigDecimal(String, int, RoudingMode) 3 failed"); + assertEquals("23521.0000", NumberUtils.toScaledBigDecimal("23.521", 4, RoundingMode.HALF_EVEN) + .multiply(BigDecimal.valueOf(1000)) + .toString(), "toScaledBigDecimal(String, int, RoudingMode) 4 failed"); + assertEquals(NumberUtils.toScaledBigDecimal((String) null, 2, RoundingMode.HALF_UP), BigDecimal.ZERO, "toScaledBigDecimal(String, int, RoudingMode) 5 failed"); } @Test @@ -417,15 +370,15 @@ public void testCreateNumber() { assertEquals(Long.valueOf(12345), NumberUtils.createNumber("12345l"), "createNumber(String) 6 failed"); assertEquals(Float.valueOf("-1234.5"), NumberUtils.createNumber("-1234.5"), "createNumber(String) 7 failed"); assertEquals(Integer.valueOf("-12345"), NumberUtils.createNumber("-12345"), "createNumber(String) 8 failed"); - assertTrue(0xFADE == NumberUtils.createNumber("0xFADE").intValue(), "createNumber(String) 9a failed"); - assertTrue(0xFADE == NumberUtils.createNumber("0Xfade").intValue(), "createNumber(String) 9b failed"); - assertTrue(-0xFADE == NumberUtils.createNumber("-0xFADE").intValue(), "createNumber(String) 10a failed"); - assertTrue(-0xFADE == NumberUtils.createNumber("-0Xfade").intValue(), "createNumber(String) 10b failed"); + assertEquals(0xFADE, NumberUtils.createNumber("0xFADE").intValue(), "createNumber(String) 9a failed"); + assertEquals(0xFADE, NumberUtils.createNumber("0Xfade").intValue(), "createNumber(String) 9b failed"); + assertEquals(-0xFADE, NumberUtils.createNumber("-0xFADE").intValue(), "createNumber(String) 10a failed"); + assertEquals(-0xFADE, NumberUtils.createNumber("-0Xfade").intValue(), "createNumber(String) 10b failed"); assertEquals(Double.valueOf("1.1E200"), NumberUtils.createNumber("1.1E200"), "createNumber(String) 11 failed"); assertEquals(Float.valueOf("1.1E20"), NumberUtils.createNumber("1.1E20"), "createNumber(String) 12 failed"); assertEquals(Double.valueOf("-1.1E200"), NumberUtils.createNumber("-1.1E200"), "createNumber(String) 13 failed"); assertEquals(Double.valueOf("1.1E-200"), NumberUtils.createNumber("1.1E-200"), "createNumber(String) 14 failed"); - assertEquals(null, NumberUtils.createNumber(null), "createNumber(null) failed"); + assertNull(NumberUtils.createNumber(null), "createNumber(null) failed"); assertEquals(new BigInteger("12345678901234567890"), NumberUtils.createNumber("12345678901234567890L"), "createNumber(String) failed"); assertEquals(new BigDecimal("1.1E-700"), NumberUtils.createNumber("1.1E-700F"), "createNumber(String) 15 failed"); @@ -606,7 +559,7 @@ public void testCreateNumberMagnitude() { @Test public void testCreateFloat() { assertEquals(Float.valueOf("1234.5"), NumberUtils.createFloat("1234.5"), "createFloat(String) failed"); - assertEquals(null, NumberUtils.createFloat(null), "createFloat(null) failed"); + assertNull(NumberUtils.createFloat(null), "createFloat(null) failed"); this.testCreateFloatFailure(""); this.testCreateFloatFailure(" "); this.testCreateFloatFailure("\b\t\n\f\r"); @@ -623,7 +576,7 @@ protected void testCreateFloatFailure(final String str) { @Test public void testCreateDouble() { assertEquals(Double.valueOf("1234.5"), NumberUtils.createDouble("1234.5"), "createDouble(String) failed"); - assertEquals(null, NumberUtils.createDouble(null), "createDouble(null) failed"); + assertNull(NumberUtils.createDouble(null), "createDouble(null) failed"); this.testCreateDoubleFailure(""); this.testCreateDoubleFailure(" "); this.testCreateDoubleFailure("\b\t\n\f\r"); @@ -641,7 +594,7 @@ protected void testCreateDoubleFailure(final String str) { @Test public void testCreateInteger() { assertEquals(Integer.valueOf("12345"), NumberUtils.createInteger("12345"), "createInteger(String) failed"); - assertEquals(null, NumberUtils.createInteger(null), "createInteger(null) failed"); + assertNull(NumberUtils.createInteger(null), "createInteger(null) failed"); this.testCreateIntegerFailure(""); this.testCreateIntegerFailure(" "); this.testCreateIntegerFailure("\b\t\n\f\r"); @@ -659,7 +612,7 @@ protected void testCreateIntegerFailure(final String str) { @Test public void testCreateLong() { assertEquals(Long.valueOf("12345"), NumberUtils.createLong("12345"), "createLong(String) failed"); - assertEquals(null, NumberUtils.createLong(null), "createLong(null) failed"); + assertNull(NumberUtils.createLong(null), "createLong(null) failed"); this.testCreateLongFailure(""); this.testCreateLongFailure(" "); this.testCreateLongFailure("\b\t\n\f\r"); @@ -677,7 +630,7 @@ protected void testCreateLongFailure(final String str) { @Test public void testCreateBigInteger() { assertEquals(new BigInteger("12345"), NumberUtils.createBigInteger("12345"), "createBigInteger(String) failed"); - assertEquals(null, NumberUtils.createBigInteger(null), "createBigInteger(null) failed"); + assertNull(NumberUtils.createBigInteger(null), "createBigInteger(null) failed"); this.testCreateBigIntegerFailure(""); this.testCreateBigIntegerFailure(" "); this.testCreateBigIntegerFailure("\b\t\n\f\r"); @@ -708,7 +661,7 @@ protected void testCreateBigIntegerFailure(final String str) { @Test public void testCreateBigDecimal() { assertEquals(new BigDecimal("1234.5"), NumberUtils.createBigDecimal("1234.5"), "createBigDecimal(String) failed"); - assertEquals(null, NumberUtils.createBigDecimal(null), "createBigDecimal(null) failed"); + assertNull(NumberUtils.createBigDecimal(null), "createBigDecimal(null) failed"); this.testCreateBigDecimalFailure(""); this.testCreateBigDecimalFailure(" "); this.testCreateBigDecimalFailure("\b\t\n\f\r"); @@ -1111,188 +1064,188 @@ public void testMaximumFloat() { // Testing JDK against old Lang functionality @Test public void testCompareDouble() { - assertTrue(Double.compare(Double.NaN, Double.NaN) == 0); - assertTrue(Double.compare(Double.NaN, Double.POSITIVE_INFINITY) == +1); - assertTrue(Double.compare(Double.NaN, Double.MAX_VALUE) == +1); - assertTrue(Double.compare(Double.NaN, 1.2d) == +1); - assertTrue(Double.compare(Double.NaN, 0.0d) == +1); - assertTrue(Double.compare(Double.NaN, -0.0d) == +1); - assertTrue(Double.compare(Double.NaN, -1.2d) == +1); - assertTrue(Double.compare(Double.NaN, -Double.MAX_VALUE) == +1); - assertTrue(Double.compare(Double.NaN, Double.NEGATIVE_INFINITY) == +1); + assertEquals(0, Double.compare(Double.NaN, Double.NaN)); + assertEquals(Double.compare(Double.NaN, Double.POSITIVE_INFINITY), +1); + assertEquals(Double.compare(Double.NaN, Double.MAX_VALUE), +1); + assertEquals(Double.compare(Double.NaN, 1.2d), +1); + assertEquals(Double.compare(Double.NaN, 0.0d), +1); + assertEquals(Double.compare(Double.NaN, -0.0d), +1); + assertEquals(Double.compare(Double.NaN, -1.2d), +1); + assertEquals(Double.compare(Double.NaN, -Double.MAX_VALUE), +1); + assertEquals(Double.compare(Double.NaN, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.NaN) == -1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY) == 0); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.MAX_VALUE) == +1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, 1.2d) == +1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, 0.0d) == +1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, -0.0d) == +1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, -1.2d) == +1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, -Double.MAX_VALUE) == +1); - assertTrue(Double.compare(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY) == +1); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, Double.NaN), -1); + assertEquals(0, Double.compare(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, Double.MAX_VALUE), +1); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, 1.2d), +1); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, 0.0d), +1); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, -0.0d), +1); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, -1.2d), +1); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, -Double.MAX_VALUE), +1); + assertEquals(Double.compare(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(Double.MAX_VALUE, Double.NaN) == -1); - assertTrue(Double.compare(Double.MAX_VALUE, Double.POSITIVE_INFINITY) == -1); - assertTrue(Double.compare(Double.MAX_VALUE, Double.MAX_VALUE) == 0); - assertTrue(Double.compare(Double.MAX_VALUE, 1.2d) == +1); - assertTrue(Double.compare(Double.MAX_VALUE, 0.0d) == +1); - assertTrue(Double.compare(Double.MAX_VALUE, -0.0d) == +1); - assertTrue(Double.compare(Double.MAX_VALUE, -1.2d) == +1); - assertTrue(Double.compare(Double.MAX_VALUE, -Double.MAX_VALUE) == +1); - assertTrue(Double.compare(Double.MAX_VALUE, Double.NEGATIVE_INFINITY) == +1); + assertEquals(Double.compare(Double.MAX_VALUE, Double.NaN), -1); + assertEquals(Double.compare(Double.MAX_VALUE, Double.POSITIVE_INFINITY), -1); + assertEquals(0, Double.compare(Double.MAX_VALUE, Double.MAX_VALUE)); + assertEquals(Double.compare(Double.MAX_VALUE, 1.2d), +1); + assertEquals(Double.compare(Double.MAX_VALUE, 0.0d), +1); + assertEquals(Double.compare(Double.MAX_VALUE, -0.0d), +1); + assertEquals(Double.compare(Double.MAX_VALUE, -1.2d), +1); + assertEquals(Double.compare(Double.MAX_VALUE, -Double.MAX_VALUE), +1); + assertEquals(Double.compare(Double.MAX_VALUE, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(1.2d, Double.NaN) == -1); - assertTrue(Double.compare(1.2d, Double.POSITIVE_INFINITY) == -1); - assertTrue(Double.compare(1.2d, Double.MAX_VALUE) == -1); - assertTrue(Double.compare(1.2d, 1.2d) == 0); - assertTrue(Double.compare(1.2d, 0.0d) == +1); - assertTrue(Double.compare(1.2d, -0.0d) == +1); - assertTrue(Double.compare(1.2d, -1.2d) == +1); - assertTrue(Double.compare(1.2d, -Double.MAX_VALUE) == +1); - assertTrue(Double.compare(1.2d, Double.NEGATIVE_INFINITY) == +1); + assertEquals(Double.compare(1.2d, Double.NaN), -1); + assertEquals(Double.compare(1.2d, Double.POSITIVE_INFINITY), -1); + assertEquals(Double.compare(1.2d, Double.MAX_VALUE), -1); + assertEquals(0, Double.compare(1.2d, 1.2d)); + assertEquals(Double.compare(1.2d, 0.0d), +1); + assertEquals(Double.compare(1.2d, -0.0d), +1); + assertEquals(Double.compare(1.2d, -1.2d), +1); + assertEquals(Double.compare(1.2d, -Double.MAX_VALUE), +1); + assertEquals(Double.compare(1.2d, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(0.0d, Double.NaN) == -1); - assertTrue(Double.compare(0.0d, Double.POSITIVE_INFINITY) == -1); - assertTrue(Double.compare(0.0d, Double.MAX_VALUE) == -1); - assertTrue(Double.compare(0.0d, 1.2d) == -1); - assertTrue(Double.compare(0.0d, 0.0d) == 0); - assertTrue(Double.compare(0.0d, -0.0d) == +1); - assertTrue(Double.compare(0.0d, -1.2d) == +1); - assertTrue(Double.compare(0.0d, -Double.MAX_VALUE) == +1); - assertTrue(Double.compare(0.0d, Double.NEGATIVE_INFINITY) == +1); + assertEquals(Double.compare(0.0d, Double.NaN), -1); + assertEquals(Double.compare(0.0d, Double.POSITIVE_INFINITY), -1); + assertEquals(Double.compare(0.0d, Double.MAX_VALUE), -1); + assertEquals(Double.compare(0.0d, 1.2d), -1); + assertEquals(0, Double.compare(0.0d, 0.0d)); + assertEquals(Double.compare(0.0d, -0.0d), +1); + assertEquals(Double.compare(0.0d, -1.2d), +1); + assertEquals(Double.compare(0.0d, -Double.MAX_VALUE), +1); + assertEquals(Double.compare(0.0d, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(-0.0d, Double.NaN) == -1); - assertTrue(Double.compare(-0.0d, Double.POSITIVE_INFINITY) == -1); - assertTrue(Double.compare(-0.0d, Double.MAX_VALUE) == -1); - assertTrue(Double.compare(-0.0d, 1.2d) == -1); - assertTrue(Double.compare(-0.0d, 0.0d) == -1); - assertTrue(Double.compare(-0.0d, -0.0d) == 0); - assertTrue(Double.compare(-0.0d, -1.2d) == +1); - assertTrue(Double.compare(-0.0d, -Double.MAX_VALUE) == +1); - assertTrue(Double.compare(-0.0d, Double.NEGATIVE_INFINITY) == +1); + assertEquals(Double.compare(-0.0d, Double.NaN), -1); + assertEquals(Double.compare(-0.0d, Double.POSITIVE_INFINITY), -1); + assertEquals(Double.compare(-0.0d, Double.MAX_VALUE), -1); + assertEquals(Double.compare(-0.0d, 1.2d), -1); + assertEquals(Double.compare(-0.0d, 0.0d), -1); + assertEquals(0, Double.compare(-0.0d, -0.0d)); + assertEquals(Double.compare(-0.0d, -1.2d), +1); + assertEquals(Double.compare(-0.0d, -Double.MAX_VALUE), +1); + assertEquals(Double.compare(-0.0d, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(-1.2d, Double.NaN) == -1); - assertTrue(Double.compare(-1.2d, Double.POSITIVE_INFINITY) == -1); - assertTrue(Double.compare(-1.2d, Double.MAX_VALUE) == -1); - assertTrue(Double.compare(-1.2d, 1.2d) == -1); - assertTrue(Double.compare(-1.2d, 0.0d) == -1); - assertTrue(Double.compare(-1.2d, -0.0d) == -1); - assertTrue(Double.compare(-1.2d, -1.2d) == 0); - assertTrue(Double.compare(-1.2d, -Double.MAX_VALUE) == +1); - assertTrue(Double.compare(-1.2d, Double.NEGATIVE_INFINITY) == +1); + assertEquals(Double.compare(-1.2d, Double.NaN), -1); + assertEquals(Double.compare(-1.2d, Double.POSITIVE_INFINITY), -1); + assertEquals(Double.compare(-1.2d, Double.MAX_VALUE), -1); + assertEquals(Double.compare(-1.2d, 1.2d), -1); + assertEquals(Double.compare(-1.2d, 0.0d), -1); + assertEquals(Double.compare(-1.2d, -0.0d), -1); + assertEquals(0, Double.compare(-1.2d, -1.2d)); + assertEquals(Double.compare(-1.2d, -Double.MAX_VALUE), +1); + assertEquals(Double.compare(-1.2d, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(-Double.MAX_VALUE, Double.NaN) == -1); - assertTrue(Double.compare(-Double.MAX_VALUE, Double.POSITIVE_INFINITY) == -1); - assertTrue(Double.compare(-Double.MAX_VALUE, Double.MAX_VALUE) == -1); - assertTrue(Double.compare(-Double.MAX_VALUE, 1.2d) == -1); - assertTrue(Double.compare(-Double.MAX_VALUE, 0.0d) == -1); - assertTrue(Double.compare(-Double.MAX_VALUE, -0.0d) == -1); - assertTrue(Double.compare(-Double.MAX_VALUE, -1.2d) == -1); - assertTrue(Double.compare(-Double.MAX_VALUE, -Double.MAX_VALUE) == 0); - assertTrue(Double.compare(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY) == +1); + assertEquals(Double.compare(-Double.MAX_VALUE, Double.NaN), -1); + assertEquals(Double.compare(-Double.MAX_VALUE, Double.POSITIVE_INFINITY), -1); + assertEquals(Double.compare(-Double.MAX_VALUE, Double.MAX_VALUE), -1); + assertEquals(Double.compare(-Double.MAX_VALUE, 1.2d), -1); + assertEquals(Double.compare(-Double.MAX_VALUE, 0.0d), -1); + assertEquals(Double.compare(-Double.MAX_VALUE, -0.0d), -1); + assertEquals(Double.compare(-Double.MAX_VALUE, -1.2d), -1); + assertEquals(0, Double.compare(-Double.MAX_VALUE, -Double.MAX_VALUE)); + assertEquals(Double.compare(-Double.MAX_VALUE, Double.NEGATIVE_INFINITY), +1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.NaN) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.MAX_VALUE) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, 1.2d) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, 0.0d) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, -0.0d) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, -1.2d) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, -Double.MAX_VALUE) == -1); - assertTrue(Double.compare(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY) == 0); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, Double.NaN), -1); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), -1); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, Double.MAX_VALUE), -1); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, 1.2d), -1); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, 0.0d), -1); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, -0.0d), -1); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, -1.2d), -1); + assertEquals(Double.compare(Double.NEGATIVE_INFINITY, -Double.MAX_VALUE), -1); + assertEquals(0, Double.compare(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY)); } @Test public void testCompareFloat() { - assertTrue(Float.compare(Float.NaN, Float.NaN) == 0); - assertTrue(Float.compare(Float.NaN, Float.POSITIVE_INFINITY) == +1); - assertTrue(Float.compare(Float.NaN, Float.MAX_VALUE) == +1); - assertTrue(Float.compare(Float.NaN, 1.2f) == +1); - assertTrue(Float.compare(Float.NaN, 0.0f) == +1); - assertTrue(Float.compare(Float.NaN, -0.0f) == +1); - assertTrue(Float.compare(Float.NaN, -1.2f) == +1); - assertTrue(Float.compare(Float.NaN, -Float.MAX_VALUE) == +1); - assertTrue(Float.compare(Float.NaN, Float.NEGATIVE_INFINITY) == +1); + assertEquals(0, Float.compare(Float.NaN, Float.NaN)); + assertEquals(Float.compare(Float.NaN, Float.POSITIVE_INFINITY), +1); + assertEquals(Float.compare(Float.NaN, Float.MAX_VALUE), +1); + assertEquals(Float.compare(Float.NaN, 1.2f), +1); + assertEquals(Float.compare(Float.NaN, 0.0f), +1); + assertEquals(Float.compare(Float.NaN, -0.0f), +1); + assertEquals(Float.compare(Float.NaN, -1.2f), +1); + assertEquals(Float.compare(Float.NaN, -Float.MAX_VALUE), +1); + assertEquals(Float.compare(Float.NaN, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.NaN) == -1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY) == 0); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.MAX_VALUE) == +1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, 1.2f) == +1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, 0.0f) == +1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, -0.0f) == +1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, -1.2f) == +1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, -Float.MAX_VALUE) == +1); - assertTrue(Float.compare(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY) == +1); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, Float.NaN), -1); + assertEquals(0, Float.compare(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, Float.MAX_VALUE), +1); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, 1.2f), +1); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, 0.0f), +1); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, -0.0f), +1); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, -1.2f), +1); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, -Float.MAX_VALUE), +1); + assertEquals(Float.compare(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(Float.MAX_VALUE, Float.NaN) == -1); - assertTrue(Float.compare(Float.MAX_VALUE, Float.POSITIVE_INFINITY) == -1); - assertTrue(Float.compare(Float.MAX_VALUE, Float.MAX_VALUE) == 0); - assertTrue(Float.compare(Float.MAX_VALUE, 1.2f) == +1); - assertTrue(Float.compare(Float.MAX_VALUE, 0.0f) == +1); - assertTrue(Float.compare(Float.MAX_VALUE, -0.0f) == +1); - assertTrue(Float.compare(Float.MAX_VALUE, -1.2f) == +1); - assertTrue(Float.compare(Float.MAX_VALUE, -Float.MAX_VALUE) == +1); - assertTrue(Float.compare(Float.MAX_VALUE, Float.NEGATIVE_INFINITY) == +1); + assertEquals(Float.compare(Float.MAX_VALUE, Float.NaN), -1); + assertEquals(Float.compare(Float.MAX_VALUE, Float.POSITIVE_INFINITY), -1); + assertEquals(0, Float.compare(Float.MAX_VALUE, Float.MAX_VALUE)); + assertEquals(Float.compare(Float.MAX_VALUE, 1.2f), +1); + assertEquals(Float.compare(Float.MAX_VALUE, 0.0f), +1); + assertEquals(Float.compare(Float.MAX_VALUE, -0.0f), +1); + assertEquals(Float.compare(Float.MAX_VALUE, -1.2f), +1); + assertEquals(Float.compare(Float.MAX_VALUE, -Float.MAX_VALUE), +1); + assertEquals(Float.compare(Float.MAX_VALUE, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(1.2f, Float.NaN) == -1); - assertTrue(Float.compare(1.2f, Float.POSITIVE_INFINITY) == -1); - assertTrue(Float.compare(1.2f, Float.MAX_VALUE) == -1); - assertTrue(Float.compare(1.2f, 1.2f) == 0); - assertTrue(Float.compare(1.2f, 0.0f) == +1); - assertTrue(Float.compare(1.2f, -0.0f) == +1); - assertTrue(Float.compare(1.2f, -1.2f) == +1); - assertTrue(Float.compare(1.2f, -Float.MAX_VALUE) == +1); - assertTrue(Float.compare(1.2f, Float.NEGATIVE_INFINITY) == +1); + assertEquals(Float.compare(1.2f, Float.NaN), -1); + assertEquals(Float.compare(1.2f, Float.POSITIVE_INFINITY), -1); + assertEquals(Float.compare(1.2f, Float.MAX_VALUE), -1); + assertEquals(0, Float.compare(1.2f, 1.2f)); + assertEquals(Float.compare(1.2f, 0.0f), +1); + assertEquals(Float.compare(1.2f, -0.0f), +1); + assertEquals(Float.compare(1.2f, -1.2f), +1); + assertEquals(Float.compare(1.2f, -Float.MAX_VALUE), +1); + assertEquals(Float.compare(1.2f, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(0.0f, Float.NaN) == -1); - assertTrue(Float.compare(0.0f, Float.POSITIVE_INFINITY) == -1); - assertTrue(Float.compare(0.0f, Float.MAX_VALUE) == -1); - assertTrue(Float.compare(0.0f, 1.2f) == -1); - assertTrue(Float.compare(0.0f, 0.0f) == 0); - assertTrue(Float.compare(0.0f, -0.0f) == +1); - assertTrue(Float.compare(0.0f, -1.2f) == +1); - assertTrue(Float.compare(0.0f, -Float.MAX_VALUE) == +1); - assertTrue(Float.compare(0.0f, Float.NEGATIVE_INFINITY) == +1); + assertEquals(Float.compare(0.0f, Float.NaN), -1); + assertEquals(Float.compare(0.0f, Float.POSITIVE_INFINITY), -1); + assertEquals(Float.compare(0.0f, Float.MAX_VALUE), -1); + assertEquals(Float.compare(0.0f, 1.2f), -1); + assertEquals(0, Float.compare(0.0f, 0.0f)); + assertEquals(Float.compare(0.0f, -0.0f), +1); + assertEquals(Float.compare(0.0f, -1.2f), +1); + assertEquals(Float.compare(0.0f, -Float.MAX_VALUE), +1); + assertEquals(Float.compare(0.0f, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(-0.0f, Float.NaN) == -1); - assertTrue(Float.compare(-0.0f, Float.POSITIVE_INFINITY) == -1); - assertTrue(Float.compare(-0.0f, Float.MAX_VALUE) == -1); - assertTrue(Float.compare(-0.0f, 1.2f) == -1); - assertTrue(Float.compare(-0.0f, 0.0f) == -1); - assertTrue(Float.compare(-0.0f, -0.0f) == 0); - assertTrue(Float.compare(-0.0f, -1.2f) == +1); - assertTrue(Float.compare(-0.0f, -Float.MAX_VALUE) == +1); - assertTrue(Float.compare(-0.0f, Float.NEGATIVE_INFINITY) == +1); + assertEquals(Float.compare(-0.0f, Float.NaN), -1); + assertEquals(Float.compare(-0.0f, Float.POSITIVE_INFINITY), -1); + assertEquals(Float.compare(-0.0f, Float.MAX_VALUE), -1); + assertEquals(Float.compare(-0.0f, 1.2f), -1); + assertEquals(Float.compare(-0.0f, 0.0f), -1); + assertEquals(0, Float.compare(-0.0f, -0.0f)); + assertEquals(Float.compare(-0.0f, -1.2f), +1); + assertEquals(Float.compare(-0.0f, -Float.MAX_VALUE), +1); + assertEquals(Float.compare(-0.0f, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(-1.2f, Float.NaN) == -1); - assertTrue(Float.compare(-1.2f, Float.POSITIVE_INFINITY) == -1); - assertTrue(Float.compare(-1.2f, Float.MAX_VALUE) == -1); - assertTrue(Float.compare(-1.2f, 1.2f) == -1); - assertTrue(Float.compare(-1.2f, 0.0f) == -1); - assertTrue(Float.compare(-1.2f, -0.0f) == -1); - assertTrue(Float.compare(-1.2f, -1.2f) == 0); - assertTrue(Float.compare(-1.2f, -Float.MAX_VALUE) == +1); - assertTrue(Float.compare(-1.2f, Float.NEGATIVE_INFINITY) == +1); + assertEquals(Float.compare(-1.2f, Float.NaN), -1); + assertEquals(Float.compare(-1.2f, Float.POSITIVE_INFINITY), -1); + assertEquals(Float.compare(-1.2f, Float.MAX_VALUE), -1); + assertEquals(Float.compare(-1.2f, 1.2f), -1); + assertEquals(Float.compare(-1.2f, 0.0f), -1); + assertEquals(Float.compare(-1.2f, -0.0f), -1); + assertEquals(0, Float.compare(-1.2f, -1.2f)); + assertEquals(Float.compare(-1.2f, -Float.MAX_VALUE), +1); + assertEquals(Float.compare(-1.2f, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(-Float.MAX_VALUE, Float.NaN) == -1); - assertTrue(Float.compare(-Float.MAX_VALUE, Float.POSITIVE_INFINITY) == -1); - assertTrue(Float.compare(-Float.MAX_VALUE, Float.MAX_VALUE) == -1); - assertTrue(Float.compare(-Float.MAX_VALUE, 1.2f) == -1); - assertTrue(Float.compare(-Float.MAX_VALUE, 0.0f) == -1); - assertTrue(Float.compare(-Float.MAX_VALUE, -0.0f) == -1); - assertTrue(Float.compare(-Float.MAX_VALUE, -1.2f) == -1); - assertTrue(Float.compare(-Float.MAX_VALUE, -Float.MAX_VALUE) == 0); - assertTrue(Float.compare(-Float.MAX_VALUE, Float.NEGATIVE_INFINITY) == +1); + assertEquals(Float.compare(-Float.MAX_VALUE, Float.NaN), -1); + assertEquals(Float.compare(-Float.MAX_VALUE, Float.POSITIVE_INFINITY), -1); + assertEquals(Float.compare(-Float.MAX_VALUE, Float.MAX_VALUE), -1); + assertEquals(Float.compare(-Float.MAX_VALUE, 1.2f), -1); + assertEquals(Float.compare(-Float.MAX_VALUE, 0.0f), -1); + assertEquals(Float.compare(-Float.MAX_VALUE, -0.0f), -1); + assertEquals(Float.compare(-Float.MAX_VALUE, -1.2f), -1); + assertEquals(0, Float.compare(-Float.MAX_VALUE, -Float.MAX_VALUE)); + assertEquals(Float.compare(-Float.MAX_VALUE, Float.NEGATIVE_INFINITY), +1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.NaN) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.MAX_VALUE) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, 1.2f) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, 0.0f) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, -0.0f) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, -1.2f) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, -Float.MAX_VALUE) == -1); - assertTrue(Float.compare(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY) == 0); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, Float.NaN), -1); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY), -1); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, Float.MAX_VALUE), -1); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, 1.2f), -1); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, 0.0f), -1); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, -0.0f), -1); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, -1.2f), -1); + assertEquals(Float.compare(Float.NEGATIVE_INFINITY, -Float.MAX_VALUE), -1); + assertEquals(0, Float.compare(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY)); } @Test @@ -1558,23 +1511,23 @@ public void testConstants() { assertTrue(NumberUtils.FLOAT_ONE instanceof Float); assertTrue(NumberUtils.FLOAT_MINUS_ONE instanceof Float); - assertTrue(NumberUtils.LONG_ZERO.longValue() == 0); - assertTrue(NumberUtils.LONG_ONE.longValue() == 1); - assertTrue(NumberUtils.LONG_MINUS_ONE.longValue() == -1); - assertTrue(NumberUtils.INTEGER_ZERO.intValue() == 0); - assertTrue(NumberUtils.INTEGER_ONE.intValue() == 1); - assertTrue(NumberUtils.INTEGER_MINUS_ONE.intValue() == -1); - assertTrue(NumberUtils.SHORT_ZERO.shortValue() == 0); - assertTrue(NumberUtils.SHORT_ONE.shortValue() == 1); - assertTrue(NumberUtils.SHORT_MINUS_ONE.shortValue() == -1); - assertTrue(NumberUtils.BYTE_ZERO.byteValue() == 0); - assertTrue(NumberUtils.BYTE_ONE.byteValue() == 1); - assertTrue(NumberUtils.BYTE_MINUS_ONE.byteValue() == -1); - assertTrue(NumberUtils.DOUBLE_ZERO.doubleValue() == 0.0d); - assertTrue(NumberUtils.DOUBLE_ONE.doubleValue() == 1.0d); + assertEquals(0, NumberUtils.LONG_ZERO.longValue()); + assertEquals(1, NumberUtils.LONG_ONE.longValue()); + assertEquals(NumberUtils.LONG_MINUS_ONE.longValue(), -1); + assertEquals(0, NumberUtils.INTEGER_ZERO.intValue()); + assertEquals(1, NumberUtils.INTEGER_ONE.intValue()); + assertEquals(NumberUtils.INTEGER_MINUS_ONE.intValue(), -1); + assertEquals(0, NumberUtils.SHORT_ZERO.shortValue()); + assertEquals(1, NumberUtils.SHORT_ONE.shortValue()); + assertEquals(NumberUtils.SHORT_MINUS_ONE.shortValue(), -1); + assertEquals(0, NumberUtils.BYTE_ZERO.byteValue()); + assertEquals(1, NumberUtils.BYTE_ONE.byteValue()); + assertEquals(NumberUtils.BYTE_MINUS_ONE.byteValue(), -1); + assertTrue(0.0d == NumberUtils.DOUBLE_ZERO.doubleValue()); + assertTrue(1.0d == NumberUtils.DOUBLE_ONE.doubleValue()); assertTrue(NumberUtils.DOUBLE_MINUS_ONE.doubleValue() == -1.0d); - assertTrue(NumberUtils.FLOAT_ZERO.floatValue() == 0.0f); - assertTrue(NumberUtils.FLOAT_ONE.floatValue() == 1.0f); + assertTrue(0.0f == NumberUtils.FLOAT_ZERO.floatValue()); + assertTrue(1.0f == NumberUtils.FLOAT_ONE.floatValue()); assertTrue(NumberUtils.FLOAT_MINUS_ONE.floatValue() == -1.0f); } @@ -1610,28 +1563,28 @@ public void testLang381() { @Test public void compareInt() { assertTrue(NumberUtils.compare(-3, 0) < 0); - assertTrue(NumberUtils.compare(113, 113)==0); + assertEquals(0, NumberUtils.compare(113, 113)); assertTrue(NumberUtils.compare(213, 32) > 0); } @Test public void compareLong() { assertTrue(NumberUtils.compare(-3L, 0L) < 0); - assertTrue(NumberUtils.compare(113L, 113L)==0); + assertEquals(0, NumberUtils.compare(113L, 113L)); assertTrue(NumberUtils.compare(213L, 32L) > 0); } @Test public void compareShort() { assertTrue(NumberUtils.compare((short)-3, (short)0) < 0); - assertTrue(NumberUtils.compare((short)113, (short)113)==0); + assertEquals(0, NumberUtils.compare((short) 113, (short) 113)); assertTrue(NumberUtils.compare((short)213, (short)32) > 0); } @Test public void compareByte() { assertTrue(NumberUtils.compare((byte)-3, (byte)0) < 0); - assertTrue(NumberUtils.compare((byte)113, (byte)113)==0); + assertEquals(0, NumberUtils.compare((byte) 113, (byte) 113)); assertTrue(NumberUtils.compare((byte)123, (byte)32) > 0); } } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java index c7634d80d..7f345aff8 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -73,16 +74,16 @@ public void testEquals() { final MutableBoolean mutBoolB = new MutableBoolean(false); final MutableBoolean mutBoolC = new MutableBoolean(true); - assertTrue(mutBoolA.equals(mutBoolA)); - assertTrue(mutBoolA.equals(mutBoolB)); - assertTrue(mutBoolB.equals(mutBoolA)); - assertTrue(mutBoolB.equals(mutBoolB)); - assertFalse(mutBoolA.equals(mutBoolC)); - assertFalse(mutBoolB.equals(mutBoolC)); - assertTrue(mutBoolC.equals(mutBoolC)); - assertFalse(mutBoolA.equals(null)); - assertFalse(mutBoolA.equals(Boolean.FALSE)); - assertFalse(mutBoolA.equals("false")); + assertEquals(mutBoolA, mutBoolA); + assertEquals(mutBoolA, mutBoolB); + assertEquals(mutBoolB, mutBoolA); + assertEquals(mutBoolB, mutBoolB); + assertNotEquals(mutBoolA, mutBoolC); + assertNotEquals(mutBoolB, mutBoolC); + assertEquals(mutBoolC, mutBoolC); + assertNotEquals(null, mutBoolA); + assertNotEquals(mutBoolA, Boolean.FALSE); + assertNotEquals("false", mutBoolA); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java index 91ad38cfa..7f5d41293 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -80,16 +81,16 @@ public void testEquals() { final MutableByte mutNumB = new MutableByte((byte) 0); final MutableByte mutNumC = new MutableByte((byte) 1); - assertTrue(mutNumA.equals(mutNumA)); - assertTrue(mutNumA.equals(mutNumB)); - assertTrue(mutNumB.equals(mutNumA)); - assertTrue(mutNumB.equals(mutNumB)); - assertFalse(mutNumA.equals(mutNumC)); - assertFalse(mutNumB.equals(mutNumC)); - assertTrue(mutNumC.equals(mutNumC)); - assertFalse(mutNumA.equals(null)); - assertFalse(mutNumA.equals(Byte.valueOf((byte) 0))); - assertFalse(mutNumA.equals("0")); + assertEquals(mutNumA, mutNumA); + assertEquals(mutNumA, mutNumB); + assertEquals(mutNumB, mutNumA); + assertEquals(mutNumB, mutNumB); + assertNotEquals(mutNumA, mutNumC); + assertNotEquals(mutNumB, mutNumC); + assertEquals(mutNumC, mutNumC); + assertNotEquals(null, mutNumA); + assertNotEquals(mutNumA, Byte.valueOf((byte) 0)); + assertNotEquals("0", mutNumA); } @Test @@ -98,10 +99,10 @@ public void testHashCode() { final MutableByte mutNumB = new MutableByte((byte) 0); final MutableByte mutNumC = new MutableByte((byte) 1); - assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); - assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumA.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumB.hashCode()); assertFalse(mutNumA.hashCode() == mutNumC.hashCode()); - assertTrue(mutNumA.hashCode() == Byte.valueOf((byte) 0).hashCode()); + assertEquals(mutNumA.hashCode(), Byte.valueOf((byte) 0).hashCode()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java index 378379a06..5bb417dbf 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -92,16 +93,16 @@ public void testEquals() { final MutableDouble mutNumB = new MutableDouble(0d); final MutableDouble mutNumC = new MutableDouble(1d); - assertTrue(mutNumA.equals(mutNumA)); - assertTrue(mutNumA.equals(mutNumB)); - assertTrue(mutNumB.equals(mutNumA)); - assertTrue(mutNumB.equals(mutNumB)); - assertFalse(mutNumA.equals(mutNumC)); - assertFalse(mutNumB.equals(mutNumC)); - assertTrue(mutNumC.equals(mutNumC)); - assertFalse(mutNumA.equals(null)); - assertFalse(mutNumA.equals(Double.valueOf(0d))); - assertFalse(mutNumA.equals("0")); + assertEquals(mutNumA, mutNumA); + assertEquals(mutNumA, mutNumB); + assertEquals(mutNumB, mutNumA); + assertEquals(mutNumB, mutNumB); + assertNotEquals(mutNumA, mutNumC); + assertNotEquals(mutNumB, mutNumC); + assertEquals(mutNumC, mutNumC); + assertNotEquals(null, mutNumA); + assertNotEquals(mutNumA, Double.valueOf(0d)); + assertNotEquals("0", mutNumA); } @Test @@ -110,10 +111,10 @@ public void testHashCode() { final MutableDouble mutNumB = new MutableDouble(0d); final MutableDouble mutNumC = new MutableDouble(1d); - assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); - assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumA.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumB.hashCode()); assertFalse(mutNumA.hashCode() == mutNumC.hashCode()); - assertTrue(mutNumA.hashCode() == Double.valueOf(0d).hashCode()); + assertEquals(mutNumA.hashCode(), Double.valueOf(0d).hashCode()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java index 96fbcdd65..4b479eca9 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -92,16 +93,16 @@ public void testEquals() { final MutableFloat mutNumB = new MutableFloat(0f); final MutableFloat mutNumC = new MutableFloat(1f); - assertTrue(mutNumA.equals(mutNumA)); - assertTrue(mutNumA.equals(mutNumB)); - assertTrue(mutNumB.equals(mutNumA)); - assertTrue(mutNumB.equals(mutNumB)); - assertFalse(mutNumA.equals(mutNumC)); - assertFalse(mutNumB.equals(mutNumC)); - assertTrue(mutNumC.equals(mutNumC)); - assertFalse(mutNumA.equals(null)); - assertFalse(mutNumA.equals(Float.valueOf(0f))); - assertFalse(mutNumA.equals("0")); + assertEquals(mutNumA, mutNumA); + assertEquals(mutNumA, mutNumB); + assertEquals(mutNumB, mutNumA); + assertEquals(mutNumB, mutNumB); + assertNotEquals(mutNumA, mutNumC); + assertNotEquals(mutNumB, mutNumC); + assertEquals(mutNumC, mutNumC); + assertNotEquals(null, mutNumA); + assertNotEquals(mutNumA, Float.valueOf(0f)); + assertNotEquals("0", mutNumA); } @Test @@ -110,10 +111,10 @@ public void testHashCode() { final MutableFloat mutNumB = new MutableFloat(0f); final MutableFloat mutNumC = new MutableFloat(1f); - assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); - assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumA.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumB.hashCode()); assertFalse(mutNumA.hashCode() == mutNumC.hashCode()); - assertTrue(mutNumA.hashCode() == Float.valueOf(0f).hashCode()); + assertEquals(mutNumA.hashCode(), Float.valueOf(0f).hashCode()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java index f3100d3e8..27eb976a6 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -87,16 +88,16 @@ public void testEquals() { * @param numC must not equal numA; must not equal numC. */ void testEquals(final Number numA, final Number numB, final Number numC) { - assertTrue(numA.equals(numA)); - assertTrue(numA.equals(numB)); - assertTrue(numB.equals(numA)); - assertTrue(numB.equals(numB)); - assertFalse(numA.equals(numC)); - assertFalse(numB.equals(numC)); - assertTrue(numC.equals(numC)); - assertFalse(numA.equals(null)); - assertFalse(numA.equals(Integer.valueOf(0))); - assertFalse(numA.equals("0")); + assertEquals(numA, numA); + assertEquals(numA, numB); + assertEquals(numB, numA); + assertEquals(numB, numB); + assertNotEquals(numA, numC); + assertNotEquals(numB, numC); + assertEquals(numC, numC); + assertNotEquals(null, numA); + assertNotEquals(numA, Integer.valueOf(0)); + assertNotEquals("0", numA); } @Test @@ -105,10 +106,10 @@ public void testHashCode() { final MutableInt mutNumB = new MutableInt(0); final MutableInt mutNumC = new MutableInt(1); - assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); - assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumA.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumB.hashCode()); assertFalse(mutNumA.hashCode() == mutNumC.hashCode()); - assertTrue(mutNumA.hashCode() == Integer.valueOf(0).hashCode()); + assertEquals(mutNumA.hashCode(), Integer.valueOf(0).hashCode()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java index 2ad7ea9ad..15ed28eae 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -80,16 +81,16 @@ public void testEquals() { final MutableLong mutNumB = new MutableLong(0); final MutableLong mutNumC = new MutableLong(1); - assertTrue(mutNumA.equals(mutNumA)); - assertTrue(mutNumA.equals(mutNumB)); - assertTrue(mutNumB.equals(mutNumA)); - assertTrue(mutNumB.equals(mutNumB)); - assertFalse(mutNumA.equals(mutNumC)); - assertFalse(mutNumB.equals(mutNumC)); - assertTrue(mutNumC.equals(mutNumC)); - assertFalse(mutNumA.equals(null)); - assertFalse(mutNumA.equals(Long.valueOf(0))); - assertFalse(mutNumA.equals("0")); + assertEquals(mutNumA, mutNumA); + assertEquals(mutNumA, mutNumB); + assertEquals(mutNumB, mutNumA); + assertEquals(mutNumB, mutNumB); + assertNotEquals(mutNumA, mutNumC); + assertNotEquals(mutNumB, mutNumC); + assertEquals(mutNumC, mutNumC); + assertNotEquals(null, mutNumA); + assertNotEquals(mutNumA, Long.valueOf(0)); + assertNotEquals("0", mutNumA); } @Test @@ -98,10 +99,10 @@ public void testHashCode() { final MutableLong mutNumB = new MutableLong(0); final MutableLong mutNumC = new MutableLong(1); - assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); - assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumA.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumB.hashCode()); assertFalse(mutNumA.hashCode() == mutNumC.hashCode()); - assertTrue(mutNumA.hashCode() == Long.valueOf(0).hashCode()); + assertEquals(mutNumA.hashCode(), Long.valueOf(0).hashCode()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java index 78ffe63d5..08df29806 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -71,16 +72,16 @@ public void testEquals() { final MutableShort mutNumB = new MutableShort((short) 0); final MutableShort mutNumC = new MutableShort((short) 1); - assertTrue(mutNumA.equals(mutNumA)); - assertTrue(mutNumA.equals(mutNumB)); - assertTrue(mutNumB.equals(mutNumA)); - assertTrue(mutNumB.equals(mutNumB)); - assertFalse(mutNumA.equals(mutNumC)); - assertFalse(mutNumB.equals(mutNumC)); - assertTrue(mutNumC.equals(mutNumC)); - assertFalse(mutNumA.equals(null)); - assertFalse(mutNumA.equals(Short.valueOf((short) 0))); - assertFalse(mutNumA.equals("0")); + assertEquals(mutNumA, mutNumA); + assertEquals(mutNumA, mutNumB); + assertEquals(mutNumB, mutNumA); + assertEquals(mutNumB, mutNumB); + assertNotEquals(mutNumA, mutNumC); + assertNotEquals(mutNumB, mutNumC); + assertEquals(mutNumC, mutNumC); + assertNotEquals(null, mutNumA); + assertNotEquals(mutNumA, Short.valueOf((short) 0)); + assertNotEquals("0", mutNumA); } @Test @@ -89,10 +90,10 @@ public void testHashCode() { final MutableShort mutNumB = new MutableShort((short) 0); final MutableShort mutNumC = new MutableShort((short) 1); - assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); - assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumA.hashCode()); + assertEquals(mutNumA.hashCode(), mutNumB.hashCode()); assertFalse(mutNumA.hashCode() == mutNumC.hashCode()); - assertTrue(mutNumA.hashCode() == Short.valueOf((short) 0).hashCode()); + assertEquals(mutNumA.hashCode(), Short.valueOf((short) 0).hashCode()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java index efa59706f..624976569 100644 --- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java @@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.text.DateFormat; import java.text.FieldPosition; @@ -301,33 +301,33 @@ public void testEqualsHashcode() { ExtendedMessageFormat other = null; // Same object - assertTrue(emf.equals(emf), "same, equals()"); - assertTrue(emf.hashCode() == emf.hashCode(), "same, hashcode()"); + assertEquals(emf, emf, "same, equals()"); + assertEquals(emf.hashCode(), emf.hashCode(), "same, hashcode()"); // Equal Object other = new ExtendedMessageFormat(pattern, Locale.US, fmtRegistry); - assertTrue(emf.equals(other), "equal, equals()"); - assertTrue(emf.hashCode() == other.hashCode(), "equal, hashcode()"); + assertEquals(emf, other, "equal, equals()"); + assertEquals(emf.hashCode(), other.hashCode(), "equal, hashcode()"); // Different Class other = new OtherExtendedMessageFormat(pattern, Locale.US, fmtRegistry); - assertFalse(emf.equals(other), "class, equals()"); - assertTrue(emf.hashCode() == other.hashCode(), "class, hashcode()"); // same hashcode + assertNotEquals(emf, other, "class, equals()"); + assertEquals(emf.hashCode(), other.hashCode(), "class, hashcode()"); // same hashcode // Different pattern other = new ExtendedMessageFormat("X" + pattern, Locale.US, fmtRegistry); - assertFalse(emf.equals(other), "pattern, equals()"); + assertNotEquals(emf, other, "pattern, equals()"); assertFalse(emf.hashCode() == other.hashCode(), "pattern, hashcode()"); // Different registry other = new ExtendedMessageFormat(pattern, Locale.US, otherRegitry); - assertFalse(emf.equals(other), "registry, equals()"); + assertNotEquals(emf, other, "registry, equals()"); assertFalse(emf.hashCode() == other.hashCode(), "registry, hashcode()"); // Different Locale other = new ExtendedMessageFormat(pattern, Locale.FRANCE, fmtRegistry); - assertFalse(emf.equals(other), "locale, equals()"); - assertTrue(emf.hashCode() == other.hashCode(), "locale, hashcode()"); // same hashcode + assertNotEquals(emf, other, "locale, equals()"); + assertEquals(emf.hashCode(), other.hashCode(), "locale, hashcode()"); // same hashcode } /** diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java index b09065f17..025456df1 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertNull; @@ -241,7 +242,7 @@ public void testCapacityAndLength() { assertTrue(sb.capacity() >= 32); assertEquals(3, sb.length()); assertEquals(3, sb.size()); - assertTrue(sb.isEmpty() == false); + assertFalse(sb.isEmpty()); sb.clear(); assertTrue(sb.capacity() >= 32); @@ -253,19 +254,19 @@ public void testCapacityAndLength() { assertTrue(sb.capacity() > 32); assertEquals(33, sb.length()); assertEquals(33, sb.size()); - assertTrue(sb.isEmpty() == false); + assertFalse(sb.isEmpty()); sb.ensureCapacity(16); assertTrue(sb.capacity() > 16); assertEquals(33, sb.length()); assertEquals(33, sb.size()); - assertTrue(sb.isEmpty() == false); + assertFalse(sb.isEmpty()); sb.minimizeCapacity(); assertEquals(33, sb.capacity()); assertEquals(33, sb.length()); assertEquals(33, sb.size()); - assertTrue(sb.isEmpty() == false); + assertFalse(sb.isEmpty()); assertThrows( IndexOutOfBoundsException.class, @@ -276,21 +277,21 @@ public void testCapacityAndLength() { assertEquals(33, sb.capacity()); assertEquals(33, sb.length()); assertEquals(33, sb.size()); - assertTrue(sb.isEmpty() == false); + assertFalse(sb.isEmpty()); sb.setLength(16); assertTrue(sb.capacity() >= 16); assertEquals(16, sb.length()); assertEquals(16, sb.size()); assertEquals("1234567890123456", sb.toString()); - assertTrue(sb.isEmpty() == false); + assertFalse(sb.isEmpty()); sb.setLength(32); assertTrue(sb.capacity() >= 32); assertEquals(32, sb.length()); assertEquals(32, sb.size()); assertEquals("1234567890123456\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sb.toString()); - assertTrue(sb.isEmpty() == false); + assertFalse(sb.isEmpty()); sb.setLength(0); assertTrue(sb.capacity() >= 32); @@ -1721,22 +1722,22 @@ public void testEquals() { assertTrue(sb1.equals(sb2)); assertTrue(sb1.equals(sb1)); assertTrue(sb2.equals(sb2)); - assertTrue(sb1.equals((Object) sb2)); + assertEquals(sb1, (Object) sb2); sb1.append("abc"); assertFalse(sb1.equals(sb2)); - assertFalse(sb1.equals((Object) sb2)); + assertNotEquals(sb1, (Object) sb2); sb2.append("ABC"); assertFalse(sb1.equals(sb2)); - assertFalse(sb1.equals((Object) sb2)); + assertNotEquals(sb1, (Object) sb2); sb2.clear().append("abc"); assertTrue(sb1.equals(sb2)); - assertTrue(sb1.equals((Object) sb2)); + assertEquals(sb1, (Object) sb2); - assertFalse(sb1.equals(Integer.valueOf(1))); - assertFalse(sb1.equals("abc")); + assertNotEquals(sb1, Integer.valueOf(1)); + assertNotEquals("abc", sb1); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java index c43df0111..406555072 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -43,8 +44,8 @@ public class StrTokenizerTest { private static final String TSV_SIMPLE_FIXTURE = "A\tb\tc"; private void checkClone(final StrTokenizer tokenizer) { - assertFalse(StrTokenizer.getCSVInstance() == tokenizer); - assertFalse(StrTokenizer.getTSVInstance() == tokenizer); + assertNotSame(StrTokenizer.getCSVInstance(), tokenizer); + assertNotSame(StrTokenizer.getTSVInstance(), tokenizer); } // ----------------------------------------------------------------------- @@ -182,11 +183,9 @@ public void test6() { assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); - assertTrue(nextCount == expected.length, - "could not cycle through entire token list" + " using the 'hasNext' and 'next' methods"); + assertEquals(nextCount, expected.length, "could not cycle through entire token list" + " using the 'hasNext' and 'next' methods"); - assertTrue(prevCount == expected.length, - "could not cycle through entire token list" + " using the 'hasPrevious' and 'previous' methods"); + assertEquals(prevCount, expected.length, "could not cycle through entire token list" + " using the 'hasPrevious' and 'previous' methods"); } diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java index 2aba15982..c1c1d403b 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.BeforeEach; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -667,7 +667,7 @@ protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncat //Date-comparison assertEquals(truncatedDate, DateUtils.truncate(truncatedDate, calendarField), "Truncating "+ fdf.format(truncatedDate) +" as Date with CalendarField-value "+ calendarField +" must return itself"); assertEquals(truncatedDate, DateUtils.truncate(lastTruncateDate, calendarField)); - assertFalse(truncatedDate.equals(DateUtils.truncate(nextTruncateDate, calendarField)), fdf.format(lastTruncateDate) +" is not an extreme when truncating as Date with CalendarField-value "+ calendarField); + assertNotEquals(truncatedDate, DateUtils.truncate(nextTruncateDate, calendarField), fdf.format(lastTruncateDate) + " is not an extreme when truncating as Date with CalendarField-value " + calendarField); //Calendar-initiations Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar; @@ -681,15 +681,15 @@ protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncat //Calendar-comparison assertEquals(truncatedCalendar, DateUtils.truncate(truncatedCalendar, calendarField), "Truncating "+ fdf.format(truncatedCalendar) +" as Calendar with CalendarField-value "+ calendarField +" must return itself"); assertEquals(truncatedCalendar, DateUtils.truncate(lastTruncateCalendar, calendarField)); - assertFalse(truncatedCalendar.equals(DateUtils.truncate(nextTruncateCalendar, calendarField)), fdf.format(lastTruncateCalendar) +" is not an extreme when truncating as Calendar with CalendarField-value "+ calendarField); + assertNotEquals(truncatedCalendar, DateUtils.truncate(nextTruncateCalendar, calendarField), fdf.format(lastTruncateCalendar) + " is not an extreme when truncating as Calendar with CalendarField-value " + calendarField); //Object-comparison assertEquals(truncatedDate, DateUtils.truncate((Object) truncatedDate, calendarField), "Truncating "+ fdf.format(truncatedDate) +" as Date cast to Object with CalendarField-value "+ calendarField +" must return itself as Date"); assertEquals(truncatedDate, DateUtils.truncate((Object) lastTruncateDate, calendarField)); - assertFalse(truncatedDate.equals(DateUtils.truncate((Object) nextTruncateDate, calendarField)), fdf.format(lastTruncateDate) +" is not an extreme when truncating as Date cast to Object with CalendarField-value "+ calendarField); + assertNotEquals(truncatedDate, DateUtils.truncate((Object) nextTruncateDate, calendarField), fdf.format(lastTruncateDate) + " is not an extreme when truncating as Date cast to Object with CalendarField-value " + calendarField); assertEquals(truncatedDate, DateUtils.truncate((Object) truncatedCalendar, calendarField), "Truncating "+ fdf.format(truncatedCalendar) +" as Calendar cast to Object with CalendarField-value "+ calendarField +" must return itself as Date"); assertEquals(truncatedDate, DateUtils.truncate((Object) lastTruncateCalendar, calendarField)); - assertFalse(truncatedDate.equals(DateUtils.truncate((Object) nextTruncateCalendar, calendarField)), fdf.format(lastTruncateCalendar) +" is not an extreme when truncating as Calendar cast to Object with CalendarField-value "+ calendarField); + assertNotEquals(truncatedDate, DateUtils.truncate((Object) nextTruncateCalendar, calendarField), fdf.format(lastTruncateCalendar) + " is not an extreme when truncating as Calendar cast to Object with CalendarField-value " + calendarField); } /** @@ -717,14 +717,14 @@ protected void roundToJanuaryFirst(final Date minDate, final Date maxDate, final final Date toPrevRoundDate = DateUtils.addMilliseconds(minDate, -1); final Date toNextRoundDate = DateUtils.addMilliseconds(maxDate, 1); - assertFalse(januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField)), fdf.format(minDate) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField); - assertFalse(januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField)), fdf.format(maxDate) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField); + assertNotEquals(januaryOneDate, DateUtils.round(toPrevRoundDate, calendarField), fdf.format(minDate) + " is not an lower-extreme when rounding as Date with CalendarField-value " + calendarField); + assertNotEquals(januaryOneDate, DateUtils.round(toNextRoundDate, calendarField), fdf.format(maxDate) + " is not an upper-extreme when rounding as Date with CalendarField-value " + calendarField); final Calendar toPrevRoundCalendar = Calendar.getInstance(); toPrevRoundCalendar.setTime(toPrevRoundDate); final Calendar toNextRoundCalendar = Calendar.getInstance(); toNextRoundCalendar.setTime(toNextRoundDate); - assertFalse(januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField)), fdf.format(minCalendar) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField); - assertFalse(januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField)), fdf.format(maxCalendar) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField); + assertNotEquals(januaryOneDate, DateUtils.round(toPrevRoundDate, calendarField), fdf.format(minCalendar) + " is not an lower-extreme when rounding as Date with CalendarField-value " + calendarField); + assertNotEquals(januaryOneDate, DateUtils.round(toNextRoundDate, calendarField), fdf.format(maxCalendar) + " is not an upper-extreme when rounding as Date with CalendarField-value " + calendarField); } } diff --git a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java index 8271c2b6b..3f2112405 100644 --- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java @@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -397,13 +398,11 @@ public void testLexx() { // test failures in equals final DurationFormatUtils.Token token = new DurationFormatUtils.Token(DurationFormatUtils.y, 4); - assertFalse(token.equals(new Object()), "Token equal to non-Token class. "); - assertFalse(token.equals(new DurationFormatUtils.Token(new Object())), - "Token equal to Token with wrong value class. "); - assertFalse(token.equals(new DurationFormatUtils.Token(DurationFormatUtils.y, 1)), - "Token equal to Token with different count. "); + assertNotEquals(token, new Object(), "Token equal to non-Token class. "); + assertNotEquals(token, new DurationFormatUtils.Token(new Object()), "Token equal to Token with wrong value class. "); + assertNotEquals(token, new DurationFormatUtils.Token(DurationFormatUtils.y, 1), "Token equal to Token with different count. "); final DurationFormatUtils.Token numToken = new DurationFormatUtils.Token(Integer.valueOf(1), 4); - assertTrue(numToken.equals(numToken), "Token with Number value not equal to itself. "); + assertEquals(numToken, numToken, "Token with Number value not equal to itself. "); } diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java index c6ee1fe4f..d62b57b9c 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java @@ -17,10 +17,9 @@ package org.apache.commons.lang3.time; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.text.FieldPosition; @@ -64,7 +63,7 @@ public void test_getInstance_String() { final FastDateFormat format2 = FastDateFormat.getInstance("MM-DD-yyyy"); final FastDateFormat format3 = FastDateFormat.getInstance("MM-DD-yyyy"); - assertTrue(format1 != format2); // -- junit 3.8 version -- assertFalse(format1 == format2); + assertNotSame(format1, format2); assertSame(format2, format3); assertEquals("MM/DD/yyyy", format1.getPattern()); assertEquals(TimeZone.getDefault(), format1.getTimeZone()); @@ -173,12 +172,12 @@ public void testCheckDifferingStyles() { final FastDateFormat longShort = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, Locale.US); final FastDateFormat longLong = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.LONG, Locale.US); - assertFalse(shortShort.equals(shortLong)); - assertFalse(shortShort.equals(longShort)); - assertFalse(shortShort.equals(longLong)); - assertFalse(shortLong.equals(longShort)); - assertFalse(shortLong.equals(longLong)); - assertFalse(longShort.equals(longLong)); + assertNotEquals(shortShort, shortLong); + assertNotEquals(shortShort, longShort); + assertNotEquals(shortShort, longLong); + assertNotEquals(shortLong, longShort); + assertNotEquals(shortLong, longLong); + assertNotEquals(longShort, longLong); } @Test diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index a7647c2db..99c9e42d0 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -462,7 +463,7 @@ private void testSdfAndFdp(final String format, final String date, final boolean } } // SDF and FDF should produce equivalent results - assertTrue((f==null)==(s==null), "Should both or neither throw Exceptions"); + assertEquals((f == null), (s == null), "Should both or neither throw Exceptions"); assertEquals(dsdf, dfdp, "Parsed dates should be equal"); } @@ -554,7 +555,7 @@ public void testEquals() { assertEquals(parser1, parser2); assertEquals(parser1.hashCode(), parser2.hashCode()); - assertFalse(parser1.equals(new Object())); + assertNotEquals(parser1, new Object()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java index 8a05740ec..096cbbb2c 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java @@ -17,7 +17,7 @@ package org.apache.commons.lang3.time; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -232,7 +232,7 @@ public void testEquals() { assertEquals(printer1, printer2); assertEquals(printer1.hashCode(), printer2.hashCode()); - assertFalse(printer1.equals(new Object())); + assertNotEquals(printer1, new Object()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java index 0d65b0e3c..332afe23f 100644 --- a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java +++ b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java @@ -160,7 +160,7 @@ public void testLang315() { } watch.stop(); final long totalTime = watch.getTime(); - assertTrue(suspendTime == totalTime); + assertEquals(suspendTime, totalTime); } // test bad states diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java index 6728b0f8d..260879a95 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java @@ -17,11 +17,10 @@ package org.apache.commons.lang3.tuple; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -66,12 +65,12 @@ public void testPairOf() { @Test public void testEquals() { assertEquals(ImmutablePair.of(null, "foo"), ImmutablePair.of(null, "foo")); - assertFalse(ImmutablePair.of("foo", 0).equals(ImmutablePair.of("foo", null))); - assertFalse(ImmutablePair.of("foo", "bar").equals(ImmutablePair.of("xyz", "bar"))); + assertNotEquals(ImmutablePair.of("foo", 0), ImmutablePair.of("foo", null)); + assertNotEquals(ImmutablePair.of("foo", "bar"), ImmutablePair.of("xyz", "bar")); final ImmutablePair p = ImmutablePair.of("foo", "bar"); - assertTrue(p.equals(p)); - assertFalse(p.equals(new Object())); + assertEquals(p, p); + assertNotEquals(p, new Object()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java index 874300fc9..8f76000bd 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java @@ -17,11 +17,10 @@ package org.apache.commons.lang3.tuple; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -74,12 +73,12 @@ public void testTripleOf() { @Test public void testEquals() { assertEquals(ImmutableTriple.of(null, "foo", 42), ImmutableTriple.of(null, "foo", 42)); - assertFalse(ImmutableTriple.of("foo", 0, Boolean.TRUE).equals(ImmutableTriple.of("foo", null, null))); - assertFalse(ImmutableTriple.of("foo", "bar", "baz").equals(ImmutableTriple.of("xyz", "bar", "blo"))); + assertNotEquals(ImmutableTriple.of("foo", 0, Boolean.TRUE), ImmutableTriple.of("foo", null, null)); + assertNotEquals(ImmutableTriple.of("foo", "bar", "baz"), ImmutableTriple.of("xyz", "bar", "blo")); final ImmutableTriple p = ImmutableTriple.of("foo", "bar", "baz"); - assertTrue(p.equals(p)); - assertFalse(p.equals(new Object())); + assertEquals(p, p); + assertNotEquals(p, new Object()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java index a3e3965ee..9d456219d 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java @@ -17,9 +17,8 @@ package org.apache.commons.lang3.tuple; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -72,12 +71,12 @@ public void testPairOf() { @Test public void testEquals() { assertEquals(MutablePair.of(null, "foo"), MutablePair.of(null, "foo")); - assertFalse(MutablePair.of("foo", 0).equals(MutablePair.of("foo", null))); - assertFalse(MutablePair.of("foo", "bar").equals(MutablePair.of("xyz", "bar"))); + assertNotEquals(MutablePair.of("foo", 0), MutablePair.of("foo", null)); + assertNotEquals(MutablePair.of("foo", "bar"), MutablePair.of("xyz", "bar")); final MutablePair p = MutablePair.of("foo", "bar"); - assertTrue(p.equals(p)); - assertFalse(p.equals(new Object())); + assertEquals(p, p); + assertNotEquals(p, new Object()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java index 01c2ae0cf..b5cca98ee 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java @@ -17,9 +17,8 @@ package org.apache.commons.lang3.tuple; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -79,13 +78,13 @@ public void testTripleOf() { @Test public void testEquals() { assertEquals(MutableTriple.of(null, "foo", "baz"), MutableTriple.of(null, "foo", "baz")); - assertFalse(MutableTriple.of("foo", 0, Boolean.TRUE).equals(MutableTriple.of("foo", null, Boolean.TRUE))); - assertFalse(MutableTriple.of("foo", "bar", "baz").equals(MutableTriple.of("xyz", "bar", "baz"))); - assertFalse(MutableTriple.of("foo", "bar", "baz").equals(MutableTriple.of("foo", "bar", "blo"))); + assertNotEquals(MutableTriple.of("foo", 0, Boolean.TRUE), MutableTriple.of("foo", null, Boolean.TRUE)); + assertNotEquals(MutableTriple.of("foo", "bar", "baz"), MutableTriple.of("xyz", "bar", "baz")); + assertNotEquals(MutableTriple.of("foo", "bar", "baz"), MutableTriple.of("foo", "bar", "blo")); final MutableTriple p = MutableTriple.of("foo", "bar", "baz"); - assertTrue(p.equals(p)); - assertFalse(p.equals(new Object())); + assertEquals(p, p); + assertNotEquals(p, new Object()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java index 2dc548357..dfbd98625 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/PairTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/PairTest.java @@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -56,7 +57,7 @@ public void testCompatibilityBetweenPairs() { assertTrue(set.contains(pair2)); pair2.setValue("bar"); - assertFalse(pair.equals(pair2)); + assertNotEquals(pair, pair2); assertFalse(pair.hashCode() == pair2.hashCode()); } @@ -74,9 +75,9 @@ public void testMapEntry() { public void testComparable1() { final Pair pair1 = Pair.of("A", "D"); final Pair pair2 = Pair.of("B", "C"); - assertTrue(pair1.compareTo(pair1) == 0); + assertEquals(0, pair1.compareTo(pair1)); assertTrue(pair1.compareTo(pair2) < 0); - assertTrue(pair2.compareTo(pair2) == 0); + assertEquals(0, pair2.compareTo(pair2)); assertTrue(pair2.compareTo(pair1) > 0); } @@ -84,9 +85,9 @@ public void testComparable1() { public void testComparable2() { final Pair pair1 = Pair.of("A", "C"); final Pair pair2 = Pair.of("A", "D"); - assertTrue(pair1.compareTo(pair1) == 0); + assertEquals(0, pair1.compareTo(pair1)); assertTrue(pair1.compareTo(pair2) < 0); - assertTrue(pair2.compareTo(pair2) == 0); + assertEquals(0, pair2.compareTo(pair2)); assertTrue(pair2.compareTo(pair1) > 0); } diff --git a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java index efa0ee74f..48ba48f9e 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/TripleTest.java @@ -59,9 +59,9 @@ public void testCompatibilityBetweenTriples() { public void testComparable1() { final Triple triple1 = Triple.of("A", "D", "A"); final Triple triple2 = Triple.of("B", "C", "A"); - assertTrue(triple1.compareTo(triple1) == 0); + assertEquals(0, triple1.compareTo(triple1)); assertTrue(triple1.compareTo(triple2) < 0); - assertTrue(triple2.compareTo(triple2) == 0); + assertEquals(0, triple2.compareTo(triple2)); assertTrue(triple2.compareTo(triple1) > 0); } @@ -69,9 +69,9 @@ public void testComparable1() { public void testComparable2() { final Triple triple1 = Triple.of("A", "C", "B"); final Triple triple2 = Triple.of("A", "D", "B"); - assertTrue(triple1.compareTo(triple1) == 0); + assertEquals(0, triple1.compareTo(triple1)); assertTrue(triple1.compareTo(triple2) < 0); - assertTrue(triple2.compareTo(triple2) == 0); + assertEquals(0, triple2.compareTo(triple2)); assertTrue(triple2.compareTo(triple1) > 0); } @@ -79,9 +79,9 @@ public void testComparable2() { public void testComparable3() { final Triple triple1 = Triple.of("A", "A", "D"); final Triple triple2 = Triple.of("A", "B", "C"); - assertTrue(triple1.compareTo(triple1) == 0); + assertEquals(0, triple1.compareTo(triple1)); assertTrue(triple1.compareTo(triple2) < 0); - assertTrue(triple2.compareTo(triple2) == 0); + assertEquals(0, triple2.compareTo(triple2)); assertTrue(triple2.compareTo(triple1) > 0); } @@ -89,9 +89,9 @@ public void testComparable3() { public void testComparable4() { final Triple triple1 = Triple.of("B", "A", "C"); final Triple triple2 = Triple.of("B", "A", "D"); - assertTrue(triple1.compareTo(triple1) == 0); + assertEquals(0, triple1.compareTo(triple1)); assertTrue(triple1.compareTo(triple2) < 0); - assertTrue(triple2.compareTo(triple2) == 0); + assertEquals(0, triple2.compareTo(triple2)); assertTrue(triple2.compareTo(triple1) > 0); }