From 1d37fc5fd51bcf97bb7f875dda7f86e8a611346f Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Thu, 17 Jun 2004 21:41:56 +0000 Subject: [PATCH] Added method to verify that serialization / deserialization preserves equals and hashCode (when this is supported). git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141302 13f79535-47bb-0310-9956-ffa450edef68 --- src/test/org/apache/commons/math/TestUtils.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/org/apache/commons/math/TestUtils.java b/src/test/org/apache/commons/math/TestUtils.java index bb5a208d5..481d07997 100644 --- a/src/test/org/apache/commons/math/TestUtils.java +++ b/src/test/org/apache/commons/math/TestUtils.java @@ -27,7 +27,7 @@ import junit.framework.Assert; import org.apache.commons.math.complex.Complex; /** - * @version $Revision: 1.13 $ $Date: 2004/05/05 19:55:14 $ + * @version $Revision: 1.14 $ $Date: 2004/06/17 21:41:56 $ */ public class TestUtils { /** @@ -97,4 +97,15 @@ public class TestUtils { return result; } + + /** + * Verifies that serialization preserves equals and hashCode + * + * @param object + */ + public static void checkSerializedEquality(Object object) { + Object object2 = serializeAndRecover(object); + Assert.assertEquals("Equals check", object, object2); + Assert.assertEquals("HashCode check", object.hashCode(), object2.hashCode()); + } }