You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ps...@apache.org on 2005/12/27 06:05:37 UTC
svn commit: r359173 -
/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java
Author: psteitz
Date: Mon Dec 26 21:05:35 2005
New Revision: 359173
URL: http://svn.apache.org/viewcvs?rev=359173&view=rev
Log:
Javadoc.
Modified:
jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java?rev=359173&r1=359172&r2=359173&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java Mon Dec 26 21:05:35 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2005 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.
@@ -34,12 +34,16 @@
*/
public class TestUtils {
/**
- *
+ * Collection of static methods used in math unit tests.
*/
private TestUtils() {
super();
}
+ /**
+ * Verifies that expected and actual are within delta, or are both NaN or
+ * infinities of the same sign.
+ */
public static void assertEquals(double expected, double actual, double delta) {
assertEquals(null, expected, actual, delta);
}
@@ -58,7 +62,7 @@
}
}
- /*
+ /**
* Verifies that the two arguments are exactly the same, either
* both NaN or infinities of same sign, or identical floating point values.
*/
@@ -94,6 +98,13 @@
}
}
+ /**
+ * Serializes an object to a temp file and then recovers the object from the file.
+ * Returns the deserialized object.
+ *
+ * @param o object to serialize and recover
+ * @return the recovered, deseriailized object
+ */
public static Object serializeAndRecover(Object o){
Object result = null;
@@ -140,9 +151,10 @@
}
/**
- * Verifies that serialization preserves equals and hashCode
+ * Verifies that serialization preserves equals and hashCode.
+ * Serializes the object, then recovers it and checks equals and hash code.
*
- * @param object
+ * @param object the object to serialize and recover
*/
public static void checkSerializedEquality(Object object) {
Object object2 = serializeAndRecover(object);
@@ -150,11 +162,32 @@
Assert.assertEquals("HashCode check", object.hashCode(), object2.hashCode());
}
- public static void assertRelativelyEquals(double expected, double actual, double relativeError) {
+ /**
+ * Verifies that the relative error in actual vs. expected is less than or
+ * equal to relativeError. If expected is infinite or NaN, actual must be
+ * the same (NaN or infinity of the same sign).
+ *
+ * @param expected expected value
+ * @param actual observed value
+ * @param relativeError maximum allowable relative error
+ */
+ public static void assertRelativelyEquals(double expected, double actual,
+ double relativeError) {
assertRelativelyEquals(null, expected, actual, relativeError);
}
- public static void assertRelativelyEquals(String msg, double expected, double actual, double relativeError) {
+ /**
+ * Verifies that the relative error in actual vs. expected is less than or
+ * equal to relativeError. If expected is infinite or NaN, actual must be
+ * the same (NaN or infinity of the same sign).
+ *
+ * @param msg message to return with failure
+ * @param expected expected value
+ * @param actual observed value
+ * @param relativeError maximum allowable relative error
+ */
+ public static void assertRelativelyEquals(String msg, double expected,
+ double actual, double relativeError) {
if (Double.isNaN(expected)) {
Assert.assertTrue(msg, Double.isNaN(actual));
} else if (Double.isNaN(actual)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org