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]

FYI: new GapContent.insertString test


Hi,
the attached patch contains a new test which checks for the wrong behavior which
caused PR 26888. Additionally I made another part of that class more robust
agains unexpected exceptions.

The ChangeLog:

2006-03-29  Robert Schuster  <robertschuster@fsfe.org>

        * gnu/testlet/javax/swing/text/GapContent/insertString.java:
        (testGeneral): Let test fail when unexpected exception occurs.
        (testSpecialInsert): New test.

cya
Robert
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.4
diff -u -r1.4 insertString.java
--- gnu/testlet/javax/swing/text/GapContent/insertString.java	2 Feb 2006 10:45:51 -0000	1.4
+++ gnu/testlet/javax/swing/text/GapContent/insertString.java	29 Mar 2006 15:22:14 -0000
@@ -2,6 +2,7 @@
 
 // Copyright (C) 2005 Roman Kennke <kennke@aicas.com>
 // Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+// Copyright (C) 2006 Robert Schuster  <robertschuster@fsfe.org>
 
 // This file is part of Mauve.
 
@@ -27,6 +28,7 @@
 
 import javax.swing.text.BadLocationException;
 import javax.swing.text.GapContent;
+import javax.swing.text.Position;
 
 /**
  * Tests if GapContent.insertString works correctly.
@@ -67,6 +69,8 @@
     testBigInsert(harness);
     testComplexInsert(harness);
     testGeneral(harness);
+
+    testSpecialInsert(harness);
   }
 
   /**
@@ -202,6 +206,11 @@
     {
       pass = true;
     }
+    catch (Exception _)
+    {
+      pass = false;
+    }
+
     harness.check(pass);
     
     // insert at index of last character - this is OK
@@ -268,4 +277,32 @@
     harness.check(pass);    
   }
 
+  public void testSpecialInsert(TestHarness harness)
+    {
+      harness.checkPoint("specialInsert");
+      int posValue = -1;
+
+      try
+        {
+	  GapContent gc = new GapContent();
+  	  gc.insertString(0, "foo\nbar\n");
+	  gc.remove(0, 4);
+
+          // Gap starts at 0 now and the following Position
+          // instance is created at the end of the gap.
+          Position pos = gc.createPosition(0);
+
+          // This insertion should not move the offset
+          // of the Position object.
+	  gc.insertString(0, "z");
+
+	  posValue = pos.getOffset();
+        }
+      catch(BadLocationException ble)
+        {
+        }
+      harness.check(posValue, 0);
+    }
+
+
 }

Attachment: signature.asc
Description: OpenPGP digital signature


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