You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2017/06/08 08:15:53 UTC
[19/48] [lang] Make sure lines in files don't have trailing white
spaces and remove all trailing white spaces
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
----------------------------------------------------------------------
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 ce94122..8d5de10 100644
--- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.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.
@@ -150,7 +150,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
@Test
public void testGetContextLabels() {
assertEquals(5, exceptionContext.getContextEntries().size());
-
+
exceptionContext.addContextValue("test2", "different value");
final Set<String> labels = exceptionContext.getContextLabels();
@@ -165,7 +165,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
@Test
public void testGetContextEntries() {
assertEquals(5, exceptionContext.getContextEntries().size());
-
+
exceptionContext.addContextValue("test2", "different value");
final List<Pair<String, Object>> entries = exceptionContext.getContextEntries();
@@ -177,7 +177,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext &
assertEquals("test Poorly written obj", entries.get(4).getKey());
assertEquals("test2", entries.get(5).getKey());
}
-
+
@Test
public void testJavaSerialization() {
exceptionContext.setContextValue("test Poorly written obj", "serializable replacement");
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java
index ee5e0c5..e0e6071 100644
--- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java
@@ -21,13 +21,13 @@ package org.apache.commons.lang3.exception;
* Base class for testing {@link Exception} descendants
*/
public abstract class AbstractExceptionTest {
-
+
protected static final String CAUSE_MESSAGE = "Cause message";
protected static final String EXCEPTION_MESSAGE = "Exception message";
-
+
protected static final String WRONG_EXCEPTION_MESSAGE = "Wrong exception message";
protected static final String WRONG_CAUSE_MESSAGE = "Wrong cause message";
-
+
protected Exception generateCause() {
return new Exception(CAUSE_MESSAGE);
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java
index 5406be5..6030f89 100644
--- a/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java
@@ -26,49 +26,49 @@ import static org.junit.Assert.assertNull;
* JUnit tests for {@link CloneFailedExceptionTest}.
*/
public class CloneFailedExceptionTest extends AbstractExceptionTest {
-
+
@Test(expected = CloneFailedException.class)
public void testThrowingInformativeException() throws Exception {
throw new CloneFailedException(EXCEPTION_MESSAGE, generateCause());
}
-
+
@Test(expected = CloneFailedException.class)
public void testThrowingExceptionWithMessage() throws Exception {
throw new CloneFailedException(EXCEPTION_MESSAGE);
}
-
+
@Test(expected = CloneFailedException.class)
public void testThrowingExceptionWithCause() throws Exception {
throw new CloneFailedException(generateCause());
}
-
+
@Test
public void testWithCauseAndMessage() throws Exception {
final Exception exception = new CloneFailedException(EXCEPTION_MESSAGE, generateCause());
assertNotNull(exception);
assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage());
-
+
final Throwable cause = exception.getCause();
assertNotNull(cause);
assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage());
}
-
+
@Test
public void testWithoutCause() throws Exception {
final Exception exception = new CloneFailedException(EXCEPTION_MESSAGE);
assertNotNull(exception);
assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage());
-
+
final Throwable cause = exception.getCause();
assertNull(cause);
}
-
+
@Test
public void testWithoutMessage() throws Exception {
final Exception exception = new CloneFailedException(generateCause());
assertNotNull(exception);
assertNotNull(exception.getMessage());
-
+
final Throwable cause = exception.getCause();
assertNotNull(cause);
assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage());
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
----------------------------------------------------------------------
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 75b66ab..9df0e75 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.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.
@@ -29,7 +29,7 @@ import org.junit.Test;
* JUnit tests for ContextedException.
*/
public class ContextedExceptionTest extends AbstractExceptionContextTest<ContextedException> {
-
+
@Override
public void setUp() throws Exception {
exceptionContext = new ContextedException(new Exception(TEST_MESSAGE));
@@ -49,7 +49,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
public void testContextedExceptionString() {
exceptionContext = new ContextedException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
-
+
final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.contains(TEST_MESSAGE));
}
@@ -74,7 +74,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
assertTrue(trace.contains(TEST_MESSAGE_2));
assertTrue(message.contains(TEST_MESSAGE_2));
}
-
+
@Test
public void testContextedExceptionStringThrowableContext() {
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
@@ -94,7 +94,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context
.addContextValue("test Date", new Date())
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
-
+
final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
----------------------------------------------------------------------
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 c10b1e8..3a32175 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.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.
@@ -30,7 +30,7 @@ import org.junit.Test;
* JUnit tests for ContextedRuntimeException.
*/
public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<ContextedRuntimeException> {
-
+
@Override
@Before
public void setUp() throws Exception {
@@ -51,7 +51,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
public void testContextedExceptionString() {
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE);
assertEquals(TEST_MESSAGE, exceptionContext.getMessage());
-
+
final String trace = ExceptionUtils.getStackTrace(exceptionContext);
assertTrue(trace.contains(TEST_MESSAGE));
}
@@ -76,11 +76,11 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
assertTrue(trace.contains(TEST_MESSAGE_2));
assertTrue(message.contains(TEST_MESSAGE_2));
}
-
+
@Test
public void testContextedExceptionStringThrowableContext() {
// Use an anonymous subclass to make sure users can provide custom implementations
- exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE),
+ exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE),
new DefaultExceptionContext() {private static final long serialVersionUID = 1L;});
final String message = exceptionContext.getMessage();
final String trace = ExceptionUtils.getStackTrace(exceptionContext);
@@ -98,7 +98,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
.addContextValue("test Date", new Date())
.addContextValue("test Nbr", Integer.valueOf(5))
.addContextValue("test Poorly written obj", new ObjectWithFaultyToString());
-
+
final String message = exceptionContext.getMessage();
assertTrue(message != null);
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java
index 79bf332..5a6c292 100644
--- a/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.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,14 +23,14 @@ import org.junit.Test;
* JUnit tests for DefaultExceptionContext.
*/
public class DefaultExceptionContextTest extends AbstractExceptionContextTest<DefaultExceptionContext> {
-
+
@Override
@Before
public void setUp() throws Exception {
exceptionContext = new DefaultExceptionContext();
super.setUp();
}
-
+
@Test
public void testFormattedExceptionMessageNull() {
exceptionContext = new DefaultExceptionContext();
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
index af8b847..00ec843 100644
--- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.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.
@@ -43,7 +43,7 @@ import org.junit.Test;
* @since 1.0
*/
public class ExceptionUtilsTest {
-
+
private NestableException nested;
private Throwable withCause;
private Throwable withoutCause;
@@ -98,7 +98,7 @@ public class ExceptionUtilsTest {
}
//-----------------------------------------------------------------------
-
+
@Test
public void testConstructor() {
assertNotNull(new ExceptionUtils());
@@ -108,7 +108,7 @@ public class ExceptionUtilsTest {
assertTrue(Modifier.isPublic(ExceptionUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(ExceptionUtils.class.getModifiers()));
}
-
+
//-----------------------------------------------------------------------
@SuppressWarnings("deprecation") // Specifically tests the deprecated methods
@Test
@@ -135,7 +135,7 @@ public class ExceptionUtilsTest {
assertSame(null, ExceptionUtils.getCause(withCause, new String[0]));
assertSame(null, ExceptionUtils.getCause(withCause, new String[] {null}));
assertSame(nested, ExceptionUtils.getCause(withCause, new String[] {"getCause"}));
-
+
// not known type, so match on supplied method names
assertSame(null, ExceptionUtils.getCause(withoutCause, null));
assertSame(null, ExceptionUtils.getCause(withoutCause, new String[0]));
@@ -263,22 +263,22 @@ public class ExceptionUtilsTest {
public void testIndexOf_ThrowableClass() {
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null));
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, null));
assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithCause.class));
assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, NestableException.class));
assertEquals(0, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithoutCause.class));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, null));
assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithCause.class));
assertEquals(0, ExceptionUtils.indexOfThrowable(nested, NestableException.class));
assertEquals(1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithoutCause.class));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, null));
assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class));
assertEquals(1, ExceptionUtils.indexOfThrowable(withCause, NestableException.class));
assertEquals(2, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithoutCause.class));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, Exception.class));
}
@@ -286,17 +286,17 @@ public class ExceptionUtilsTest {
public void testIndexOf_ThrowableClassInt() {
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null, 0));
assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class, 0));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, null));
assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithCause.class, 0));
assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, NestableException.class, 0));
assertEquals(0, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithoutCause.class, 0));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, null, 0));
assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithCause.class, 0));
assertEquals(0, ExceptionUtils.indexOfThrowable(nested, NestableException.class, 0));
assertEquals(1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithoutCause.class, 0));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, null));
assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 0));
assertEquals(1, ExceptionUtils.indexOfThrowable(withCause, NestableException.class, 0));
@@ -306,7 +306,7 @@ public class ExceptionUtilsTest {
assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 0));
assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 1));
assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 9));
-
+
assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, Exception.class, 0));
}
@@ -315,22 +315,22 @@ public class ExceptionUtilsTest {
public void testIndexOfType_ThrowableClass() {
assertEquals(-1, ExceptionUtils.indexOfType(null, null));
assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class));
-
+
assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, null));
assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, ExceptionWithCause.class));
assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, NestableException.class));
assertEquals(0, ExceptionUtils.indexOfType(withoutCause, ExceptionWithoutCause.class));
-
+
assertEquals(-1, ExceptionUtils.indexOfType(nested, null));
assertEquals(-1, ExceptionUtils.indexOfType(nested, ExceptionWithCause.class));
assertEquals(0, ExceptionUtils.indexOfType(nested, NestableException.class));
assertEquals(1, ExceptionUtils.indexOfType(nested, ExceptionWithoutCause.class));
-
+
assertEquals(-1, ExceptionUtils.indexOfType(withCause, null));
assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class));
assertEquals(1, ExceptionUtils.indexOfType(withCause, NestableException.class));
assertEquals(2, ExceptionUtils.indexOfType(withCause, ExceptionWithoutCause.class));
-
+
assertEquals(0, ExceptionUtils.indexOfType(withCause, Exception.class));
}
@@ -338,17 +338,17 @@ public class ExceptionUtilsTest {
public void testIndexOfType_ThrowableClassInt() {
assertEquals(-1, ExceptionUtils.indexOfType(null, null, 0));
assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class, 0));
-
+
assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, null));
assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, ExceptionWithCause.class, 0));
assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, NestableException.class, 0));
assertEquals(0, ExceptionUtils.indexOfType(withoutCause, ExceptionWithoutCause.class, 0));
-
+
assertEquals(-1, ExceptionUtils.indexOfType(nested, null, 0));
assertEquals(-1, ExceptionUtils.indexOfType(nested, ExceptionWithCause.class, 0));
assertEquals(0, ExceptionUtils.indexOfType(nested, NestableException.class, 0));
assertEquals(1, ExceptionUtils.indexOfType(nested, ExceptionWithoutCause.class, 0));
-
+
assertEquals(-1, ExceptionUtils.indexOfType(withCause, null));
assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 0));
assertEquals(1, ExceptionUtils.indexOfType(withCause, NestableException.class, 0));
@@ -358,7 +358,7 @@ public class ExceptionUtilsTest {
assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 0));
assertEquals(-1, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 1));
assertEquals(-1, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 9));
-
+
assertEquals(0, ExceptionUtils.indexOfType(withCause, Exception.class, 0));
}
@@ -369,27 +369,27 @@ public class ExceptionUtilsTest {
// could pipe system.err to a known stream, but not much point as
// internally this method calls stream method anyway
}
-
+
@Test
public void testPrintRootCauseStackTrace_ThrowableStream() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
ExceptionUtils.printRootCauseStackTrace(null, (PrintStream) null);
ExceptionUtils.printRootCauseStackTrace(null, new PrintStream(out));
assertEquals(0, out.toString().length());
-
+
out = new ByteArrayOutputStream(1024);
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null);
fail();
} catch (final IllegalArgumentException ex) {
}
-
+
out = new ByteArrayOutputStream(1024);
final Throwable cause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(cause, new PrintStream(out));
String stackTrace = out.toString();
assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
-
+
out = new ByteArrayOutputStream(1024);
ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintStream(out));
stackTrace = out.toString();
@@ -402,20 +402,20 @@ public class ExceptionUtilsTest {
ExceptionUtils.printRootCauseStackTrace(null, (PrintWriter) null);
ExceptionUtils.printRootCauseStackTrace(null, new PrintWriter(writer));
assertEquals(0, writer.getBuffer().length());
-
+
writer = new StringWriter(1024);
try {
ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null);
fail();
} catch (final IllegalArgumentException ex) {
}
-
+
writer = new StringWriter(1024);
final Throwable cause = createExceptionWithCause();
ExceptionUtils.printRootCauseStackTrace(cause, new PrintWriter(writer));
String stackTrace = writer.toString();
assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER));
-
+
writer = new StringWriter(1024);
ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintWriter(writer));
stackTrace = writer.toString();
@@ -426,7 +426,7 @@ public class ExceptionUtilsTest {
@Test
public void testGetRootCauseStackTrace_Throwable() throws Exception {
assertEquals(0, ExceptionUtils.getRootCauseStackTrace(null).length);
-
+
final Throwable cause = createExceptionWithCause();
String[] stackTrace = ExceptionUtils.getRootCauseStackTrace(cause);
boolean match = false;
@@ -437,7 +437,7 @@ public class ExceptionUtilsTest {
}
}
assertTrue(match);
-
+
stackTrace = ExceptionUtils.getRootCauseStackTrace(withoutCause);
match = false;
for (final String element : stackTrace) {
@@ -458,10 +458,10 @@ public class ExceptionUtilsTest {
public void test_getMessage_Throwable() {
Throwable th = null;
assertEquals("", ExceptionUtils.getMessage(th));
-
+
th = new IllegalArgumentException("Base");
assertEquals("IllegalArgumentException: Base", ExceptionUtils.getMessage(th));
-
+
th = new ExceptionWithCause("Wrapper", th);
assertEquals("ExceptionUtilsTest.ExceptionWithCause: Wrapper", ExceptionUtils.getMessage(th));
}
@@ -470,10 +470,10 @@ public class ExceptionUtilsTest {
public void test_getRootCauseMessage_Throwable() {
Throwable th = null;
assertEquals("", ExceptionUtils.getRootCauseMessage(th));
-
+
th = new IllegalArgumentException("Base");
assertEquals("IllegalArgumentException: Base", ExceptionUtils.getRootCauseMessage(th));
-
+
th = new ExceptionWithCause("Wrapper", th);
assertEquals("IllegalArgumentException: Base", ExceptionUtils.getRootCauseMessage(th));
}
@@ -522,9 +522,9 @@ public class ExceptionUtilsTest {
}
}
- // Temporary classes to allow the nested exception code to be removed
- // prior to a rewrite of this test class.
- private static class NestableException extends Exception {
+ // Temporary classes to allow the nested exception code to be removed
+ // prior to a rewrite of this test class.
+ private static class NestableException extends Exception {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unused")
@@ -554,7 +554,7 @@ public class ExceptionUtilsTest {
assertTrue(ioe instanceof IOException);
assertEquals(1, ExceptionUtils.getThrowableCount(ioe));
}
-
+
try {
redeclareCheckedException();
Assert.fail("Exception not thrown");
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/math/FractionTest.java
----------------------------------------------------------------------
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 d55b8d8..3c36761 100644
--- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java
@@ -30,7 +30,7 @@ import org.junit.Test;
* Test cases for the {@link Fraction} class
*/
public class FractionTest {
-
+
private static final int SKIP = 500; //53
//--------------------------------------------------------------------------
@@ -38,37 +38,37 @@ public class FractionTest {
public void testConstants() {
assertEquals(0, Fraction.ZERO.getNumerator());
assertEquals(1, Fraction.ZERO.getDenominator());
-
+
assertEquals(1, Fraction.ONE.getNumerator());
assertEquals(1, Fraction.ONE.getDenominator());
-
+
assertEquals(1, Fraction.ONE_HALF.getNumerator());
assertEquals(2, Fraction.ONE_HALF.getDenominator());
-
+
assertEquals(1, Fraction.ONE_THIRD.getNumerator());
assertEquals(3, Fraction.ONE_THIRD.getDenominator());
-
+
assertEquals(2, Fraction.TWO_THIRDS.getNumerator());
assertEquals(3, Fraction.TWO_THIRDS.getDenominator());
-
+
assertEquals(1, Fraction.ONE_QUARTER.getNumerator());
assertEquals(4, Fraction.ONE_QUARTER.getDenominator());
-
+
assertEquals(2, Fraction.TWO_QUARTERS.getNumerator());
assertEquals(4, Fraction.TWO_QUARTERS.getDenominator());
-
+
assertEquals(3, Fraction.THREE_QUARTERS.getNumerator());
assertEquals(4, Fraction.THREE_QUARTERS.getDenominator());
-
+
assertEquals(1, Fraction.ONE_FIFTH.getNumerator());
assertEquals(5, Fraction.ONE_FIFTH.getDenominator());
-
+
assertEquals(2, Fraction.TWO_FIFTHS.getNumerator());
assertEquals(5, Fraction.TWO_FIFTHS.getDenominator());
-
+
assertEquals(3, Fraction.THREE_FIFTHS.getNumerator());
assertEquals(5, Fraction.THREE_FIFTHS.getDenominator());
-
+
assertEquals(4, Fraction.FOUR_FIFTHS.getNumerator());
assertEquals(5, Fraction.FOUR_FIFTHS.getDenominator());
}
@@ -76,58 +76,58 @@ public class FractionTest {
@Test
public void testFactory_int_int() {
Fraction f = null;
-
+
// zero
f = Fraction.getFraction(0, 1);
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getFraction(0, 2);
assertEquals(0, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
// normal
f = Fraction.getFraction(1, 1);
assertEquals(1, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getFraction(2, 1);
assertEquals(2, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getFraction(23, 345);
assertEquals(23, f.getNumerator());
assertEquals(345, f.getDenominator());
-
+
// improper
f = Fraction.getFraction(22, 7);
assertEquals(22, f.getNumerator());
assertEquals(7, f.getDenominator());
-
+
// negatives
f = Fraction.getFraction(-6, 10);
assertEquals(-6, f.getNumerator());
assertEquals(10, f.getDenominator());
-
+
f = Fraction.getFraction(6, -10);
assertEquals(-6, f.getNumerator());
assertEquals(10, f.getDenominator());
-
+
f = Fraction.getFraction(-6, -10);
assertEquals(6, f.getNumerator());
assertEquals(10, f.getDenominator());
-
+
// zero denominator
try {
f = Fraction.getFraction(1, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(2, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(-3, 0);
fail("expecting ArithmeticException");
@@ -147,25 +147,25 @@ public class FractionTest {
@Test
public void testFactory_int_int_int() {
Fraction f = null;
-
+
// zero
f = Fraction.getFraction(0, 0, 2);
assertEquals(0, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getFraction(2, 0, 2);
assertEquals(4, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getFraction(0, 1, 2);
assertEquals(1, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
// normal
f = Fraction.getFraction(1, 1, 2);
assertEquals(3, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
// negatives
try {
f = Fraction.getFraction(1, -6, -10);
@@ -181,12 +181,12 @@ public class FractionTest {
f = Fraction.getFraction(1, -6, -10);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
// negative whole
f = Fraction.getFraction(-1, 6, 10);
assertEquals(-16, f.getNumerator());
assertEquals(10, f.getDenominator());
-
+
try {
f = Fraction.getFraction(-1, -6, 10);
fail("expecting ArithmeticException");
@@ -196,33 +196,33 @@ public class FractionTest {
f = Fraction.getFraction(-1, 6, -10);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(-1, -6, -10);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
// zero denominator
try {
f = Fraction.getFraction(0, 1, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(1, 2, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(-1, -3, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
- f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2);
+ f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(-Integer.MAX_VALUE, 1, 2);
fail("expecting ArithmeticException");
@@ -250,87 +250,87 @@ public class FractionTest {
@Test
public void testReducedFactory_int_int() {
Fraction f = null;
-
+
// zero
f = Fraction.getReducedFraction(0, 1);
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
// normal
f = Fraction.getReducedFraction(1, 1);
assertEquals(1, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getReducedFraction(2, 1);
assertEquals(2, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
// improper
f = Fraction.getReducedFraction(22, 7);
assertEquals(22, f.getNumerator());
assertEquals(7, f.getDenominator());
-
+
// negatives
f = Fraction.getReducedFraction(-6, 10);
assertEquals(-3, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f = Fraction.getReducedFraction(6, -10);
assertEquals(-3, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f = Fraction.getReducedFraction(-6, -10);
assertEquals(3, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
// zero denominator
try {
f = Fraction.getReducedFraction(1, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getReducedFraction(2, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getReducedFraction(-3, 0);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
- // reduced
+ // reduced
f = Fraction.getReducedFraction(0, 2);
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getReducedFraction(2, 2);
assertEquals(1, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getReducedFraction(2, 4);
assertEquals(1, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getReducedFraction(15, 10);
assertEquals(3, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getReducedFraction(121, 22);
assertEquals(11, f.getNumerator());
assertEquals(2, f.getDenominator());
-
- // Extreme values
+
+ // Extreme values
// OK, can reduce before negating
f = Fraction.getReducedFraction(-2, Integer.MIN_VALUE);
assertEquals(1, f.getNumerator());
assertEquals(-(Integer.MIN_VALUE / 2), f.getDenominator());
-
+
// Can't reduce, negation will throw
- try {
- f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE);
+ try {
+ f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE);
fail("Expecting ArithmeticException");
- } catch (final ArithmeticException ex) {}
+ } catch (final ArithmeticException ex) {}
// LANG-662
f = Fraction.getReducedFraction(Integer.MIN_VALUE, 2);
@@ -341,62 +341,62 @@ public class FractionTest {
@Test
public void testFactory_double() {
Fraction f = null;
-
+
try {
f = Fraction.getFraction(Double.NaN);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(Double.POSITIVE_INFINITY);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction(Double.NEGATIVE_INFINITY);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f = Fraction.getFraction((double) Integer.MAX_VALUE + 1);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
// zero
f = Fraction.getFraction(0.0d);
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
// one
f = Fraction.getFraction(1.0d);
assertEquals(1, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
// one half
f = Fraction.getFraction(0.5d);
assertEquals(1, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
// negative
f = Fraction.getFraction(-0.875d);
assertEquals(-7, f.getNumerator());
assertEquals(8, f.getDenominator());
-
+
// over 1
f = Fraction.getFraction(1.25d);
assertEquals(5, f.getNumerator());
assertEquals(4, f.getDenominator());
-
+
// two thirds
f = Fraction.getFraction(0.66666d);
assertEquals(2, f.getNumerator());
assertEquals(3, f.getDenominator());
-
+
// small
f = Fraction.getFraction(1.0d/10001d);
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
// normal
Fraction f2 = null;
for (int i = 1; i <= 100; i++) { // denominator
@@ -432,38 +432,38 @@ public class FractionTest {
public void testFactory_String() {
Fraction.getFraction(null);
}
-
-
+
+
@Test
public void testFactory_String_double() {
Fraction f = null;
-
+
f = Fraction.getFraction("0.0");
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getFraction("0.2");
assertEquals(1, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f = Fraction.getFraction("0.5");
assertEquals(1, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getFraction("0.66666");
assertEquals(2, f.getNumerator());
assertEquals(3, f.getDenominator());
-
+
try {
f = Fraction.getFraction("2.3R");
fail("Expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction("2147483648"); // too big
fail("Expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction(".");
fail("Expecting NumberFormatException");
@@ -473,46 +473,46 @@ public class FractionTest {
@Test
public void testFactory_String_proper() {
Fraction f = null;
-
+
f = Fraction.getFraction("0 0/1");
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getFraction("1 1/5");
assertEquals(6, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f = Fraction.getFraction("7 1/2");
assertEquals(15, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getFraction("1 2/4");
assertEquals(6, f.getNumerator());
assertEquals(4, f.getDenominator());
-
+
f = Fraction.getFraction("-7 1/2");
assertEquals(-15, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getFraction("-1 2/4");
assertEquals(-6, f.getNumerator());
assertEquals(4, f.getDenominator());
-
+
try {
f = Fraction.getFraction("2 3");
fail("expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction("a 3");
fail("expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction("2 b/4");
fail("expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction("2 ");
fail("expecting NumberFormatException");
@@ -522,7 +522,7 @@ public class FractionTest {
f = Fraction.getFraction(" 3");
fail("expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction(" ");
fail("expecting NumberFormatException");
@@ -532,46 +532,46 @@ public class FractionTest {
@Test
public void testFactory_String_improper() {
Fraction f = null;
-
+
f = Fraction.getFraction("0/1");
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f = Fraction.getFraction("1/5");
assertEquals(1, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f = Fraction.getFraction("1/2");
assertEquals(1, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f = Fraction.getFraction("2/3");
assertEquals(2, f.getNumerator());
assertEquals(3, f.getDenominator());
-
+
f = Fraction.getFraction("7/3");
assertEquals(7, f.getNumerator());
assertEquals(3, f.getDenominator());
-
+
f = Fraction.getFraction("2/4");
assertEquals(2, f.getNumerator());
assertEquals(4, f.getDenominator());
-
+
try {
f = Fraction.getFraction("2/d");
fail("expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction("2e/3");
fail("expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction("2/");
fail("expecting NumberFormatException");
} catch (final NumberFormatException ex) {}
-
+
try {
f = Fraction.getFraction("/");
fail("expecting NumberFormatException");
@@ -581,13 +581,13 @@ public class FractionTest {
@Test
public void testGets() {
Fraction f = null;
-
+
f = Fraction.getFraction(3, 5, 6);
assertEquals(23, f.getNumerator());
assertEquals(3, f.getProperWhole());
assertEquals(5, f.getProperNumerator());
assertEquals(6, f.getDenominator());
-
+
f = Fraction.getFraction(-3, 5, 6);
assertEquals(-23, f.getNumerator());
assertEquals(-3, f.getProperWhole());
@@ -600,22 +600,22 @@ public class FractionTest {
assertEquals(0, f.getProperNumerator());
assertEquals(1, f.getDenominator());
}
-
+
@Test
public void testConversions() {
Fraction f = null;
-
+
f = Fraction.getFraction(3, 7, 8);
assertEquals(3, f.intValue());
assertEquals(3L, f.longValue());
assertEquals(3.875f, f.floatValue(), 0.00001f);
assertEquals(3.875d, f.doubleValue(), 0.00001d);
}
-
+
@Test
public void testReduce() {
Fraction f = null;
-
+
f = Fraction.getFraction(50, 75);
Fraction result = f.reduce();
assertEquals(2, result.getNumerator());
@@ -660,26 +660,26 @@ public class FractionTest {
assertEquals(Integer.MIN_VALUE / 2, result.getNumerator());
assertEquals(1, result.getDenominator());
}
-
+
@Test
public void testInvert() {
Fraction f = null;
-
+
f = Fraction.getFraction(50, 75);
f = f.invert();
assertEquals(75, f.getNumerator());
assertEquals(50, f.getDenominator());
-
+
f = Fraction.getFraction(4, 3);
f = f.invert();
assertEquals(3, f.getNumerator());
assertEquals(4, f.getDenominator());
-
+
f = Fraction.getFraction(-15, 47);
f = f.invert();
assertEquals(-47, f.getNumerator());
assertEquals(15, f.getDenominator());
-
+
f = Fraction.getFraction(0, 3);
try {
f = f.invert();
@@ -698,16 +698,16 @@ public class FractionTest {
assertEquals(1, f.getNumerator());
assertEquals(Integer.MAX_VALUE, f.getDenominator());
}
-
+
@Test
public void testNegate() {
Fraction f = null;
-
+
f = Fraction.getFraction(50, 75);
f = f.negate();
assertEquals(-50, f.getNumerator());
assertEquals(75, f.getDenominator());
-
+
f = Fraction.getFraction(-50, 75);
f = f.negate();
assertEquals(50, f.getNumerator());
@@ -725,16 +725,16 @@ public class FractionTest {
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
}
-
+
@Test
public void testAbs() {
Fraction f = null;
-
+
f = Fraction.getFraction(50, 75);
f = f.abs();
assertEquals(50, f.getNumerator());
assertEquals(75, f.getDenominator());
-
+
f = Fraction.getFraction(-50, 75);
f = f.abs();
assertEquals(50, f.getNumerator());
@@ -756,14 +756,14 @@ public class FractionTest {
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
}
-
+
@Test
public void testPow() {
Fraction f = null;
-
+
f = Fraction.getFraction(3, 5);
assertEquals(Fraction.ONE, f.pow(0));
-
+
f = Fraction.getFraction(3, 5);
assertSame(f, f.pow(1));
assertEquals(f, f.pow(1));
@@ -772,26 +772,26 @@ public class FractionTest {
f = f.pow(2);
assertEquals(9, f.getNumerator());
assertEquals(25, f.getDenominator());
-
+
f = Fraction.getFraction(3, 5);
f = f.pow(3);
assertEquals(27, f.getNumerator());
assertEquals(125, f.getDenominator());
-
+
f = Fraction.getFraction(3, 5);
f = f.pow(-1);
assertEquals(5, f.getNumerator());
assertEquals(3, f.getDenominator());
-
+
f = Fraction.getFraction(3, 5);
f = f.pow(-2);
assertEquals(25, f.getNumerator());
assertEquals(9, f.getDenominator());
-
+
// check unreduced fractions stay that way.
f = Fraction.getFraction(6, 10);
assertEquals(Fraction.ONE, f.pow(0));
-
+
f = Fraction.getFraction(6, 10);
assertEquals(f, f.pow(1));
assertFalse(f.pow(1).equals(Fraction.getFraction(3,5)));
@@ -800,22 +800,22 @@ public class FractionTest {
f = f.pow(2);
assertEquals(9, f.getNumerator());
assertEquals(25, f.getDenominator());
-
+
f = Fraction.getFraction(6, 10);
f = f.pow(3);
assertEquals(27, f.getNumerator());
assertEquals(125, f.getDenominator());
-
+
f = Fraction.getFraction(6, 10);
f = f.pow(-1);
assertEquals(10, f.getNumerator());
assertEquals(6, f.getDenominator());
-
+
f = Fraction.getFraction(6, 10);
f = f.pow(-2);
assertEquals(25, f.getNumerator());
assertEquals(9, f.getDenominator());
-
+
// zero to any positive power is still zero.
f = Fraction.getFraction(0, 1231);
f = f.pow(1);
@@ -869,73 +869,73 @@ public class FractionTest {
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
}
-
+
@Test
public void testAdd() {
Fraction f = null;
Fraction f1 = null;
Fraction f2 = null;
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(1, 5);
f = f1.add(f2);
assertEquals(4, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(2, 5);
f = f1.add(f2);
assertEquals(1, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(3, 5);
f = f1.add(f2);
assertEquals(6, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(-4, 5);
f = f1.add(f2);
assertEquals(-1, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f1 = Fraction.getFraction(Integer.MAX_VALUE - 1, 1);
f2 = Fraction.ONE;
f = f1.add(f2);
assertEquals(Integer.MAX_VALUE, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(1, 2);
f = f1.add(f2);
assertEquals(11, f.getNumerator());
assertEquals(10, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 8);
f2 = Fraction.getFraction(1, 6);
f = f1.add(f2);
assertEquals(13, f.getNumerator());
assertEquals(24, f.getDenominator());
-
+
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(1, 5);
f = f1.add(f2);
assertSame(f2, f);
f = f2.add(f1);
assertSame(f2, f);
-
+
f1 = Fraction.getFraction(-1, 13*13*2*2);
f2 = Fraction.getFraction(-2, 13*17*2);
f = f1.add(f2);
assertEquals(13*13*17*2*2, f.getDenominator());
assertEquals(-17 - 2*13*2, f.getNumerator());
-
+
try {
f.add(null);
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {}
-
+
// if this fraction is added naively, it will overflow.
// check that it doesn't.
f1 = Fraction.getFraction(1,32768*3);
@@ -949,18 +949,18 @@ public class FractionTest {
f = f1.add(f2);
assertEquals(Integer.MIN_VALUE+1, f.getNumerator());
assertEquals(3, f.getDenominator());
-
+
f1 = Fraction.getFraction(Integer.MAX_VALUE - 1, 1);
f2 = Fraction.ONE;
f = f1.add(f2);
assertEquals(Integer.MAX_VALUE, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
try {
f = f.add(Fraction.ONE); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
} catch (final ArithmeticException ex) {}
-
+
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
f2 = Fraction.getFraction(-1,5);
@@ -968,19 +968,19 @@ public class FractionTest {
f = f1.add(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
} catch (final ArithmeticException ex) {}
-
+
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f= Fraction.getFraction(-Integer.MAX_VALUE, 1);
f = f.add(f);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
@@ -988,65 +988,65 @@ public class FractionTest {
fail("expecting ArithmeticException but got: " + f.toString());
} catch (final ArithmeticException ex) {}
}
-
+
@Test
public void testSubtract() {
Fraction f = null;
Fraction f1 = null;
Fraction f2 = null;
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(1, 5);
f = f1.subtract(f2);
assertEquals(2, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f1 = Fraction.getFraction(7, 5);
f2 = Fraction.getFraction(2, 5);
f = f1.subtract(f2);
assertEquals(1, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(3, 5);
f = f1.subtract(f2);
assertEquals(0, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(-4, 5);
f = f1.subtract(f2);
assertEquals(7, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(4, 5);
f = f1.subtract(f2);
assertEquals(-4, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(-4, 5);
f = f1.subtract(f2);
assertEquals(4, f.getNumerator());
assertEquals(5, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(1, 2);
f = f1.subtract(f2);
assertEquals(1, f.getNumerator());
assertEquals(10, f.getDenominator());
-
+
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(1, 5);
f = f2.subtract(f1);
assertSame(f2, f);
-
+
try {
f.subtract(null);
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {}
-
+
// if this fraction is subtracted naively, it will overflow.
// check that it doesn't.
f1 = Fraction.getFraction(1,32768*3);
@@ -1060,7 +1060,7 @@ public class FractionTest {
f = f1.subtract(f2);
assertEquals(Integer.MIN_VALUE+1, f.getNumerator());
assertEquals(3, f.getDenominator());
-
+
f1 = Fraction.getFraction(Integer.MAX_VALUE, 1);
f2 = Fraction.ONE;
f = f1.subtract(f2);
@@ -1073,7 +1073,7 @@ public class FractionTest {
f = f1.subtract(f2);
fail("expecting ArithmeticException"); //should overflow
} catch (final ArithmeticException ex) {}
-
+
// denominator should not be a multiple of 2 or 3 to trigger overflow
f1 = Fraction.getFraction(Integer.MIN_VALUE, 5);
f2 = Fraction.getFraction(1,5);
@@ -1081,19 +1081,19 @@ public class FractionTest {
f = f1.subtract(f2); // should overflow
fail("expecting ArithmeticException but got: " + f.toString());
} catch (final ArithmeticException ex) {}
-
+
try {
f= Fraction.getFraction(Integer.MIN_VALUE, 1);
f = f.subtract(Fraction.ONE);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f= Fraction.getFraction(Integer.MAX_VALUE, 1);
f = f.subtract(Fraction.ONE.negate());
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
f1 = Fraction.getFraction(3,327680);
f2 = Fraction.getFraction(2,59049);
try {
@@ -1101,19 +1101,19 @@ public class FractionTest {
fail("expecting ArithmeticException but got: " + f.toString());
} catch (final ArithmeticException ex) {}
}
-
+
@Test
public void testMultiply() {
Fraction f = null;
Fraction f1 = null;
Fraction f2 = null;
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(2, 5);
f = f1.multiplyBy(f2);
assertEquals(6, f.getNumerator());
assertEquals(25, f.getDenominator());
-
+
f1 = Fraction.getFraction(6, 10);
f2 = Fraction.getFraction(6, 10);
f = f1.multiplyBy(f2);
@@ -1122,31 +1122,31 @@ public class FractionTest {
f = f.multiplyBy(f2);
assertEquals(27, f.getNumerator());
assertEquals(125, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(-2, 5);
f = f1.multiplyBy(f2);
assertEquals(-6, f.getNumerator());
assertEquals(25, f.getDenominator());
-
+
f1 = Fraction.getFraction(-3, 5);
f2 = Fraction.getFraction(-2, 5);
f = f1.multiplyBy(f2);
assertEquals(6, f.getNumerator());
assertEquals(25, f.getDenominator());
-
-
+
+
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(2, 7);
f = f1.multiplyBy(f2);
assertSame(Fraction.ZERO, f);
-
+
f1 = Fraction.getFraction(2, 7);
f2 = Fraction.ONE;
f = f1.multiplyBy(f2);
assertEquals(2, f.getNumerator());
assertEquals(7, f.getDenominator());
-
+
f1 = Fraction.getFraction(Integer.MAX_VALUE, 1);
f2 = Fraction.getFraction(Integer.MIN_VALUE, Integer.MAX_VALUE);
f = f1.multiplyBy(f2);
@@ -1157,55 +1157,55 @@ public class FractionTest {
f.multiplyBy(null);
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {}
-
+
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
try {
f1 = Fraction.getFraction(1, -Integer.MAX_VALUE);
f = f1.multiplyBy(f1); // should overflow
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
}
-
+
@Test
public void testDivide() {
Fraction f = null;
Fraction f1 = null;
Fraction f2 = null;
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.getFraction(2, 5);
f = f1.divideBy(f2);
assertEquals(3, f.getNumerator());
assertEquals(2, f.getDenominator());
-
+
f1 = Fraction.getFraction(3, 5);
f2 = Fraction.ZERO;
try {
f = f1.divideBy(f2);
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
-
+
f1 = Fraction.getFraction(0, 5);
f2 = Fraction.getFraction(2, 7);
f = f1.divideBy(f2);
assertSame(Fraction.ZERO, f);
-
+
f1 = Fraction.getFraction(2, 7);
f2 = Fraction.ONE;
f = f1.divideBy(f2);
assertEquals(2, f.getNumerator());
assertEquals(7, f.getDenominator());
-
+
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
- f = f1.divideBy(f1);
+ f = f1.divideBy(f1);
assertEquals(1, f.getNumerator());
assertEquals(1, f.getDenominator());
-
+
f1 = Fraction.getFraction(Integer.MIN_VALUE, Integer.MAX_VALUE);
f2 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.divideBy(f2);
@@ -1216,7 +1216,7 @@ public class FractionTest {
f.divideBy(null);
fail("IllegalArgumentException");
} catch (final IllegalArgumentException ex) {}
-
+
try {
f1 = Fraction.getFraction(1, Integer.MAX_VALUE);
f = f1.divideBy(f1.invert()); // should overflow
@@ -1228,69 +1228,69 @@ public class FractionTest {
fail("expecting ArithmeticException");
} catch (final ArithmeticException ex) {}
}
-
+
@Test
public void testEquals() {
Fraction f1 = null;
Fraction f2 = null;
-
+
f1 = Fraction.getFraction(3, 5);
assertFalse(f1.equals(null));
assertFalse(f1.equals(new Object()));
assertFalse(f1.equals(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));
-
+
f2 = Fraction.getFraction(3, 5);
assertTrue(f1.equals(f2));
-
+
f2 = Fraction.getFraction(6, 10);
assertFalse(f1.equals(f2));
}
-
+
@Test
public void testHashCode() {
final Fraction f1 = Fraction.getFraction(3, 5);
Fraction f2 = Fraction.getFraction(3, 5);
-
+
assertTrue(f1.hashCode() == f2.hashCode());
-
+
f2 = Fraction.getFraction(2, 5);
assertTrue(f1.hashCode() != f2.hashCode());
-
+
f2 = Fraction.getFraction(6, 10);
assertTrue(f1.hashCode() != f2.hashCode());
}
-
+
@Test
public void testCompareTo() {
Fraction f1 = null;
Fraction f2 = null;
-
+
f1 = Fraction.getFraction(3, 5);
assertTrue(f1.compareTo(f1) == 0);
-
+
try {
f1.compareTo(null);
fail("expecting NullPointerException");
} catch (final NullPointerException ex) {}
-
+
f2 = Fraction.getFraction(2, 5);
assertTrue(f1.compareTo(f2) > 0);
assertTrue(f2.compareTo(f2) == 0);
-
+
f2 = Fraction.getFraction(4, 5);
assertTrue(f1.compareTo(f2) < 0);
assertTrue(f2.compareTo(f2) == 0);
-
+
f2 = Fraction.getFraction(3, 5);
assertTrue(f1.compareTo(f2) == 0);
assertTrue(f2.compareTo(f2) == 0);
-
+
f2 = Fraction.getFraction(6, 10);
assertTrue(f1.compareTo(f2) == 0);
assertTrue(f2.compareTo(f2) == 0);
@@ -1300,7 +1300,7 @@ public class FractionTest {
assertTrue(f2.compareTo(f2) == 0);
}
-
+
@Test
public void testToString() {
Fraction f = null;
@@ -1309,26 +1309,26 @@ public class FractionTest {
final String str = f.toString();
assertEquals("3/5", str);
assertSame(str, f.toString());
-
+
f = Fraction.getFraction(7, 5);
- assertEquals("7/5", f.toString());
-
+ assertEquals("7/5", f.toString());
+
f = Fraction.getFraction(4, 2);
- assertEquals("4/2", f.toString());
-
+ assertEquals("4/2", f.toString());
+
f = Fraction.getFraction(0, 2);
- assertEquals("0/2", f.toString());
-
+ assertEquals("0/2", f.toString());
+
f = Fraction.getFraction(2, 2);
- assertEquals("2/2", f.toString());
+ assertEquals("2/2", f.toString());
f = Fraction.getFraction(Integer.MIN_VALUE, 0, 1);
- assertEquals("-2147483648/1", f.toString());
+ assertEquals("-2147483648/1", f.toString());
f = Fraction.getFraction(-1, 1, Integer.MAX_VALUE);
assertEquals("-2147483648/2147483647", f.toString());
}
-
+
@Test
public void testToProperString() {
Fraction f = null;
@@ -1337,27 +1337,27 @@ public class FractionTest {
final String str = f.toProperString();
assertEquals("3/5", str);
assertSame(str, f.toProperString());
-
+
f = Fraction.getFraction(7, 5);
- assertEquals("1 2/5", f.toProperString());
-
+ assertEquals("1 2/5", f.toProperString());
+
f = Fraction.getFraction(14, 10);
- assertEquals("1 4/10", f.toProperString());
-
+ assertEquals("1 4/10", f.toProperString());
+
f = Fraction.getFraction(4, 2);
- assertEquals("2", f.toProperString());
-
+ assertEquals("2", f.toProperString());
+
f = Fraction.getFraction(0, 2);
- assertEquals("0", f.toProperString());
-
+ assertEquals("0", f.toProperString());
+
f = Fraction.getFraction(2, 2);
- assertEquals("1", f.toProperString());
-
+ assertEquals("1", f.toProperString());
+
f = Fraction.getFraction(-7, 5);
- assertEquals("-1 2/5", f.toProperString());
+ assertEquals("-1 2/5", f.toProperString());
f = Fraction.getFraction(Integer.MIN_VALUE, 0, 1);
- assertEquals("-2147483648", f.toProperString());
+ assertEquals("-2147483648", f.toProperString());
f = Fraction.getFraction(-1, 1, Integer.MAX_VALUE);
assertEquals("-1 1/2147483647", f.toProperString());
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
index 1c98c3d..026c0f7 100644
--- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.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.
@@ -101,5 +101,5 @@ public class IEEE754rUtilsTest {
public void testConstructorExists() {
new IEEE754rUtils();
}
-
+
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
----------------------------------------------------------------------
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 e504239..3a53c1e 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -114,7 +114,7 @@ public class NumberUtilsTest {
assertTrue("toFloat(String,int) 1 failed", NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f);
assertTrue("toFloat(String,int) 2 failed", NumberUtils.toFloat("a", 5.0f) == 5.0f);
}
-
+
/**
* Test for {(@link NumberUtils#createNumber(String)}
*/
@@ -123,7 +123,7 @@ public class NumberUtilsTest {
final String shouldBeFloat = "1.23";
final String shouldBeDouble = "3.40282354e+38";
final String shouldBeBigDecimal = "1.797693134862315759e+308";
-
+
assertTrue(NumberUtils.createNumber(shouldBeFloat) instanceof Float);
assertTrue(NumberUtils.createNumber(shouldBeDouble) instanceof Double);
assertTrue(NumberUtils.createNumber(shouldBeBigDecimal) instanceof BigDecimal);
@@ -243,7 +243,7 @@ public class NumberUtilsTest {
final Number bigNum = NumberUtils.createNumber("-1.1E-700F");
assertNotNull(bigNum);
assertEquals(BigDecimal.class, bigNum.getClass());
-
+
// LANG-1018
assertEquals("createNumber(String) LANG-1018 failed",
Double.valueOf("-160952.54"), NumberUtils.createNumber("-160952.54"));
@@ -254,7 +254,7 @@ public class NumberUtilsTest {
assertEquals("createNumber(String) LANG-1215 failed",
Double.valueOf("193343.82"), NumberUtils.createNumber("193343.82"));
}
-
+
@Test
public void testLang1087(){
// no sign cases
@@ -1418,7 +1418,7 @@ public class NumberUtilsTest {
}
fail("Expecting "+ expected + " for isCreatable/createNumber using \"" + val + "\" but got " + isValid + " and " + canCreate);
}
-
+
@Test
public void testIsParsable() {
assertFalse( NumberUtils.isParsable(null) );
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java
----------------------------------------------------------------------
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 67c6229..09c793c 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.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.
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue;
/**
* JUnit tests.
- *
+ *
* @since 2.2
* @see MutableBoolean
*/
@@ -41,7 +41,7 @@ public class MutableBooleanTest {
assertEquals(+1, mutBool.compareTo(new MutableBoolean(false)));
assertEquals(0, mutBool.compareTo(new MutableBoolean(true)));
}
-
+
@Test(expected=NullPointerException.class)
public void testCompareToNull() {
final MutableBoolean mutBool = new MutableBoolean(false);
@@ -88,7 +88,7 @@ public class MutableBooleanTest {
public void testGetSet() {
assertFalse(new MutableBoolean().booleanValue());
assertEquals(Boolean.FALSE, new MutableBoolean().getValue());
-
+
final MutableBoolean mutBool = new MutableBoolean(false);
assertEquals(Boolean.FALSE, mutBool.toBoolean());
assertFalse(mutBool.booleanValue());
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
----------------------------------------------------------------------
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 10d9aee..61dfd0d 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.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.
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue;
/**
* JUnit tests.
- *
+ *
* @see MutableByte
*/
public class MutableByteTest {
@@ -33,9 +33,9 @@ public class MutableByteTest {
@Test
public void testConstructors() {
assertEquals((byte) 0, new MutableByte().byteValue());
-
+
assertEquals((byte) 1, new MutableByte((byte) 1).byteValue());
-
+
assertEquals((byte) 2, new MutableByte(Byte.valueOf((byte) 2)).byteValue());
assertEquals((byte) 3, new MutableByte(new MutableByte((byte) 3)).byteValue());
@@ -53,15 +53,15 @@ public class MutableByteTest {
final MutableByte mutNum = new MutableByte((byte) 0);
assertEquals((byte) 0, new MutableByte().byteValue());
assertEquals(Byte.valueOf((byte) 0), new MutableByte().getValue());
-
+
mutNum.setValue((byte) 1);
assertEquals((byte) 1, mutNum.byteValue());
assertEquals(Byte.valueOf((byte) 1), mutNum.getValue());
-
+
mutNum.setValue(Byte.valueOf((byte) 2));
assertEquals((byte) 2, mutNum.byteValue());
assertEquals(Byte.valueOf((byte) 2), mutNum.getValue());
-
+
mutNum.setValue(new MutableByte((byte) 3));
assertEquals((byte) 3, mutNum.byteValue());
assertEquals(Byte.valueOf((byte) 3), mutNum.getValue());
@@ -121,7 +121,7 @@ public class MutableByteTest {
@Test
public void testPrimitiveValues() {
final MutableByte mutNum = new MutableByte( (byte) 1 );
-
+
assertEquals( 1.0F, mutNum.floatValue(), 0 );
assertEquals( 1.0, mutNum.doubleValue(), 0 );
assertEquals( (byte) 1, mutNum.byteValue() );
@@ -140,7 +140,7 @@ public class MutableByteTest {
public void testIncrement() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.increment();
-
+
assertEquals(2, mutNum.intValue());
assertEquals(2L, mutNum.longValue());
}
@@ -169,7 +169,7 @@ public class MutableByteTest {
public void testDecrement() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.decrement();
-
+
assertEquals(0, mutNum.intValue());
assertEquals(0L, mutNum.longValue());
}
@@ -198,7 +198,7 @@ public class MutableByteTest {
public void testAddValuePrimitive() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add((byte)1);
-
+
assertEquals((byte) 2, mutNum.byteValue());
}
@@ -206,7 +206,7 @@ public class MutableByteTest {
public void testAddValueObject() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.add(Integer.valueOf(1));
-
+
assertEquals((byte) 2, mutNum.byteValue());
}
@@ -250,7 +250,7 @@ public class MutableByteTest {
public void testSubtractValuePrimitive() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract((byte) 1);
-
+
assertEquals((byte) 0, mutNum.byteValue());
}
@@ -258,7 +258,7 @@ public class MutableByteTest {
public void testSubtractValueObject() {
final MutableByte mutNum = new MutableByte((byte) 1);
mutNum.subtract(Integer.valueOf(1));
-
+
assertEquals((byte) 0, mutNum.byteValue());
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
----------------------------------------------------------------------
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 8cfb8f3..df1b6d5 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.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.
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue;
/**
* JUnit tests.
- *
+ *
* @see MutableDouble
*/
public class MutableDoubleTest {
@@ -33,12 +33,12 @@ public class MutableDoubleTest {
@Test
public void testConstructors() {
assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d);
-
+
assertEquals(1d, new MutableDouble(1d).doubleValue(), 0.0001d);
-
+
assertEquals(2d, new MutableDouble(Double.valueOf(2d)).doubleValue(), 0.0001d);
assertEquals(3d, new MutableDouble(new MutableDouble(3d)).doubleValue(), 0.0001d);
-
+
assertEquals(2d, new MutableDouble("2.0").doubleValue(), 0.0001d);
}
@@ -53,15 +53,15 @@ public class MutableDoubleTest {
final MutableDouble mutNum = new MutableDouble(0d);
assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d);
assertEquals(Double.valueOf(0), new MutableDouble().getValue());
-
+
mutNum.setValue(1);
assertEquals(1d, mutNum.doubleValue(), 0.0001d);
assertEquals(Double.valueOf(1d), mutNum.getValue());
-
+
mutNum.setValue(Double.valueOf(2d));
assertEquals(2d, mutNum.doubleValue(), 0.0001d);
assertEquals(Double.valueOf(2d), mutNum.getValue());
-
+
mutNum.setValue(new MutableDouble(3d));
assertEquals(3d, mutNum.doubleValue(), 0.0001d);
assertEquals(Double.valueOf(3d), mutNum.getValue());
@@ -77,10 +77,10 @@ public class MutableDoubleTest {
public void testNanInfinite() {
MutableDouble mutNum = new MutableDouble(Double.NaN);
assertTrue(mutNum.isNaN());
-
+
mutNum = new MutableDouble(Double.POSITIVE_INFINITY);
assertTrue(mutNum.isInfinite());
-
+
mutNum = new MutableDouble(Double.NEGATIVE_INFINITY);
assertTrue(mutNum.isInfinite());
}
@@ -133,7 +133,7 @@ public class MutableDoubleTest {
@Test
public void testPrimitiveValues() {
final MutableDouble mutNum = new MutableDouble(1.7);
-
+
assertEquals( 1.7F, mutNum.floatValue(), 0 );
assertEquals( 1.7, mutNum.doubleValue(), 0 );
assertEquals( (byte) 1, mutNum.byteValue() );
@@ -152,7 +152,7 @@ public class MutableDoubleTest {
public void testIncrement() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.increment();
-
+
assertEquals(2, mutNum.intValue());
assertEquals(2L, mutNum.longValue());
}
@@ -181,7 +181,7 @@ public class MutableDoubleTest {
public void testDecrement() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.decrement();
-
+
assertEquals(0, mutNum.intValue());
assertEquals(0L, mutNum.longValue());
}
@@ -210,7 +210,7 @@ public class MutableDoubleTest {
public void testAddValuePrimitive() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(1.1d);
-
+
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
}
@@ -218,7 +218,7 @@ public class MutableDoubleTest {
public void testAddValueObject() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.add(Double.valueOf(1.1d));
-
+
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
}
@@ -262,7 +262,7 @@ public class MutableDoubleTest {
public void testSubtractValuePrimitive() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(0.9d);
-
+
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
}
@@ -270,7 +270,7 @@ public class MutableDoubleTest {
public void testSubtractValueObject() {
final MutableDouble mutNum = new MutableDouble(1);
mutNum.subtract(Double.valueOf(0.9d));
-
+
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
----------------------------------------------------------------------
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 af4abd8..169763a 100644
--- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java
+++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.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.
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue;
/**
* JUnit tests.
- *
+ *
* @see MutableFloat
*/
public class MutableFloatTest {
@@ -33,9 +33,9 @@ public class MutableFloatTest {
@Test
public void testConstructors() {
assertEquals(0f, new MutableFloat().floatValue(), 0.0001f);
-
+
assertEquals(1f, new MutableFloat(1f).floatValue(), 0.0001f);
-
+
assertEquals(2f, new MutableFloat(Float.valueOf(2f)).floatValue(), 0.0001f);
assertEquals(3f, new MutableFloat(new MutableFloat(3f)).floatValue(), 0.0001f);
@@ -53,15 +53,15 @@ public class MutableFloatTest {
final MutableFloat mutNum = new MutableFloat(0f);
assertEquals(0f, new MutableFloat().floatValue(), 0.0001f);
assertEquals(Float.valueOf(0), new MutableFloat().getValue());
-
+
mutNum.setValue(1);
assertEquals(1f, mutNum.floatValue(), 0.0001f);
assertEquals(Float.valueOf(1f), mutNum.getValue());
-
+
mutNum.setValue(Float.valueOf(2f));
assertEquals(2f, mutNum.floatValue(), 0.0001f);
assertEquals(Float.valueOf(2f), mutNum.getValue());
-
+
mutNum.setValue(new MutableFloat(3f));
assertEquals(3f, mutNum.floatValue(), 0.0001f);
assertEquals(Float.valueOf(3f), mutNum.getValue());
@@ -77,10 +77,10 @@ public class MutableFloatTest {
public void testNanInfinite() {
MutableFloat mutNum = new MutableFloat(Float.NaN);
assertTrue(mutNum.isNaN());
-
+
mutNum = new MutableFloat(Float.POSITIVE_INFINITY);
assertTrue(mutNum.isInfinite());
-
+
mutNum = new MutableFloat(Float.NEGATIVE_INFINITY);
assertTrue(mutNum.isInfinite());
}
@@ -133,7 +133,7 @@ public class MutableFloatTest {
@Test
public void testPrimitiveValues() {
final MutableFloat mutNum = new MutableFloat(1.7F);
-
+
assertEquals( 1, mutNum.intValue() );
assertEquals( 1.7, mutNum.doubleValue(), 0.00001 );
assertEquals( (byte) 1, mutNum.byteValue() );
@@ -152,7 +152,7 @@ public class MutableFloatTest {
public void testIncrement() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.increment();
-
+
assertEquals(2, mutNum.intValue());
assertEquals(2L, mutNum.longValue());
}
@@ -181,7 +181,7 @@ public class MutableFloatTest {
public void testDecrement() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.decrement();
-
+
assertEquals(0, mutNum.intValue());
assertEquals(0L, mutNum.longValue());
}
@@ -210,7 +210,7 @@ public class MutableFloatTest {
public void testAddValuePrimitive() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.add(1.1f);
-
+
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
}
@@ -218,7 +218,7 @@ public class MutableFloatTest {
public void testAddValueObject() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.add(Float.valueOf(1.1f));
-
+
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
}
@@ -262,7 +262,7 @@ public class MutableFloatTest {
public void testSubtractValuePrimitive() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(0.9f);
-
+
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
}
@@ -270,7 +270,7 @@ public class MutableFloatTest {
public void testSubtractValueObject() {
final MutableFloat mutNum = new MutableFloat(1);
mutNum.subtract(Float.valueOf(0.9f));
-
+
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
}