Increment, decrement add and subtract methods
from Stephen Putman git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@387322 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
976c15d1a3
commit
62a97240a5
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2005 The Apache Software Foundation.
|
||||
* Copyright 2004-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
|
@ -153,6 +152,78 @@ public class MutableByte extends Number implements Comparable, Mutable {
|
|||
return new Byte(byteValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Increments the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void increment() {
|
||||
value++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void decrement() {
|
||||
value--;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(byte operand) {
|
||||
this.value += operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(Number operand) {
|
||||
this.value += operand.byteValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(byte operand) {
|
||||
this.value -= operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(Number operand) {
|
||||
this.value -= operand.byteValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Compares this object against the specified object. The result is <code>true</code> if and only if the argument
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2005 The Apache Software Foundation.
|
||||
* Copyright 2004-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
@ -164,6 +163,78 @@ public class MutableDouble extends Number implements Comparable, Mutable {
|
|||
return new Double(doubleValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Increments the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void increment() {
|
||||
value++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void decrement() {
|
||||
value--;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(double operand) {
|
||||
this.value += operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(Number operand) {
|
||||
this.value += operand.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(double operand) {
|
||||
this.value -= operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(Number operand) {
|
||||
this.value -= operand.doubleValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Compares this object against the specified object. The result is <code>true</code> if and only if the argument
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2005 The Apache Software Foundation.
|
||||
* Copyright 2004-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
@ -98,6 +97,78 @@ public class MutableFloat extends Number implements Comparable, Mutable {
|
|||
setValue(((Number) value).floatValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Increments the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void increment() {
|
||||
value++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void decrement() {
|
||||
value--;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(float operand) {
|
||||
this.value += operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(Number operand) {
|
||||
this.value += operand.floatValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(float operand) {
|
||||
this.value -= operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(Number operand) {
|
||||
this.value -= operand.floatValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// shortValue and bytValue rely on Number implementation
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2005 The Apache Software Foundation.
|
||||
* Copyright 2004-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
|
@ -96,6 +95,78 @@ public class MutableInt extends Number implements Comparable, Mutable {
|
|||
setValue(((Number) value).intValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Increments the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void increment() {
|
||||
value++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void decrement() {
|
||||
value--;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(int operand) {
|
||||
this.value += operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(Number operand) {
|
||||
this.value += operand.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(int operand) {
|
||||
this.value -= operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(Number operand) {
|
||||
this.value -= operand.intValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// shortValue and bytValue rely on Number implementation
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2005 The Apache Software Foundation.
|
||||
* Copyright 2004-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
|
@ -96,6 +95,78 @@ public class MutableLong extends Number implements Comparable, Mutable {
|
|||
setValue(((Number) value).longValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Increments the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void increment() {
|
||||
value++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void decrement() {
|
||||
value--;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(long operand) {
|
||||
this.value += operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(Number operand) {
|
||||
this.value += operand.longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(long operand) {
|
||||
this.value -= operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(Number operand) {
|
||||
this.value -= operand.longValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// shortValue and bytValue rely on Number implementation
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2005 The Apache Software Foundation.
|
||||
* Copyright 2004-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
|
@ -96,6 +95,78 @@ public class MutableShort extends Number implements Comparable, Mutable {
|
|||
setValue(((Number) value).shortValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Increments the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void increment() {
|
||||
value++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the value.
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void decrement() {
|
||||
value--;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(short operand) {
|
||||
this.value += operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void add(Number operand) {
|
||||
this.value += operand.shortValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(short operand) {
|
||||
this.value -= operand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts a value.
|
||||
*
|
||||
* @param operand
|
||||
* the value to add
|
||||
* @throws NullPointerException
|
||||
* if the object is null
|
||||
*
|
||||
* @since Commons Lang 2.2
|
||||
*/
|
||||
public void subtract(Number operand) {
|
||||
this.value -= operand.shortValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// bytValue relies on Number implementation
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 The Apache Software Foundation.
|
||||
* Copyright 2002-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -144,6 +144,50 @@ public class MutableByteTest extends TestCase {
|
|||
assertEquals(new Byte((byte) 123), new MutableByte((byte) 123).toByte());
|
||||
}
|
||||
|
||||
public void testIncrement() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.increment();
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testDecrement() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.decrement();
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValuePrimitive() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.add((byte)1);
|
||||
|
||||
assertEquals((byte) 2, mutNum.byteValue());
|
||||
}
|
||||
|
||||
public void testAddValueObject() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.add(new Integer(1));
|
||||
|
||||
assertEquals((byte) 2, mutNum.byteValue());
|
||||
}
|
||||
|
||||
public void testSubtractValuePrimitive() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.subtract((byte) 1);
|
||||
|
||||
assertEquals((byte) 0, mutNum.byteValue());
|
||||
}
|
||||
|
||||
public void testSubtractValueObject() {
|
||||
MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.subtract(new Integer(1));
|
||||
|
||||
assertEquals((byte) 0, mutNum.byteValue());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableByte((byte) 0).toString());
|
||||
assertEquals("10", new MutableByte((byte) 10).toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 The Apache Software Foundation.
|
||||
* Copyright 2002-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -155,6 +155,50 @@ public class MutableDoubleTest extends TestCase {
|
|||
assertEquals(new Double(12.3d), new MutableDouble(12.3d).toDouble());
|
||||
}
|
||||
|
||||
public void testIncrement() {
|
||||
MutableDouble mutNum = new MutableDouble(1);
|
||||
mutNum.increment();
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testDecrement() {
|
||||
MutableDouble mutNum = new MutableDouble(1);
|
||||
mutNum.decrement();
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValuePrimitive() {
|
||||
MutableDouble mutNum = new MutableDouble(1);
|
||||
mutNum.add(1.1d);
|
||||
|
||||
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
|
||||
}
|
||||
|
||||
public void testAddValueObject() {
|
||||
MutableDouble mutNum = new MutableDouble(1);
|
||||
mutNum.add(new Double(1.1d));
|
||||
|
||||
assertEquals(2.1d, mutNum.doubleValue(), 0.01d);
|
||||
}
|
||||
|
||||
public void testSubtractValuePrimitive() {
|
||||
MutableDouble mutNum = new MutableDouble(1);
|
||||
mutNum.subtract(0.9d);
|
||||
|
||||
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
|
||||
}
|
||||
|
||||
public void testSubtractValueObject() {
|
||||
MutableDouble mutNum = new MutableDouble(1);
|
||||
mutNum.subtract(new Double(0.9d));
|
||||
|
||||
assertEquals(0.1d, mutNum.doubleValue(), 0.01d);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0.0", new MutableDouble(0d).toString());
|
||||
assertEquals("10.0", new MutableDouble(10d).toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 The Apache Software Foundation.
|
||||
* Copyright 2002-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -155,6 +155,50 @@ public class MutableFloatTest extends TestCase {
|
|||
assertEquals(new Float(12.3f), new MutableFloat(12.3f).toFloat());
|
||||
}
|
||||
|
||||
public void testIncrement() {
|
||||
MutableFloat mutNum = new MutableFloat(1);
|
||||
mutNum.increment();
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testDecrement() {
|
||||
MutableFloat mutNum = new MutableFloat(1);
|
||||
mutNum.decrement();
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValuePrimitive() {
|
||||
MutableFloat mutNum = new MutableFloat(1);
|
||||
mutNum.add(1.1f);
|
||||
|
||||
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
|
||||
}
|
||||
|
||||
public void testAddValueObject() {
|
||||
MutableFloat mutNum = new MutableFloat(1);
|
||||
mutNum.add(new Float(1.1f));
|
||||
|
||||
assertEquals(2.1f, mutNum.floatValue(), 0.01f);
|
||||
}
|
||||
|
||||
public void testSubtractValuePrimitive() {
|
||||
MutableFloat mutNum = new MutableFloat(1);
|
||||
mutNum.subtract(0.9f);
|
||||
|
||||
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
|
||||
}
|
||||
|
||||
public void testSubtractValueObject() {
|
||||
MutableFloat mutNum = new MutableFloat(1);
|
||||
mutNum.subtract(new Float(0.9f));
|
||||
|
||||
assertEquals(0.1f, mutNum.floatValue(), 0.01f);
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0.0", new MutableFloat(0f).toString());
|
||||
assertEquals("10.0", new MutableFloat(10f).toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 The Apache Software Foundation.
|
||||
* Copyright 2002-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -150,6 +150,54 @@ public class MutableIntTest extends TestCase {
|
|||
assertEquals(new Integer(123), new MutableInt(123).toInteger());
|
||||
}
|
||||
|
||||
public void testIncrement() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.increment();
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testDecrement() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.decrement();
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValuePrimitive() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.add(1);
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValueObject() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.add(new Integer(1));
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testSubtractValuePrimitive() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.subtract(1);
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testSubtractValueObject() {
|
||||
MutableInt mutNum = new MutableInt(1);
|
||||
mutNum.subtract(new Integer(1));
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableInt(0).toString());
|
||||
assertEquals("10", new MutableInt(10).toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 The Apache Software Foundation.
|
||||
* Copyright 2002-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -144,6 +144,54 @@ public class MutableLongTest extends TestCase {
|
|||
assertEquals(new Long(123L), new MutableLong(123L).toLong());
|
||||
}
|
||||
|
||||
public void testIncrement() {
|
||||
MutableLong mutNum = new MutableLong(1);
|
||||
mutNum.increment();
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testDecrement() {
|
||||
MutableLong mutNum = new MutableLong(1);
|
||||
mutNum.decrement();
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValuePrimitive() {
|
||||
MutableLong mutNum = new MutableLong(1);
|
||||
mutNum.add(1);
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValueObject() {
|
||||
MutableLong mutNum = new MutableLong(1);
|
||||
mutNum.add(new Long(1));
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testSubtractValuePrimitive() {
|
||||
MutableLong mutNum = new MutableLong(1);
|
||||
mutNum.subtract(1);
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testSubtractValueObject() {
|
||||
MutableLong mutNum = new MutableLong(1);
|
||||
mutNum.subtract(new Long(1));
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableLong(0).toString());
|
||||
assertEquals("10", new MutableLong(10).toString());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2005 The Apache Software Foundation.
|
||||
* Copyright 2002-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -144,6 +144,50 @@ public class MutableShortTest extends TestCase {
|
|||
assertEquals(new Short((short) 123), new MutableShort((short) 123).toShort());
|
||||
}
|
||||
|
||||
public void testIncrement() {
|
||||
MutableShort mutNum = new MutableShort((short) 1);
|
||||
mutNum.increment();
|
||||
|
||||
assertEquals(2, mutNum.intValue());
|
||||
assertEquals(2L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testDecrement() {
|
||||
MutableShort mutNum = new MutableShort((short) 1);
|
||||
mutNum.decrement();
|
||||
|
||||
assertEquals(0, mutNum.intValue());
|
||||
assertEquals(0L, mutNum.longValue());
|
||||
}
|
||||
|
||||
public void testAddValuePrimitive() {
|
||||
MutableShort mutNum = new MutableShort((short) 1);
|
||||
mutNum.add((short) 1);
|
||||
|
||||
assertEquals((short) 2, mutNum.shortValue());
|
||||
}
|
||||
|
||||
public void testAddValueObject() {
|
||||
MutableShort mutNum = new MutableShort((short) 1);
|
||||
mutNum.add(new Short((short) 1));
|
||||
|
||||
assertEquals((short) 2, mutNum.shortValue());
|
||||
}
|
||||
|
||||
public void testSubtractValuePrimitive() {
|
||||
MutableShort mutNum = new MutableShort((short) 1);
|
||||
mutNum.subtract((short) 1);
|
||||
|
||||
assertEquals((short) 0, mutNum.shortValue());
|
||||
}
|
||||
|
||||
public void testSubtractValueObject() {
|
||||
MutableShort mutNum = new MutableShort((short) 1);
|
||||
mutNum.subtract(new Short((short) 1));
|
||||
|
||||
assertEquals((short) 0, mutNum.shortValue());
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
assertEquals("0", new MutableShort((short) 0).toString());
|
||||
assertEquals("10", new MutableShort((short) 10).toString());
|
||||
|
|
Loading…
Reference in New Issue