This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: new mauve test


This patch introduces a new mauve test used to prove the correctness of
the my clone patch for CubicSegment.

This is not a complete test for the whole class, just a test for clone.

If you find it useful, I'll commit.

Also, I'm a bit unsure about the class tag, so if you know a better one,
please tell me.

Ciao,
Mario

2006-07-11  Mario Torre  <neugens@limasoftware.net>

	* gnu/testlet/java/awt/java2d/CubicSegmentTest.java: New test.

-- 
Lima Software, SO.PR.IND. s.r.l.
http://www.limasoftware.net/
pgp key: http://subkeys.pgp.net/

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0
#P mauve
Index: gnu/testlet/java/awt/java2d/CubicSegmentTest.java
===================================================================
RCS file: gnu/testlet/java/awt/java2d/CubicSegmentTest.java
diff -N gnu/testlet/java/awt/java2d/CubicSegmentTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/java2d/CubicSegmentTest.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,80 @@
+/* cubicSegment.java -- simple test for class CubicSegment 
+   Copyright (C) 2006 Lima Software, SO.PR.IND. s.r.l.
+   
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// FIXME: this can be wrong
+// Tags: JDK 1.2
+
+package gnu.testlet.java.awt.java2d;
+
+import java.awt.geom.Point2D;
+
+import gnu.java.awt.java2d.CubicSegment;
+import gnu.java.awt.java2d.Segment;
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Mauve testlet for CubicSegment class.
+ * 
+ * @author Mario Torre <neugens@limasoftware.net>
+ *
+ */
+public class CubicSegmentTest implements Testlet
+{
+	/* Test Harness */
+	protected TestHarness harness = null;
+
+	public void test(TestHarness harness)
+	{
+		this.harness = harness;
+		
+		this.testClone();
+	}
+	
+	private void testClone()
+	{
+		this.harness.checkPoint("testClone()");
+		
+		CubicSegment segment =
+				new CubicSegment(0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0);
+		CubicSegment clonedSegment = (CubicSegment) segment.clone();
+		
+		this.harness.check(clonedSegment != segment,
+				"Cloned, but still disting objects");
+		this.harness.check(clonedSegment.getClass() == segment.getClass());
+		this.harness.check(clonedSegment instanceof Segment, "same class");
+		
+		Point2D point2d = new Point2D.Double(4.0, 4.0);
+		
+		// fields have to have the same contents
+		this.harness.check(segment.cp1.getX() == clonedSegment.cp1.getX(),
+					"field have the same content");
+		
+		// now update a field so that we can show they are not the same object
+		segment.cp1 = point2d;
+		this.harness.check(segment.cp1.getX() == point2d.getX(),
+					"updated internal field");
+		this.harness.check(clonedSegment.cp1.getX() != point2d.getX());
+		this.harness.check(segment.cp1.getX() != clonedSegment.cp1.getX(),
+					"field do not have the same content anymore");
+	}
+}

Attachment: signature.asc
Description: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggiofirmata digitalmente


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]