commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1532679 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/util/Pair.java test/java/org/apache/commons/math3/util/PairTest.java
Date Wed, 16 Oct 2013 08:08:07 GMT
Author: erans
Date: Wed Oct 16 08:08:07 2013
New Revision: 1532679

URL: http://svn.apache.org/r1532679
Log:
MATH-1041
Added "toString" method. Thanks to Sean Owen.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java?rev=1532679&r1=1532678&r2=1532679&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java Wed Oct
16 08:08:07 2013
@@ -133,4 +133,9 @@ public class Pair<K, V> {
 
         return result;
     }
+
+    @Override
+    public String toString() {
+        return "[" + getKey() + ", " + getValue() + "]";
+    }
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java?rev=1532679&r1=1532678&r2=1532679&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java Wed
Oct 16 08:08:07 2013
@@ -73,6 +73,12 @@ public class PairTest {
         Assert.assertFalse(p1.hashCode() == p2.hashCode());
     }
 
+    @Test
+    public void testToString() {
+        Assert.assertEquals("[null, null]", new Pair<Object, Object>(null, null).toString());
+        Assert.assertEquals("[foo, 3]", new Pair<String, Integer>("foo", 3).toString());
+    }
+
     /**
      * A mutable integer.
      */



Mime
View raw message