You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ba...@apache.org on 2006/12/29 19:48:38 UTC
svn commit: r491076 - in /jakarta/commons/proper/lang/trunk/src:
java/org/apache/commons/lang/math/NumberUtils.java
test/org/apache/commons/lang/math/NumberUtilsTest.java
Author: bayard
Date: Fri Dec 29 10:48:37 2006
New Revision: 491076
URL: http://svn.apache.org/viewvc?view=rev&rev=491076
Log:
Rolling back r467482 as the methods are already in java.util.Arrays. These were added as a part of #LANG-238.
Modified:
jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java?view=diff&rev=491076&r1=491075&r2=491076
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java (original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java Fri Dec 29 10:48:37 2006
@@ -666,170 +666,6 @@
return new BigDecimal(str);
}
- // Equals in array
- //--------------------------------------------------------------------
- /**
- * <p>Whether the contents of two byte[] arrays are equal.</p>
- *
- * @param array1 first array to compare
- * @param array2 second array to compare
- * @return whether the two arrays are equal
- */
- public static boolean equals(byte[] array1, byte[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- if (array1.length != array2.length) {
- return false;
- }
-
- for (int i=0; i<array1.length; i++) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * <p>Whether the contents of two short[] arrays are equal.</p>
- *
- * @param array1 first array to compare
- * @param array2 second array to compare
- * @return whether the two arrays are equal
- */
- public static boolean equals(short[] array1, short[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- if (array1.length != array2.length) {
- return false;
- }
-
- for (int i=0; i<array1.length; i++) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * <p>Whether the contents of two int[] arrays are equal.</p>
- *
- * @param array1 first array to compare
- * @param array2 second array to compare
- * @return whether the two arrays are equal
- */
- public static boolean equals(int[] array1, int[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- if (array1.length != array2.length) {
- return false;
- }
-
- for (int i=0; i<array1.length; i++) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * <p>Whether the contents of two long[] arrays are equal.</p>
- *
- * @param array1 first array to compare
- * @param array2 second array to compare
- * @return whether the two arrays are equal
- */
- public static boolean equals(long[] array1, long[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- if (array1.length != array2.length) {
- return false;
- }
-
- for (int i=0; i<array1.length; i++) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * <p>Whether the contents of two float[] arrays are equal.</p>
- *
- * @param array1 first array to compare
- * @param array2 second array to compare
- * @return whether the two arrays are equal
- */
- public static boolean equals(float[] array1, float[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- if (array1.length != array2.length) {
- return false;
- }
-
- for (int i=0; i<array1.length; i++) {
- if (compare(array1[i], array2[i]) != 0) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * <p>Whether the contents of two double[] arrays are equal.</p>
- *
- * @param array1 first array to compare
- * @param array2 second array to compare
- * @return whether the two arrays are equal
- */
- public static boolean equals(double[] array1, double[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- if (array1.length != array2.length) {
- return false;
- }
-
- for (int i=0; i<array1.length; i++) {
- if (compare(array1[i], array2[i]) != 0) {
- return false;
- }
- }
-
- return true;
- }
-
// Min in array
//--------------------------------------------------------------------
/**
Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java?view=diff&rev=491076&r1=491075&r2=491076
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java (original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java Fri Dec 29 10:48:37 2006
@@ -318,194 +318,6 @@
}
}
- // equals tests
- // ----------------------------------------------------------------------
- public void testEqualsByte() {
- byte[] array1 = null;
- byte[] array2 = null;
- assertEquals( true, NumberUtils.equals(array1, array2) );
- assertEquals( true, NumberUtils.equals(array2, array1) );
-
- array1 = new byte[] { 50, 20 }; // array2 still null
- assertEquals( false, NumberUtils.equals(array1, array2) );
- assertEquals( false, NumberUtils.equals(array2, array1) );
-
- // test same reference equivalence
- array2 = array1;
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test object equivalence
- array2 = new byte[] { 50, 20 };
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test symmetry is not equivalent
- array2 = new byte[] { 20, 50 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test the whole length of rhs is tested against
- array2 = new byte[] { 50, 20, 10 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test whole length of lhs is tested against
- array2 = new byte[] { 50 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
- }
-
- public void testEqualsShort() {
- short[] array1 = null;
- short[] array2 = null;
- assertEquals( true, NumberUtils.equals(array1, array2) );
- assertEquals( true, NumberUtils.equals(array2, array1) );
-
- array1 = new short[] { 50, 20 }; // array2 still null
- assertEquals( false, NumberUtils.equals(array1, array2) );
- assertEquals( false, NumberUtils.equals(array2, array1) );
-
- // test same reference equivalence
- array2 = array1;
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test object equivalence
- array2 = new short[] { 50, 20 };
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test symmetry is not equivalent
- array2 = new short[] { 20, 50 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test the whole length of rhs is tested against
- array2 = new short[] { 50, 20, 10 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test whole length of lhs is tested against
- array2 = new short[] { 50 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
- }
-
- public void testEqualsInt() {
- int[] array1 = null;
- int[] array2 = null;
- assertEquals( true, NumberUtils.equals(array1, array2) );
- assertEquals( true, NumberUtils.equals(array2, array1) );
-
- array1 = new int[] { 50, 20 }; // array2 still null
- assertEquals( false, NumberUtils.equals(array1, array2) );
- assertEquals( false, NumberUtils.equals(array2, array1) );
-
- // test same reference equivalence
- array2 = array1;
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test object equivalence
- array2 = new int[] { 50, 20 };
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test symmetry is not equivalent
- array2 = new int[] { 20, 50 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test the whole length of rhs is tested against
- array2 = new int[] { 50, 20, 10 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test whole length of lhs is tested against
- array2 = new int[] { 50 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
- }
-
- public void testEqualsLong() {
- long[] array1 = null;
- long[] array2 = null;
- assertEquals( true, NumberUtils.equals(array1, array2) );
- assertEquals( true, NumberUtils.equals(array2, array1) );
-
- array1 = new long[] { 50L, 20L }; // array2 still null
- assertEquals( false, NumberUtils.equals(array1, array2) );
- assertEquals( false, NumberUtils.equals(array2, array1) );
-
- // test same reference equivalence
- array2 = array1;
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test object equivalence
- array2 = new long[] { 50L, 20L };
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test symmetry is not equivalent
- array2 = new long[] { 20L, 50L };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test the whole length of rhs is tested against
- array2 = new long[] { 50L, 20L, 10L };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test whole length of lhs is tested against
- array2 = new long[] { 50L };
- assertEquals( false, NumberUtils.equals(array1, array2) );
- }
-
- public void testEqualsFloat() {
- float[] array1 = null;
- float[] array2 = null;
- assertEquals( true, NumberUtils.equals(array1, array2) );
- assertEquals( true, NumberUtils.equals(array2, array1) );
-
- array1 = new float[] { 50.6f, 20.6f }; // array2 still null
- assertEquals( false, NumberUtils.equals(array1, array2) );
- assertEquals( false, NumberUtils.equals(array2, array1) );
-
- // test same reference equivalence
- array2 = array1;
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test object equivalence
- array2 = new float[] { 50.6f, 20.6f };
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test symmetry is not equivalent
- array2 = new float[] { 20.6f, 50.6f };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test the whole length of rhs is tested against
- array2 = new float[] { 50.6f, 20.6f, 10.6f };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test whole length of lhs is tested against
- array2 = new float[] { 50.6f };
- assertEquals( false, NumberUtils.equals(array1, array2) );
- }
-
- public void testEqualsDouble() {
- double[] array1 = null;
- double[] array2 = null;
- assertEquals( true, NumberUtils.equals(array1, array2) );
- assertEquals( true, NumberUtils.equals(array2, array1) );
-
- array1 = new double[] { 50.6, 20.6 }; // array2 still null
- assertEquals( false, NumberUtils.equals(array1, array2) );
- assertEquals( false, NumberUtils.equals(array2, array1) );
-
- // test same reference equivalence
- array2 = array1;
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test object equivalence
- array2 = new double[] { 50.6, 20.6 };
- assertEquals( true, NumberUtils.equals(array1, array2) );
-
- // test symmetry is not equivalent
- array2 = new double[] { 20.6, 50.6 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test the whole length of rhs is tested against
- array2 = new double[] { 50.6, 20.6, 10.6 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
-
- // test whole length of lhs is tested against
- array2 = new double[] { 50.6 };
- assertEquals( false, NumberUtils.equals(array1, array2) );
- }
-
// min/max tests
// ----------------------------------------------------------------------
public void testMinLong() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org