http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/main/java/org/apache/commons/lang3/time/StopWatch.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/time/StopWatch.java b/src/main/java/org/apache/commons/lang3/time/StopWatch.java index 0bd60a7..573fa86 100644 --- a/src/main/java/org/apache/commons/lang3/time/StopWatch.java +++ b/src/main/java/org/apache/commons/lang3/time/StopWatch.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit; * <p> * <code>StopWatch</code> provides a convenient API for timings. * </p> - * + * * <p> * To start the watch, call {@link #start()} or {@link StopWatch#createStarted()}. At this point you can: * </p> @@ -34,26 +34,26 @@ import java.util.concurrent.TimeUnit; * suspend and resume will not be counted in the total. At this point, these three options are available again.</li> * <li>{@link #stop()} the watch to complete the timing session.</li> * </ul> - * + * * <p> * It is intended that the output methods {@link #toString()} and {@link #getTime()} should only be called after stop, * split or suspend, however a suitable result will be returned at other points. * </p> - * + * * <p> * NOTE: As from v2.1, the methods protect against inappropriate calls. Thus you cannot now call stop before start, * resume before suspend or unsplit before split. * </p> - * + * * <p> * 1. split(), suspend(), or stop() cannot be invoked twice<br> * 2. unsplit() may only be called if the watch has been split()<br> * 3. resume() may only be called if the watch has been suspend()<br> * 4. start() cannot be called twice without calling reset() * </p> - * + * * <p>This class is not thread-safe</p> - * + * * @since 2.0 */ public class StopWatch { @@ -64,7 +64,7 @@ public class StopWatch { /** * Provides a started stopwatch for convenience. * - * @return StopWatch a stopwatch that's already been started. + * @return StopWatch a stopwatch that's already been started. * * @since 3.5 */ @@ -73,7 +73,7 @@ public class StopWatch { sw.start(); return sw; } - + /** * Enumeration type which indicates the status of stopwatch. */ @@ -136,7 +136,7 @@ public class StopWatch { /** * Enumeration type which indicates the split status of stopwatch. - */ + */ private enum SplitState { SPLIT, UNSPLIT @@ -157,8 +157,8 @@ public class StopWatch { private long startTime; /** - * The start time in Millis - nanoTime is only for elapsed time so we - * need to also store the currentTimeMillis to maintain the old + * The start time in Millis - nanoTime is only for elapsed time so we + * need to also store the currentTimeMillis to maintain the old * getStartTime API. */ private long startTimeMillis; @@ -181,11 +181,11 @@ public class StopWatch { * <p> * Start the stopwatch. * </p> - * + * * <p> * This method starts a new timing session, clearing any previous values. * </p> - * + * * @throws IllegalStateException * if the StopWatch is already running. */ @@ -206,11 +206,11 @@ public class StopWatch { * <p> * Stop the stopwatch. * </p> - * + * * <p> * This method ends a new timing session, allowing the time to be retrieved. * </p> - * + * * @throws IllegalStateException * if the StopWatch is not running. */ @@ -228,7 +228,7 @@ public class StopWatch { * <p> * Resets the stopwatch. Stops it if need be. * </p> - * + * * <p> * This method clears the internal values to allow the object to be reused. * </p> @@ -242,12 +242,12 @@ public class StopWatch { * <p> * Split the time. * </p> - * + * * <p> * This method sets the stop time of the watch to allow a time to be extracted. The start time is unaffected, * enabling {@link #unsplit()} to continue the timing from the original start point. * </p> - * + * * @throws IllegalStateException * if the StopWatch is not running. */ @@ -263,12 +263,12 @@ public class StopWatch { * <p> * Remove a split. * </p> - * + * * <p> * This method clears the stop time. The start time is unaffected, enabling timing from the original start point to * continue. * </p> - * + * * @throws IllegalStateException * if the StopWatch has not been split. */ @@ -283,12 +283,12 @@ public class StopWatch { * <p> * Suspend the stopwatch for later resumption. * </p> - * + * * <p> * This method suspends the watch until it is resumed. The watch will not include time between the suspend and * resume calls in the total time. * </p> - * + * * @throws IllegalStateException * if the StopWatch is not currently running. */ @@ -304,12 +304,12 @@ public class StopWatch { * <p> * Resume the stopwatch after a suspend. * </p> - * + * * <p> * This method resumes the watch after it was suspended. The watch will not include time between the suspend and * resume calls in the total time. * </p> - * + * * @throws IllegalStateException * if the StopWatch has not been suspended. */ @@ -325,12 +325,12 @@ public class StopWatch { * <p> * Get the time on the stopwatch. * </p> - * + * * <p> * This is either the time between the start and the moment this method is called, or the amount of time between * start and stop. * </p> - * + * * @return the time in milliseconds */ public long getTime() { @@ -341,14 +341,14 @@ public class StopWatch { * <p> * Get the time on the stopwatch in the specified TimeUnit. * </p> - * + * * <p> * This is either the time between the start and the moment this method is called, or the amount of time between * start and stop. The resulting time will be expressed in the desired TimeUnit with any remainder rounded down. * For example, if the specified unit is {@code TimeUnit.HOURS} and the stopwatch time is 59 minutes, then the * result returned will be {@code 0}. * </p> - * + * * @param timeUnit the unit of time, not null * @return the time in the specified TimeUnit, rounded down * @since 3.5 @@ -361,12 +361,12 @@ public class StopWatch { * <p> * Get the time on the stopwatch in nanoseconds. * </p> - * + * * <p> * This is either the time between the start and the moment this method is called, or the amount of time between * start and stop. * </p> - * + * * @return the time in nanoseconds * @since 3.0 */ @@ -385,13 +385,13 @@ public class StopWatch { * <p> * Get the split time on the stopwatch. * </p> - * + * * <p> * This is the time between start and latest split. * </p> - * + * * @return the split time in milliseconds - * + * * @throws IllegalStateException * if the StopWatch has not yet been split. * @since 2.1 @@ -403,13 +403,13 @@ public class StopWatch { * <p> * Get the split time on the stopwatch in nanoseconds. * </p> - * + * * <p> * This is the time between start and latest split. * </p> - * + * * @return the split time in nanoseconds - * + * * @throws IllegalStateException * if the StopWatch has not yet been split. * @since 3.0 @@ -423,7 +423,7 @@ public class StopWatch { /** * Returns the time this stopwatch was started. - * + * * @return the time this stopwatch was started * @throws IllegalStateException * if this StopWatch has not been started @@ -441,11 +441,11 @@ public class StopWatch { * <p> * Gets a summary of the time that the stopwatch recorded as a string. * </p> - * + * * <p> * The format used is ISO 8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> - * + * * @return the time as a String */ @Override @@ -457,11 +457,11 @@ public class StopWatch { * <p> * Gets a summary of the split time that the stopwatch recorded as a string. * </p> - * + * * <p> * The format used is ISO 8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> - * + * * @return the split time as a String * @since 2.1 */ @@ -509,6 +509,6 @@ public class StopWatch { */ public boolean isStopped() { return runningState.isStopped(); - } + } }
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java index 3df3a7f..e84c49b 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java @@ -18,12 +18,12 @@ package org.apache.commons.lang3.tuple; /** * <p>An immutable pair consisting of two {@code Object} elements.</p> - * + * * <p>Although the implementation is immutable, there is no restriction on the objects * that may be stored. If mutable objects are stored in the pair, then the pair * itself effectively becomes mutable. The class is also {@code final}, so a subclass * can not add undesirable behaviour.</p> - * + * * <p>#ThreadSafe# if both paired objects are thread-safe</p> * * @param <L> the left element type @@ -55,7 +55,7 @@ public final class ImmutablePair<L, R> extends Pair<L, R> { public static <L, R> ImmutablePair<L, R> nullPair() { return NULL; } - + /** Left object */ public final L left; /** Right object */ @@ -63,10 +63,10 @@ public final class ImmutablePair<L, R> extends Pair<L, R> { /** * <p>Obtains an immutable pair of from two objects inferring the generic types.</p> - * + * * <p>This factory allows the pair to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <R> the right element type * @param left the left element, may be null @@ -108,7 +108,7 @@ public final class ImmutablePair<L, R> extends Pair<L, R> { /** * <p>Throws {@code UnsupportedOperationException}.</p> - * + * * <p>This pair is immutable, so this operation is not supported.</p> * * @param value the value to set http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java index 83e212e..725f721 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java +++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java @@ -18,12 +18,12 @@ package org.apache.commons.lang3.tuple; /** * <p>An immutable triple consisting of three {@code Object} elements.</p> - * + * * <p>Although the implementation is immutable, there is no restriction on the objects * that may be stored. If mutable objects are stored in the triple, then the triple * itself effectively becomes mutable. The class is also {@code final}, so a subclass * can not add undesirable behaviour.</p> - * + * * <p>#ThreadSafe# if all three objects are thread-safe</p> * * @param <L> the left element type @@ -50,14 +50,14 @@ public final class ImmutableTriple<L, M, R> extends Triple<L, M, R> { * @param <L> the left element of this triple. Value is {@code null}. * @param <M> the middle element of this triple. Value is {@code null}. * @param <R> the right element of this triple. Value is {@code null}. - * @return an immutable triple of nulls. + * @return an immutable triple of nulls. * @since 3.6 */ @SuppressWarnings("unchecked") public static <L, M, R> ImmutableTriple<L, M, R> nullTriple() { return NULL; } - + /** Left object */ public final L left; /** Middle object */ @@ -67,10 +67,10 @@ public final class ImmutableTriple<L, M, R> extends Triple<L, M, R> { /** * <p>Obtains an immutable triple of from three objects inferring the generic types.</p> - * + * * <p>This factory allows the triple to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <M> the middle element type * @param <R> the right element type http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java index 3c99ac4..852edae 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java @@ -18,7 +18,7 @@ package org.apache.commons.lang3.tuple; /** * <p>A mutable pair consisting of two {@code Object} elements.</p> - * + * * <p>Not #ThreadSafe#</p> * * @param <L> the left element type @@ -38,10 +38,10 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * <p>Obtains an immutable pair of from two objects inferring the generic types.</p> - * + * * <p>This factory allows the pair to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <R> the right element type * @param left the left element, may be null @@ -82,7 +82,7 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * Sets the left element of the pair. - * + * * @param left the new value of the left element, may be null */ public void setLeft(final L left) { @@ -99,7 +99,7 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * Sets the right element of the pair. - * + * * @param right the new value of the right element, may be null */ public void setRight(final R right) { @@ -109,7 +109,7 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * Sets the {@code Map.Entry} value. * This sets the right element of the pair. - * + * * @param value the right value to set, not null * @return the old value for the right element */ http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/main/java/org/apache/commons/lang3/tuple/Pair.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/tuple/Pair.java b/src/main/java/org/apache/commons/lang3/tuple/Pair.java index de95170..3414d04 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/Pair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/Pair.java @@ -24,11 +24,11 @@ import org.apache.commons.lang3.builder.CompareToBuilder; /** * <p>A pair consisting of two elements.</p> - * + * * <p>This class is an abstract implementation defining the basic API. * It refers to the elements as 'left' and 'right'. It also implements the * {@code Map.Entry} interface where the key is 'left' and the value is 'right'.</p> - * + * * <p>Subclass implementations may be mutable or immutable. * However, there is no restriction on the type of the stored objects that may be stored. * If mutable objects are stored in the pair, then the pair itself effectively becomes mutable.</p> @@ -45,10 +45,10 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Obtains an immutable pair of from two objects inferring the generic types.</p> - * + * * <p>This factory allows the pair to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <R> the right element type * @param left the left element, may be null @@ -62,28 +62,28 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, //----------------------------------------------------------------------- /** * <p>Gets the left element from this pair.</p> - * + * * <p>When treated as a key-value pair, this is the key.</p> - * + * * @return the left element, may be null */ public abstract L getLeft(); /** * <p>Gets the right element from this pair.</p> - * + * * <p>When treated as a key-value pair, this is the value.</p> - * + * * @return the right element, may be null */ public abstract R getRight(); /** * <p>Gets the key from this pair.</p> - * + * * <p>This method implements the {@code Map.Entry} interface returning the * left element as the key.</p> - * + * * @return the left element as the key, may be null */ @Override @@ -93,10 +93,10 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Gets the value from this pair.</p> - * + * * <p>This method implements the {@code Map.Entry} interface returning the * right element as the value.</p> - * + * * @return the right element as the value, may be null */ @Override @@ -108,7 +108,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Compares the pair based on the left element followed by the right element. * The types must be {@code Comparable}.</p> - * + * * @param other the other pair, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -120,7 +120,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Compares this pair to another based on the two elements.</p> - * + * * @param obj the object to compare to, null returns false * @return true if the elements of the pair are equal */ @@ -140,7 +140,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Returns a suitable hash code. * The hash code follows the definition in {@code Map.Entry}.</p> - * + * * @return the hash code */ @Override @@ -152,7 +152,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Returns a String representation of this pair using the format {@code ($left,$right)}.</p> - * + * * @return a string describing this object, not null */ @Override @@ -162,12 +162,12 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Formats the receiver using the given format.</p> - * + * * <p>This uses {@link java.util.Formattable} to perform the formatting. Two variables may * be used to embed the left and right elements. Use {@code %1$s} for the left * element (key) and {@code %2$s} for the right element (value). * The default format used by {@code toString()} is {@code (%1$s,%2$s)}.</p> - * + * * @param format the format string, optionally containing {@code %1$s} and {@code %2$s}, not null * @return the formatted string, not null */ http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java index ee4a361..390b5f7 100644 --- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java @@ -350,7 +350,7 @@ public class AnnotationUtilsTest { NestAnnotation nest(); NestAnnotation[] nests(); } - + @Retention(RUNTIME) public @interface NestAnnotation { String string(); http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java index 28c6bbd..dbbcdfd 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java @@ -224,7 +224,7 @@ public class ArrayUtilsAddTest { assertTrue(Arrays.equals(new Float[]{Float.valueOf(3)}, newArray)); assertEquals(Float.class, newArray.getClass().getComponentType()); } - + @Test public void testLANG571(){ final String[] stringArray=null; http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java index 86b0916..80ff24d 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java @@ -28,34 +28,34 @@ import org.junit.Test; * Tests ArrayUtils insert methods. */ public class ArrayUtilsInsertTest { - + @Test public void testInsertBooleans() throws Exception { final boolean[] array = {true,false,true}; final boolean[] values = {false,true,false}; - + boolean[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); - assertArrayEquals(new boolean[0], ArrayUtils.insert(0, new boolean[0], null)); + + assertNull(ArrayUtils.insert(42, null, array)); + assertArrayEquals(new boolean[0], ArrayUtils.insert(0, new boolean[0], null)); assertNull(ArrayUtils.insert(42, (boolean[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new boolean[]{false,true,false,true}, ArrayUtils.insert(0, array, false)); assertArrayEquals(new boolean[]{true,false,false,true}, ArrayUtils.insert(1, array, false)); assertArrayEquals(new boolean[]{true,false,true,false}, ArrayUtils.insert(array.length, array, false)); @@ -69,29 +69,29 @@ public class ArrayUtilsInsertTest { public void testInsertBytes() throws Exception { final byte[] array = {1,2,3}; final byte[] values = {4,5,6}; - + byte[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new byte[0], ArrayUtils.insert(0, new byte[0], null)); assertNull(ArrayUtils.insert(42, (byte[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new byte[]{0,1,2,3}, ArrayUtils.insert(0, array, (byte) 0)); assertArrayEquals(new byte[]{1,0,2,3}, ArrayUtils.insert(1, array, (byte) 0)); assertArrayEquals(new byte[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (byte) 0)); @@ -99,34 +99,34 @@ public class ArrayUtilsInsertTest { assertArrayEquals(new byte[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new byte[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); } - + @Test public void testInsertChars() throws Exception { final char[] array = {'a','b','c'}; final char[] values = {'d','e','f'}; - + char[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new char[0], ArrayUtils.insert(0, new char[0], null)); assertNull(ArrayUtils.insert(42, (char[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new char[]{'z','a','b','c'}, ArrayUtils.insert(0, array, 'z')); assertArrayEquals(new char[]{'a','z','b','c'}, ArrayUtils.insert(1, array, 'z')); assertArrayEquals(new char[]{'a','b','c','z'}, ArrayUtils.insert(array.length, array, 'z')); @@ -134,219 +134,219 @@ public class ArrayUtilsInsertTest { assertArrayEquals(new char[]{'a','d','e','f','b','c'}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new char[]{'a','b','c','d','e','f'}, ArrayUtils.insert(array.length, array, values)); } - + @Test public void testInsertDoubles() throws Exception { final double[] array = {1,2,3}; final double[] values = {4,5,6}; final double delta = 0.000001; - + double[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new double[0], ArrayUtils.insert(0, new double[0], null), delta); assertNull(ArrayUtils.insert(42, (double[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new double[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta); assertArrayEquals(new double[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta); assertArrayEquals(new double[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta); assertArrayEquals(new double[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta); assertArrayEquals(new double[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta); assertArrayEquals(new double[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta); - } - + } + @Test public void testInsertFloats() throws Exception { final float[] array = {1,2,3}; final float[] values = {4,5,6}; final float delta = 0.000001f; - + float[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new float[0], ArrayUtils.insert(0, new float[0], null), delta); assertNull(ArrayUtils.insert(42, (float[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new float[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta); assertArrayEquals(new float[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta); assertArrayEquals(new float[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta); assertArrayEquals(new float[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta); assertArrayEquals(new float[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta); assertArrayEquals(new float[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta); - } - + } + @Test public void testInsertInts() throws Exception { final int[] array = {1,2,3}; final int[] values = {4,5,6}; - + int[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new int[0], ArrayUtils.insert(0, new int[0], null)); assertNull(ArrayUtils.insert(42, (int[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new int[]{0,1,2,3}, ArrayUtils.insert(0, array, 0)); assertArrayEquals(new int[]{1,0,2,3}, ArrayUtils.insert(1, array, 0)); assertArrayEquals(new int[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0)); assertArrayEquals(new int[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new int[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new int[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); - } - - + } + + @Test public void testInsertLongs() throws Exception { final long[] array = {1,2,3}; final long[] values = {4,5,6}; - + long[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new long[0], ArrayUtils.insert(0, new long[0], null)); assertNull(ArrayUtils.insert(42, (long[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new long[]{0,1,2,3}, ArrayUtils.insert(0, array, 0)); assertArrayEquals(new long[]{1,0,2,3}, ArrayUtils.insert(1, array, 0)); assertArrayEquals(new long[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0)); assertArrayEquals(new long[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new long[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new long[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); - } - - + } + + @Test public void testInsertShorts() throws Exception { final short[] array = {1,2,3}; final short[] values = {4,5,6}; - + short[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new short[0], ArrayUtils.insert(0, new short[0], null)); assertNull(ArrayUtils.insert(42, (short[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new short[]{0,1,2,3}, ArrayUtils.insert(0, array, (short) 0)); assertArrayEquals(new short[]{1,0,2,3}, ArrayUtils.insert(1, array, (short) 0)); assertArrayEquals(new short[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (short) 0)); assertArrayEquals(new short[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new short[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new short[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values)); - } - - + } + + @Test public void testInsertGenericArray() throws Exception { final String[] array = {"a","b","c"}; final String[] values = {"d","e","f"}; - + String[] result = ArrayUtils.insert(42, array, (String[]) null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new String[0], ArrayUtils.insert(0, new String[0], (String[]) null)); assertNull(ArrayUtils.insert(42, null, (String[]) null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + assertArrayEquals(new String[]{"z","a","b","c"}, ArrayUtils.insert(0, array, "z")); assertArrayEquals(new String[]{"a","z","b","c"}, ArrayUtils.insert(1, array, "z")); assertArrayEquals(new String[]{"a","b","c","z"}, ArrayUtils.insert(array.length, array, "z")); assertArrayEquals(new String[]{"d","e","f","a","b","c"}, ArrayUtils.insert(0, array, values)); assertArrayEquals(new String[]{"a","d","e","f","b","c"}, ArrayUtils.insert(1, array, values)); assertArrayEquals(new String[]{"a","b","c","d","e","f"}, ArrayUtils.insert(array.length, array, values)); - } + } } http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java index 3414027..9e596d4 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java index 0572f8c..95ea490 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -104,7 +104,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveByteArray() { byte[] array; @@ -133,7 +133,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveCharArray() { char[] array; @@ -162,7 +162,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveDoubleArray() { double[] array; @@ -191,7 +191,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveFloatArray() { float[] array; @@ -220,7 +220,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveIntArray() { int[] array; @@ -249,7 +249,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveLongArray() { long[] array; @@ -278,7 +278,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveShortArray() { short[] array; @@ -307,7 +307,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveElementObjectArray() { Object[] array; @@ -326,7 +326,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new Object[] {"b", "a"}, array)); assertEquals(Object.class, array.getClass().getComponentType()); } - + @Test public void testRemoveElementBooleanArray() { boolean[] array; @@ -345,7 +345,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new boolean[] {false, true}, array)); assertEquals(Boolean.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementByteArray() { byte[] array; @@ -364,7 +364,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new byte[] {2, 1}, array)); assertEquals(Byte.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementCharArray() { char[] array; @@ -383,7 +383,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new char[] {'b', 'a'}, array)); assertEquals(Character.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementDoubleArray() { @@ -403,7 +403,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new double[] {2, 1}, array)); assertEquals(Double.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementFloatArray() { @@ -423,7 +423,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new float[] {2, 1}, array)); assertEquals(Float.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementIntArray() { int[] array; @@ -442,7 +442,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new int[] {2, 1}, array)); assertEquals(Integer.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementLongArray() { @@ -462,7 +462,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new long[] {2, 1}, array)); assertEquals(Long.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementShortArray() { short[] array; @@ -481,7 +481,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new short[] {2, 1}, array)); assertEquals(Short.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveAllBooleanOccurences() { @@ -524,7 +524,7 @@ public class ArrayUtilsRemoveTest { a = new char[] { '1', '2', '2', '3', '2' }; assertTrue(Arrays.equals(new char[] { '1', '2', '2', '3', '2' }, ArrayUtils.removeAllOccurences(a, '4'))); } - + @Test public void testRemoveAllByteOccurences() { byte[] a = null; @@ -568,7 +568,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllIntOccurences() { + public void testRemoveAllIntOccurences() { int[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -586,10 +586,10 @@ public class ArrayUtilsRemoveTest { a = new int[] { 1, 2, 2, 3, 2 }; assertTrue(Arrays.equals(new int[] { 1, 2, 2, 3, 2 }, ArrayUtils.removeAllOccurences(a, 4))); - } - + } + @Test - public void testRemoveAllLongOccurences() { + public void testRemoveAllLongOccurences() { long[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -610,7 +610,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllFloatOccurences() { + public void testRemoveAllFloatOccurences() { float[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -631,7 +631,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllDoubleOccurences() { + public void testRemoveAllDoubleOccurences() { double[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -652,7 +652,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllObjectOccurences() { + public void testRemoveAllObjectOccurences() { String[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, "2"));