public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: GapContent.insertString - corrected test
@ 2006-01-24 17:23 David Gilbert
  0 siblings, 0 replies; only message in thread
From: David Gilbert @ 2006-01-24 17:23 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

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

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 2214 bytes --]

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);    
   }
 
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-01-24 17:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-24 17:23 FYI: GapContent.insertString - corrected test David Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).