public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
From: Robert Schuster <theBohemian@gmx.net>
To: mauve-patches@sources.redhat.com
Subject: FYI: new GapContent.insertString test
Date: Wed, 29 Mar 2006 15:27:00 -0000	[thread overview]
Message-ID: <442AA768.9060204@gmx.net> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 455 bytes --]

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

[-- Attachment #1.2: mauve-gapcontent-insert.diff --]
[-- Type: text/x-patch, Size: 2026 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.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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

                 reply	other threads:[~2006-03-29 15:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=442AA768.9060204@gmx.net \
    --to=thebohemian@gmx.net \
    --cc=mauve-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).