This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: javax.swing.text.StringContent.java - new tests
- 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 13:46:59 +0000
- Subject: FYI: javax.swing.text.StringContent.java - new tests
I committed these new tests (along with some header updates in the
existing test classes):
2006-01-24 David Gilbert <david.gilbert@object-refinery.com>
*
gnu/testlet/javax/swing/text/StringContent/BadLocationExceptionTest.java:
Updated header and imports,
* gnu/testlet/javax/swing/text/StringContent/constructors.java: New
tests,
* gnu/testlet/javax/swing/text/StringContent/createPosition.java:
Likewise,
* gnu/testlet/javax/swing/text/StringContent/getChars.java: Likewise,
* gnu/testlet/javax/swing/text/StringContent/getString.java: Likewise,
* gnu/testlet/javax/swing/text/StringContent/insertString.java:
Likewise,
* gnu/testlet/javax/swing/text/StringContent/insertUndo.java:
Updated header and imports,
* gnu/testlet/javax/swing/text/StringContent/length.java: New tests,
* gnu/testlet/javax/swing/text/StringContent/remove.java: New tests,
* gnu/testlet/javax/swing/text/StringContent/removeUndo.java:
Updated header and imports,
* gnu/testlet/javax/swing/text/StringContent/stickyPosition.java:
Likewise,
* gnu/testlet/javax/swing/text/StringContent/StringContentTest.java:
Likewise.
Regards,
Dave
Index: gnu/testlet/javax/swing/text/StringContent/BadLocationExceptionTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/StringContent/BadLocationExceptionTest.java,v
retrieving revision 1.2
diff -u -r1.2 BadLocationExceptionTest.java
--- gnu/testlet/javax/swing/text/StringContent/BadLocationExceptionTest.java 10 Jan 2005 09:38:42 -0000 1.2
+++ gnu/testlet/javax/swing/text/StringContent/BadLocationExceptionTest.java 24 Jan 2006 13:42:46 -0000
@@ -16,19 +16,16 @@
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA.
package gnu.testlet.javax.swing.text.StringContent;
-import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
import javax.swing.text.BadLocationException;
-import javax.swing.text.Position;
import javax.swing.text.StringContent;
-import javax.swing.text.Segment;
-import javax.swing.undo.UndoableEdit;
public class BadLocationExceptionTest implements Testlet
{
Index: gnu/testlet/javax/swing/text/StringContent/StringContentTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/StringContent/StringContentTest.java,v
retrieving revision 1.5
diff -u -r1.5 StringContentTest.java
--- gnu/testlet/javax/swing/text/StringContent/StringContentTest.java 10 Jan 2005 09:38:42 -0000 1.5
+++ gnu/testlet/javax/swing/text/StringContent/StringContentTest.java 24 Jan 2006 13:42:46 -0000
@@ -16,19 +16,17 @@
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA.
package gnu.testlet.javax.swing.text.StringContent;
-import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
import javax.swing.text.BadLocationException;
-import javax.swing.text.Position;
-import javax.swing.text.StringContent;
import javax.swing.text.Segment;
-import javax.swing.undo.UndoableEdit;
+import javax.swing.text.StringContent;
public class StringContentTest implements Testlet
{
Index: gnu/testlet/javax/swing/text/StringContent/constructors.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/StringContent/constructors.java
diff -N gnu/testlet/javax/swing/text/StringContent/constructors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/StringContent/constructors.java 24 Jan 2006 13:42:46 -0000
@@ -0,0 +1,82 @@
+/* constructors.java -- Some checks for the constructors in the StringContent
+ class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.javax.swing.text.StringContent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.StringContent;
+
+public class constructors implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ testConstructor1(harness);
+ testConstructor2(harness);
+ }
+
+ public void testConstructor1(TestHarness harness)
+ {
+ harness.checkPoint("()");
+ StringContent sc = new StringContent();
+ harness.check(sc.length(), 1);
+
+ boolean pass = false;
+ try
+ {
+ pass = sc.getString(0, 1).equals("\n");
+ }
+ catch (BadLocationException e)
+ {
+ harness.fail(e.toString());
+ }
+ harness.check(pass);
+ }
+
+ public void testConstructor2(TestHarness harness)
+ {
+ harness.checkPoint("(int)");
+ StringContent sc = new StringContent(10);
+ harness.check(sc.length(), 1);
+ boolean pass = false;
+ try
+ {
+ pass = sc.getString(0, 1).equals("\n");
+ }
+ catch (BadLocationException e)
+ {
+ harness.fail(e.toString());
+ }
+ harness.check(pass);
+ }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/StringContent/createPosition.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/StringContent/createPosition.java
diff -N gnu/testlet/javax/swing/text/StringContent/createPosition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/StringContent/createPosition.java 24 Jan 2006 13:42:46 -0000
@@ -0,0 +1,103 @@
+/* createPosition.java -- Some checks for the createPosition() method in the
+ StringContent class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.javax.swing.text.StringContent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Position;
+import javax.swing.text.StringContent;
+
+public class createPosition implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ StringContent sc = new StringContent();
+ harness.check(sc.length(), 1);
+ try
+ {
+ sc.insertString(0, "ABC");
+ }
+ catch (BadLocationException e)
+ {
+ // ignore
+ }
+
+ // negative index
+ boolean pass = false;
+ try
+ {
+ sc.createPosition(-1);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // index of last char
+ Position p = null;
+ try
+ {
+ p = sc.createPosition(3);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(p.getOffset(), 3);
+
+ // index of last char + 1
+ try
+ {
+ p = sc.createPosition(4);
+ }
+ catch (BadLocationException e)
+ {
+ }
+ harness.check(p.getOffset(), 4);
+
+ // index of last char + 2
+ pass = false;
+ try
+ {
+ p = sc.createPosition(5);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/StringContent/getChars.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/StringContent/getChars.java
diff -N gnu/testlet/javax/swing/text/StringContent/getChars.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/StringContent/getChars.java 24 Jan 2006 13:42:47 -0000
@@ -0,0 +1,167 @@
+/* getChars.java -- Some checks for the getChars() method in the StringContent
+ class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.javax.swing.text.StringContent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Segment;
+import javax.swing.text.StringContent;
+
+public class getChars implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ StringContent sc = new StringContent();
+ char[] ch = new char[] { 'A', 'B', 'C' };
+ Segment seg = new Segment(ch, 0, 3);
+
+ // check default result
+ try
+ {
+ sc.getChars(0, 1, seg);
+ }
+ catch (BadLocationException e)
+ {
+ // ignore - tests below will fail if this happens
+ }
+ harness.check(seg.offset, 0);
+ harness.check(seg.count, 1);
+ harness.check(seg.array != ch);
+ harness.check(seg.array[0], '\n');
+
+ // if len goes past end of range, should get BadLocationException
+ boolean pass = false;
+ try
+ {
+ sc.getChars(0, 2, seg);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // add some more text
+ try
+ {
+ sc.insertString(0, "ABCDEFG");
+ }
+ catch (BadLocationException e)
+ {
+ }
+ harness.check(sc.length(), 8);
+
+ // if index < 0 should get BadLocationException
+ pass = false;
+ try
+ {
+ sc.getChars(-1, 3, seg);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // if index > end of text should get BadLocationException
+ pass = false;
+ try
+ {
+ sc.getChars(99, 1, seg);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // if len goes past end of range, should get BadLocationException
+ pass = false;
+ try
+ {
+ sc.getChars(0, 99, seg);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try a zero length string
+ try
+ {
+ sc.getChars(1, 0, seg);
+ }
+ catch (BadLocationException e)
+ {
+ }
+ harness.check(seg.offset, 1);
+ harness.check(seg.count, 0);
+
+ // what happens for null Segment
+ pass = false;
+ try
+ {
+ sc.getChars(0, 1, null);
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ catch (BadLocationException e)
+ {
+ // ignore
+ }
+ harness.check(pass);
+
+ // what happens if we update the Segment array, does that change the
+ // StringContent
+ Segment seg2 = new Segment();
+ Segment seg3 = new Segment();
+ StringContent sc2 = new StringContent();
+ try
+ {
+ sc2.insertString(0, "XYZ");
+ sc2.getChars(0, 3, seg2);
+ seg2.array[1] = '5';
+ sc2.getChars(0, 3, seg3);
+ }
+ catch (BadLocationException e)
+ {
+ // ignore
+ }
+ harness.check(seg2.array[1], '5');
+ harness.check(seg3.array[1], '5');
+ }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/StringContent/getString.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/StringContent/getString.java
diff -N gnu/testlet/javax/swing/text/StringContent/getString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/StringContent/getString.java 24 Jan 2006 13:42:47 -0000
@@ -0,0 +1,132 @@
+/* getString.java -- Some checks for the getString() method in the StringContent
+ class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.javax.swing.text.StringContent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.StringContent;
+
+public class getString implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ StringContent sc = new StringContent();
+
+ // check default result
+ boolean pass = false;
+ try
+ {
+ pass = sc.getString(0, 1).equals("\n");
+ }
+ catch (BadLocationException e)
+ {
+ }
+ harness.check(pass);
+
+ // if len goes past end of range, should get BadLocationException
+ pass = false;
+ try
+ {
+ sc.getString(0, 2);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // add some more text
+ try
+ {
+ sc.insertString(0, "ABCDEFG");
+ }
+ catch (BadLocationException e)
+ {
+ }
+ harness.check(sc.length(), 8);
+
+ // if index < 0 should get BadLocationException
+ pass = false;
+ try
+ {
+ /*String s =*/ sc.getString(-1, 3);
+ }
+ catch (StringIndexOutOfBoundsException e)
+ {
+ pass = false; // JDK does this, API docs say it should be a
+ // BadLocationException
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // if index > end of text should get BadLocationException
+ pass = false;
+ try
+ {
+ /*String s =*/ sc.getString(99, 1);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // if len goes past end of range, should get BadLocationException
+ pass = false;
+ try
+ {
+ /* String s =*/ sc.getString(0, 99);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try a zero length string
+ pass = false;
+ try
+ {
+ pass = sc.getString(1, 0).equals("");
+ }
+ catch (BadLocationException e)
+ {
+ }
+ harness.check(pass);
+
+ }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/StringContent/insertString.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/StringContent/insertString.java
diff -N gnu/testlet/javax/swing/text/StringContent/insertString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/StringContent/insertString.java 24 Jan 2006 13:42:47 -0000
@@ -0,0 +1,120 @@
+/* insertString.java -- Some checks for the insertString() method in the
+ StringContent class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.javax.swing.text.StringContent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.StringContent;
+
+public class insertString implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ StringContent sc = new StringContent();
+ // regular insert
+ try
+ {
+ sc.insertString(0, "ABC");
+ // ignoring undo/redo here - see insertUndo.java
+ }
+ catch (BadLocationException e)
+ {
+ // ignore - checks below will fail if this happens
+ }
+ harness.check(sc.length(), 4);
+
+ // insert at location before start
+ boolean pass = false;
+ try
+ {
+ sc.insertString(-1, "XYZ");
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // insert at index of last character - this is OK
+ try
+ {
+ sc.insertString(3, "XYZ");
+ }
+ catch (BadLocationException e)
+ {
+ // ignore
+ }
+ harness.check(sc.length(), 7);
+
+ // insert at index of last character + 1 - this raises BadLocationException
+ pass = false;
+ try
+ {
+ sc.insertString(7, "XYZ");
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // insert empty string
+ try
+ {
+ sc.insertString(0, "");
+ }
+ catch (BadLocationException e)
+ {
+ // ignore
+ }
+ harness.check(sc.length(), 7);
+
+ // insert null string
+ pass = false;
+ try
+ {
+ sc.insertString(0, null);
+ }
+ catch (BadLocationException e)
+ {
+ // ignore
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/StringContent/insertUndo.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/StringContent/insertUndo.java,v
retrieving revision 1.3
diff -u -r1.3 insertUndo.java
--- gnu/testlet/javax/swing/text/StringContent/insertUndo.java 14 Jan 2005 13:21:10 -0000 1.3
+++ gnu/testlet/javax/swing/text/StringContent/insertUndo.java 24 Jan 2006 13:42:47 -0000
@@ -16,21 +16,18 @@
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA.
package gnu.testlet.javax.swing.text.StringContent;
-import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
import javax.swing.text.BadLocationException;
-import javax.swing.text.Position;
import javax.swing.text.StringContent;
-import javax.swing.text.Segment;
-
-import javax.swing.undo.UndoableEdit;
import javax.swing.undo.CannotUndoException;
+import javax.swing.undo.UndoableEdit;
public class insertUndo implements Testlet
{
Index: gnu/testlet/javax/swing/text/StringContent/length.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/StringContent/length.java
diff -N gnu/testlet/javax/swing/text/StringContent/length.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/StringContent/length.java 24 Jan 2006 13:42:47 -0000
@@ -0,0 +1,62 @@
+/* length.java -- Some checks for the length() method in the StringContent
+ class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.javax.swing.text.StringContent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.StringContent;
+
+public class length implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ StringContent sc = new StringContent();
+ harness.check(sc.length(), 1);
+ try
+ {
+ sc.insertString(0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ harness.check(sc.length(), 27);
+ sc.remove(0, 3);
+ harness.check(sc.length(), 24);
+ sc.insertString(4, "123");
+ harness.check(sc.length(), 27);
+ sc.remove(20, 5);
+ harness.check(sc.length(), 22);
+ }
+ catch (BadLocationException e)
+ {
+ harness.fail(e.toString());
+ }
+ }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/StringContent/remove.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/StringContent/remove.java
diff -N gnu/testlet/javax/swing/text/StringContent/remove.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/StringContent/remove.java 24 Jan 2006 13:42:47 -0000
@@ -0,0 +1,142 @@
+/* remove.java -- Some checks for the insertString() method in the
+ StringContent class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: 1.2
+
+package gnu.testlet.javax.swing.text.StringContent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.StringContent;
+
+public class remove implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ testGeneral(harness);
+ testRemoveLast(harness);
+ }
+
+ public void testGeneral(TestHarness harness)
+ {
+ StringContent sc = new StringContent();
+ // regular insert
+ try
+ {
+ sc.insertString(0, "ABCDEFG");
+ // ignoring undo/redo here - see insertUndo.java
+ }
+ catch (BadLocationException e)
+ {
+ // ignore - checks below will fail if this happens
+ }
+ harness.check(sc.length(), 8);
+
+ // remove from location before start
+ boolean pass = false;
+ try
+ {
+ sc.remove(-1, 3);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true; // Classpath does this
+ }
+ catch (StringIndexOutOfBoundsException e)
+ {
+ pass = false; // JDK does this - it is a bug given the API spec
+ }
+ harness.check(pass);
+
+ // remove from location after end
+ pass = false;
+ try
+ {
+ sc.remove(99, 1);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // doesn't allow removal of last char
+ pass = false;
+ try
+ {
+ sc.remove(7, 1);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ harness.check(sc.length(), 8);
+
+ // remove 0 chars
+ pass = true;
+ try
+ {
+ sc.remove(0, 0);
+ }
+ catch (BadLocationException e)
+ {
+ pass = false;
+ }
+ harness.check(pass);
+ harness.check(sc.length(), 8);
+
+ }
+
+ /**
+ * The API spec says that the last character cannot be removed
+ * (where + nitems < length()).
+ *
+ * @param harness
+ */
+ public void testRemoveLast(TestHarness harness)
+ {
+ harness.checkPoint("testRemoveLast");
+ StringContent sc = new StringContent();
+ harness.check(sc.length(), 1);
+
+ boolean pass = false;
+ try
+ {
+ sc.remove(0, 1);
+ }
+ catch (BadLocationException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/StringContent/removeUndo.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/StringContent/removeUndo.java,v
retrieving revision 1.3
diff -u -r1.3 removeUndo.java
--- gnu/testlet/javax/swing/text/StringContent/removeUndo.java 14 Jan 2005 13:47:37 -0000 1.3
+++ gnu/testlet/javax/swing/text/StringContent/removeUndo.java 24 Jan 2006 13:42:47 -0000
@@ -16,21 +16,18 @@
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA.
package gnu.testlet.javax.swing.text.StringContent;
-import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
import javax.swing.text.BadLocationException;
-import javax.swing.text.Position;
import javax.swing.text.StringContent;
-import javax.swing.text.Segment;
-import javax.swing.undo.UndoableEdit;
-import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
+import javax.swing.undo.UndoableEdit;
public class removeUndo implements Testlet
{
Index: gnu/testlet/javax/swing/text/StringContent/stickyPosition.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/StringContent/stickyPosition.java,v
retrieving revision 1.4
diff -u -r1.4 stickyPosition.java
--- gnu/testlet/javax/swing/text/StringContent/stickyPosition.java 14 Jan 2005 08:39:24 -0000 1.4
+++ gnu/testlet/javax/swing/text/StringContent/stickyPosition.java 24 Jan 2006 13:42:47 -0000
@@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA.
package gnu.testlet.javax.swing.text.StringContent;