MATH-1041
Added "toString" method. Thanks to Sean Owen. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1532679 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e65901dcb8
commit
da0bbbb9a6
|
@ -133,4 +133,9 @@ public class Pair<K, V> {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[" + getKey() + ", " + getValue() + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,12 @@ public class PairTest {
|
||||||
Assert.assertFalse(p1.hashCode() == p2.hashCode());
|
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.
|
* A mutable integer.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue