public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: javax.swing.text.Segment - new tests
@ 2006-01-23 17:12 David Gilbert
  0 siblings, 0 replies; only message in thread
From: David Gilbert @ 2006-01-23 17:12 UTC (permalink / raw)
  To: mauve-patches

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

I committed these new tests:

2006-01-23  David Gilbert  <david.gilbert@object-refinery.com>

     * gnu/testlet/javax/swing/text/Segment/clone.java: New test,
     * gnu/testlet/javax/swing/text/Segment/constructors.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/current.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/first.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/getBeginIndex.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/getEndIndex.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/getIndex.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/isPartialReturn.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/last.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/next.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/previous.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/setIndex.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/setPartialReturn.java: Likewise,
     * gnu/testlet/javax/swing/text/Segment/toString.java: Likewise.

Regards

Dave

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

Index: gnu/testlet/javax/swing/text/Segment/clone.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/clone.java
diff -N gnu/testlet/javax/swing/text/Segment/clone.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/clone.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,72 @@
+/* clone.java -- Some checks for the clone() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class clone implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C'};
+    Segment s1 = new Segment(ch, 0, 3);
+    Segment s2 = (Segment) s1.clone();
+    harness.check(!s1.equals(s2));
+    harness.check(s2.offset, 0);
+    harness.check(s2.count, 3);
+    harness.check(s2.array, ch);
+    
+    // offset is independent
+    s1.offset = 1;
+    harness.check(s2.offset, 0);
+    s2.offset = 1;
+    harness.check(s2.offset, 1);
+    
+    // count is independent
+    s1.count = 2;
+    harness.check(s2.count, 3);
+    s2.count = 2;
+    harness.check(s2.count, 2);
+    
+    // array is a shallow copy and not independent
+    s1.array[1] = 'X';
+    harness.check(s2.array[1], 'X');
+    
+    char[] ch2 = new char[] {'X', 'Y', 'Z'};
+    s1.array = ch2;
+    
+    // s2 still points to ch
+    harness.check(s2.array, ch);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/constructors.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/constructors.java
diff -N gnu/testlet/javax/swing/text/Segment/constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/constructors.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,89 @@
+/* constructors.java -- Some checks for the constructors in the Segment
+                        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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+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("()");
+    Segment s = new Segment();
+    harness.check(s.offset, 0);
+    harness.check(s.count, 0);
+    harness.check(s.array, null);
+    harness.check(s.toString(), "");
+  }
+  
+  public void testConstructor2(TestHarness harness) 
+  {
+    harness.checkPoint("(char[], int, int)");
+    char[] ch = new char[] {'A', 'B', 'C'};
+    Segment s = new Segment(ch, 1, 2);
+    harness.check(s.offset, 1);
+    harness.check(s.count, 2);
+    harness.check(s.array, ch);
+    harness.check(s.toString(), "BC");
+    harness.check(s.getIndex(), 0);
+    harness.check(s.getBeginIndex(), 1);
+    harness.check(s.getEndIndex(), 3);
+    
+    // try offset out of range - this creates an instance with a bad state
+    s = new Segment(ch, 4, 1);
+    harness.check(s.offset, 4);
+    harness.check(s.count, 1);
+    harness.check(s.array, ch);
+    
+    // null array
+    s = new Segment(null, 0, 1);
+    harness.check(s.offset, 0);
+    harness.check(s.count, 1);
+    harness.check(s.array, null);
+    
+    // negative offsets
+    s = new Segment(ch, -4, 1);
+    harness.check(s.offset, -4);
+    harness.check(s.count, 1);
+    harness.check(s.array, ch);
+    
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/current.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/current.java
diff -N gnu/testlet/javax/swing/text/Segment/current.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/current.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,68 @@
+/* current.java -- Some checks for the current() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.CharacterIterator;
+
+import javax.swing.text.Segment;
+
+public class current implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    harness.check(s.current(), 'A');
+    s.last();
+    harness.check(s.current(), 'G');
+    s.next();
+    harness.check(s.current(), CharacterIterator.DONE);
+    s.first();
+    harness.check(s.current(), 'A');
+    s.previous();
+    harness.check(s.current(), 'A');
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    harness.check(s.current(), 'A');
+    s.last();
+    harness.check(s.current(), 'F');
+    s.next();
+    harness.check(s.current(), CharacterIterator.DONE);
+    s.first();
+    harness.check(s.current(), 'D');
+    s.previous();
+    harness.check(s.current(), 'D');
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/first.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/first.java
diff -N gnu/testlet/javax/swing/text/Segment/first.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/first.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,60 @@
+/* first.java -- Some checks for the first() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class first implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    harness.check(s.first(), 'A');
+    harness.check(s.getIndex(), 0);
+    s.last();
+    harness.check(s.getIndex(), 6);
+    harness.check(s.first(), 'A');
+    harness.check(s.getIndex(), 0);
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    harness.check(s.first(), 'D');
+    harness.check(s.getIndex(), 3);
+    s.last();
+    harness.check(s.getIndex(), 5);
+    harness.check(s.first(), 'D');
+    harness.check(s.getIndex(), 3);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/getBeginIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/getBeginIndex.java
diff -N gnu/testlet/javax/swing/text/Segment/getBeginIndex.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/getBeginIndex.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,51 @@
+/* getBeginIndex.java -- Some checks for the getBeginIndex() method in the 
+   Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class getBeginIndex implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    harness.check(s.getBeginIndex(), 0);
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    harness.check(s.getBeginIndex(), 3);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/getEndIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/getEndIndex.java
diff -N gnu/testlet/javax/swing/text/Segment/getEndIndex.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/getEndIndex.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,51 @@
+/* getEndIndex.java -- Some checks for the getEndIndex() method in the 
+   Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class getEndIndex implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    harness.check(s.getEndIndex(), 7);
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    harness.check(s.getEndIndex(), 6);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/getIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/getIndex.java
diff -N gnu/testlet/javax/swing/text/Segment/getIndex.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/getIndex.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,68 @@
+/* getIndex.java -- Some checks for the getIndex() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class getIndex implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    harness.check(s.getIndex(), 0);
+    s.next();
+    harness.check(s.getIndex(), 1);
+    s.last();
+    harness.check(s.getIndex(), 6);
+    s.next();
+    harness.check(s.getIndex(), 7);
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    harness.check(s.getIndex(), 0);
+    s.first();
+    harness.check(s.getIndex(), 3);
+    s.next();
+    harness.check(s.getIndex(), 4);
+    s.last();
+    harness.check(s.getIndex(), 5);
+    s.next();
+    harness.check(s.getIndex(), 6);
+    s.first();
+    harness.check(s.getIndex(), 3);
+    s.previous();
+    harness.check(s.getIndex(), 3);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/isPartialReturn.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/isPartialReturn.java
diff -N gnu/testlet/javax/swing/text/Segment/isPartialReturn.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/isPartialReturn.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,49 @@
+/* isPartialReturn.java -- Some checks for the isPartialReturn() method in the 
+   Segment 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.4
+
+package gnu.testlet.javax.swing.text.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class isPartialReturn implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C'};
+    Segment s1 = new Segment(ch, 0, 3);
+    harness.check(s1.isPartialReturn(), false);
+    s1.setPartialReturn(true);
+    harness.check(s1.isPartialReturn(), true);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/last.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/last.java
diff -N gnu/testlet/javax/swing/text/Segment/last.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/last.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,52 @@
+/* last.java -- Some checks for the last() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class last implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    harness.check(s.last(), 'G');
+    harness.check(s.getIndex(), 6);
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    harness.check(s.last(), 'F');
+    harness.check(s.getIndex(), 5);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/next.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/next.java
diff -N gnu/testlet/javax/swing/text/Segment/next.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/next.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,64 @@
+/* next.java -- Some checks for the next() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.CharacterIterator;
+
+import javax.swing.text.Segment;
+
+public class next implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    s.first();
+    harness.check(s.next(), 'B');
+    harness.check(s.next(), 'C');
+    harness.check(s.next(), 'D');
+    harness.check(s.next(), 'E');
+    harness.check(s.next(), 'F');
+    harness.check(s.next(), 'G');
+    harness.check(s.next(), CharacterIterator.DONE);
+    harness.check(s.next(), CharacterIterator.DONE);
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    s.first();
+    harness.check(s.next(), 'E');
+    harness.check(s.next(), 'F');
+    harness.check(s.next(), CharacterIterator.DONE);
+    harness.check(s.next(), CharacterIterator.DONE);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/previous.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/previous.java
diff -N gnu/testlet/javax/swing/text/Segment/previous.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/previous.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,64 @@
+/* previous.java -- Some checks for the previous() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.CharacterIterator;
+
+import javax.swing.text.Segment;
+
+public class previous implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    s.last();
+    harness.check(s.previous(), 'F');
+    harness.check(s.previous(), 'E');
+    harness.check(s.previous(), 'D');
+    harness.check(s.previous(), 'C');
+    harness.check(s.previous(), 'B');
+    harness.check(s.previous(), 'A');
+    harness.check(s.previous(), CharacterIterator.DONE);
+    harness.check(s.previous(), CharacterIterator.DONE);
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    s.last();
+    harness.check(s.previous(), 'E');
+    harness.check(s.previous(), 'D');
+    harness.check(s.previous(), CharacterIterator.DONE);
+    harness.check(s.previous(), CharacterIterator.DONE);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/setIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/setIndex.java
diff -N gnu/testlet/javax/swing/text/Segment/setIndex.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/setIndex.java	23 Jan 2006 17:04:28 -0000
@@ -0,0 +1,124 @@
+/* setIndex.java -- Some checks for the setIndex() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class setIndex implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+    Segment s = new Segment(ch, 0, 7);
+    s.setIndex(2);
+    harness.check(s.current(), 'C');
+    s.setIndex(6);
+    harness.check(s.current(), 'G');
+    
+    // try bad indices
+    boolean pass = false;
+    try
+    {
+      s.setIndex(-1);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    pass = false;
+    try
+    {
+      s.setIndex(99);
+    }
+    catch (IllegalArgumentException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    
+    // try results for a subset of the characters
+    s = new Segment(ch, 3, 3);
+    s.setIndex(4);
+    harness.check(s.current(), 'E');
+    s.setIndex(5);
+    harness.check(s.current(), 'F');
+    
+    pass = false;
+    try
+    {
+      s.setIndex(-1);
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    pass = false;
+    try
+    {
+      s.setIndex(1);
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    pass = false;
+    try
+    {
+      s.setIndex(7);
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+    
+    pass = false;
+    try
+    {
+      s.setIndex(99);
+    }
+    catch (IllegalArgumentException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/setPartialReturn.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/setPartialReturn.java
diff -N gnu/testlet/javax/swing/text/Segment/setPartialReturn.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/setPartialReturn.java	23 Jan 2006 17:04:30 -0000
@@ -0,0 +1,49 @@
+/* setPartialReturn.java -- Some checks for the setPartialReturn() method in the 
+   Segment 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.4
+
+package gnu.testlet.javax.swing.text.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class setPartialReturn implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C'};
+    Segment s1 = new Segment(ch, 0, 3);
+    harness.check(s1.isPartialReturn(), false);
+    s1.setPartialReturn(true);
+    harness.check(s1.isPartialReturn(), true);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/text/Segment/toString.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/Segment/toString.java
diff -N gnu/testlet/javax/swing/text/Segment/toString.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/Segment/toString.java	23 Jan 2006 17:04:30 -0000
@@ -0,0 +1,52 @@
+/* toString.java -- Some checks for the toString() method in the Segment 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.Segment;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.Segment;
+
+public class toString implements Testlet
+{
+    
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    char[] ch = new char[] {'A', 'B', 'C'};
+    Segment s1 = new Segment(ch, 0, 3);
+    harness.check(s1.toString(), "ABC");
+    Segment s2 = new Segment(ch, 1, 1);
+    harness.check(s2.toString(), "B");
+    Segment s3 = new Segment(ch, 2, 0);
+    harness.check(s3.toString(), "");
+    Segment s4 = new Segment(null, 0, 0);
+    harness.check(s4.toString(), "");
+  }
+
+}
\ No newline at end of file

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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-23 17:12 FYI: javax.swing.text.Segment - new tests 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).