commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r387322 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/mutable/ test/org/apache/commons/lang/mutable/
Date Mon, 20 Mar 2006 22:09:49 GMT
Author: scolebourne
Date: Mon Mar 20 14:09:44 2006
New Revision: 387322

URL: http://svn.apache.org/viewcvs?rev=387322&view=rev
Log:
Increment, decrement add and subtract methods
from Stephen Putman

Modified:
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
Mon Mar 20 14:09:44 2006
@@ -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;
 
 /**
@@ -151,6 +150,78 @@
      */
     public Byte toByte() {
         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();
     }
 
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
Mon Mar 20 14:09:44 2006
@@ -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;
@@ -162,6 +161,78 @@
      */
     public Double toDouble() {
         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();
     }
 
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
Mon Mar 20 14:09:44 2006
@@ -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;
@@ -96,6 +95,78 @@
      */
     public void setValue(Object value) {
         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();
     }
 
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
Mon Mar 20 14:09:44 2006
@@ -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;
 
 /**
@@ -94,6 +93,78 @@
      */
     public void setValue(Object value) {
         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();
     }
 
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
Mon Mar 20 14:09:44 2006
@@ -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;
 
 /**
@@ -94,6 +93,78 @@
      */
     public void setValue(Object value) {
         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();
     }
 
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
Mon Mar 20 14:09:44 2006
@@ -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;
 
 /**
@@ -94,6 +93,78 @@
      */
     public void setValue(Object value) {
         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();
     }
 
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
Mon Mar 20 14:09:44 2006
@@ -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.
@@ -142,6 +142,50 @@
     public void testToByte() {
         assertEquals(new Byte((byte) 0), new MutableByte((byte) 0).toByte());
         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() {

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
Mon Mar 20 14:09:44 2006
@@ -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.
@@ -153,6 +153,50 @@
     public void testToDouble() {
         assertEquals(new Double(0d), new MutableDouble(0d).toDouble());
         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() {

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
Mon Mar 20 14:09:44 2006
@@ -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.
@@ -153,6 +153,50 @@
     public void testToFloat() {
         assertEquals(new Float(0f), new MutableFloat(0f).toFloat());
         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() {

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
Mon Mar 20 14:09:44 2006
@@ -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.
@@ -148,6 +148,54 @@
     public void testToInteger() {
         assertEquals(new Integer(0), new MutableInt(0).toInteger());
         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() {

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
Mon Mar 20 14:09:44 2006
@@ -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.
@@ -142,6 +142,54 @@
     public void testToLong() {
         assertEquals(new Long(0L), new MutableLong(0L).toLong());
         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() {

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java?rev=387322&r1=387321&r2=387322&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
Mon Mar 20 14:09:44 2006
@@ -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.
@@ -142,6 +142,50 @@
     public void testToShort() {
         assertEquals(new Short((short) 0), new MutableShort((short) 0).toShort());
         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() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message