public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: PlainDocument remove - new test
@ 2006-02-20 11:30 Robert Schuster
  0 siblings, 0 replies; only message in thread
From: Robert Schuster @ 2006-02-20 11:30 UTC (permalink / raw)
  To: mauve-patches


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

Hi,
this adds a new test for PlainDocument remove. It was the basis for my fix for
PR 26354.

2006-02-20  Robert Schuster  <robertschuster@fsfe.org>

        * gnu/testlet/javax/swing/text/GapContent/remove.java:
        (testGeneral): Added test.

cya
Robert

[-- Attachment #1.2: mauve-plaindocument-remove.diff --]
[-- Type: text/x-patch, Size: 2059 bytes --]

Index: gnu/testlet/javax/swing/text/PlainDocument/remove.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/PlainDocument/remove.java,v
retrieving revision 1.1
diff -u -r1.1 remove.java
--- gnu/testlet/javax/swing/text/PlainDocument/remove.java	25 Jan 2006 18:15:10 -0000	1.1
+++ gnu/testlet/javax/swing/text/PlainDocument/remove.java	20 Feb 2006 11:28:38 -0000
@@ -1,6 +1,7 @@
 /* remove.java -- Some checks for the remove() method in the PlainDocument 
    class.
    Copyright (C) 2006  David Gilbert <david.gilbert@object-refinery.com>
+   Copyright (C) 2006  Robert Schuster <robertschuster@fsfe.org>
 This file is part of Mauve.
 
 Mauve is free software; you can redistribute it and/or modify
@@ -28,6 +29,7 @@
 import gnu.testlet.Testlet;
 
 import javax.swing.text.BadLocationException;
+import javax.swing.text.Element;
 import javax.swing.text.PlainDocument;
 import javax.swing.text.Position;
 
@@ -43,6 +45,8 @@
   {
     testArguments(harness);
     testPositions(harness);
+
+    testBehavior(harness);
   }
   
   public void testArguments(TestHarness harness)
@@ -153,4 +157,39 @@
     }
   }
   
-}
\ No newline at end of file
+  private void testBehavior(TestHarness harness)
+  {
+    harness.checkPoint("testArguments");
+
+    PlainDocument pd = new PlainDocument();
+    int index0 = -1;
+    int index1 = -1;
+
+    try
+      {
+        pd.insertString(0, "abc\ndef\n", null);
+
+        // Delete the 'c'.
+        pd.remove(2, 1);
+
+        Element re = pd.getDefaultRootElement();
+        
+        // There should still be two separate lines
+        // (no Element merge should have taken place).
+        index0 = re.getElementIndex(2);
+        index1 = re.getElementIndex(3);
+      }
+    catch (BadLocationException ble)
+      {
+        // Very odd. This should not happen.
+        index0 = -1;
+        index1 = -1;
+      }
+    finally
+      {
+        harness.check(index0, 0);
+        harness.check(index1, 1);
+      }
+    
+  }
+}

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

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

only message in thread, other threads:[~2006-02-20 11:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-20 11:30 FYI: PlainDocument remove - new test Robert Schuster

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).