This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: GapContent.insertString - corrected test
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Tue, 24 Jan 2006 17:23:37 +0000
- Subject: FYI: GapContent.insertString - corrected test
After looking at the GNU Classpath implementation of this method (which
was failing the test I committed earlier today) I decided that the test
is partially incorrect and, in fact, Sun's JDK has a bug. I've
corrected the test and reported a bug to Sun:
2006-01-24 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/text/GapContent/insertString.java
(testGeneral): Corrected test.
Regards,
Dave
Index: gnu/testlet/javax/swing/text/GapContent/insertString.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/GapContent/insertString.java,v
retrieving revision 1.2
diff -u -r1.2 insertString.java
--- gnu/testlet/javax/swing/text/GapContent/insertString.java 24 Jan 2006 16:31:34 -0000 1.2
+++ gnu/testlet/javax/swing/text/GapContent/insertString.java 24 Jan 2006 17:15:30 -0000
@@ -215,23 +215,25 @@
}
harness.check(gc.length(), 7);
- // insert at index of last character + 1 - this seems to be OK for
- // GapContent, but not StringContent...
+ // insert at index of last character + 1 - the API docs say this should
+ // raise a BadLocationException, but JDK1.5.0_06 doesn't (I reported this
+ // to Sun as a bug in their implementation, will add a bug ID if one is assigned)
+ pass = false;
try
{
gc.insertString(7, "XYZ");
}
catch (BadLocationException e)
{
- // ignore
+ pass = true;
}
- harness.check(gc.length(), 10);
+ harness.check(pass);
// insert at index of last character + 2
pass = false;
try
{
- gc.insertString(11, "XYZ");
+ gc.insertString(gc.length() + 1, "XYZ");
}
catch (BadLocationException e)
{
@@ -240,6 +242,7 @@
harness.check(pass);
// insert empty string
+ int length = gc.length();
try
{
gc.insertString(0, "");
@@ -248,7 +251,7 @@
{
// ignore
}
- harness.check(gc.length(), 10);
+ harness.check(gc.length(), length);
// insert null string
pass = false;
@@ -264,22 +267,7 @@
{
pass = true;
}
- harness.check(pass);
-
- // the following can be done with GapContent but not with StringContent
- harness.checkPoint("anomaly");
- GapContent gc2 = new GapContent();
- try
- {
- harness.check(gc2.getString(0, 1).equals("\n"));
- gc2.insertString(1, "X");
- harness.check(gc2.getString(0, 2).equals("\nX"));
- }
- catch (BadLocationException e)
- {
- harness.fail(e.toString());
- }
-
+ harness.check(pass);
}
}