This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: TabSet and TabStop - new tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches <mauve-patches at sources dot redhat dot com>
- Date: Tue, 25 Jul 2006 10:25:25 +0100
- Subject: FYI: TabSet and TabStop - new tests
This patch (committed) adds some new tests for the TabSet and TabStop
classes:
2006-07-25 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/text/TabSet/constructor.java: New test,
* gnu/testlet/javax/swing/text/TabSet/equals.java: New test,
* gnu/testlet/javax/swing/text/TabSet/getTab.java: New test,
* gnu/testlet/javax/swing/text/TabSet/getTabCount.java: New test,
* gnu/testlet/javax/swing/text/TabSet/getTabIndex.java: New test,
* gnu/testlet/javax/swing/text/TabSet/getTabIndexAfter.java: New test,
* gnu/testlet/javax/swing/text/TabSet/toString.java: New test,
* gnu/testlet/javax/swing/text/TabStop/constructor.java: New test,
* gnu/testlet/javax/swing/text/TabStop/toString.java: New test.
Regards,
Dave
Index: gnu/testlet/javax/swing/text/TabSet/constructor.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabSet/constructor.java
diff -N gnu/testlet/javax/swing/text/TabSet/constructor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabSet/constructor.java 25 Jul 2006 09:20:39 -0000
@@ -0,0 +1,63 @@
+/* constructor.java -- some checks for the constructor in the TabSet 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: JDk1.4
+
+package gnu.testlet.javax.swing.text.TabSet;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+public class constructor implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabStop ts1 = new TabStop(1.0f);
+ TabStop ts2 = new TabStop(2.0f);
+ TabStop ts3 = new TabStop(3.0f);
+ TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
+ TabSet s = new TabSet(tabs);
+ harness.check(s.getTabCount(), 3);
+ harness.check(s.getTab(0), ts1);
+ harness.check(s.getTab(1), ts2);
+ harness.check(s.getTab(2), ts3);
+
+ // try modifying the original tab array
+ TabStop ts4 = new TabStop(4.0f);
+ tabs[1] = ts4;
+ harness.check(s.getTab(1), ts2);
+
+ // what if the original array is not ordered?
+ TabStop[] tabs2 = new TabStop[] {ts1, ts3, ts2};
+ TabSet s2 = new TabSet(tabs2);
+ harness.check(s2.getTabCount(), 3);
+ harness.check(s2.getTab(0), ts1);
+ harness.check(s2.getTab(1), ts3);
+ harness.check(s2.getTab(2), ts2);
+
+ // try null
+ s2 = new TabSet(null);
+ harness.check(s2.getTabCount(), 0);
+ }
+}
Index: gnu/testlet/javax/swing/text/TabSet/equals.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabSet/equals.java
diff -N gnu/testlet/javax/swing/text/TabSet/equals.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabSet/equals.java 25 Jul 2006 09:20:39 -0000
@@ -0,0 +1,58 @@
+/* equals.java -- some checks for the equals() method in the TabSet 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: JDK1.5
+
+package gnu.testlet.javax.swing.text.TabSet;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+public class equals implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabSet tsA = new TabSet(null);
+ TabSet tsB = new TabSet(null);
+ harness.check(tsA.equals(tsB));
+
+ tsA = new TabSet(new TabStop[] {});
+ tsB = new TabSet(new TabStop[] {});
+ harness.check(tsA.equals(tsB));
+
+ tsA = new TabSet(new TabStop[] {new TabStop(1.0f)});
+ tsB = new TabSet(new TabStop[] {new TabStop(1.0f)});
+ harness.check(tsA.equals(tsB));
+
+ tsA = new TabSet(new TabStop[] {new TabStop(1.1f, TabStop.ALIGN_CENTER,
+ TabStop.LEAD_DOTS)});
+ harness.check(!tsA.equals(tsB));
+ tsB = new TabSet(new TabStop[] {new TabStop(1.1f, TabStop.ALIGN_CENTER,
+ TabStop.LEAD_DOTS)});
+ harness.check(tsA.equals(tsB));
+
+ harness.check(!tsA.equals(null));
+ harness.check(!tsA.equals("a string"));
+ }
+}
Index: gnu/testlet/javax/swing/text/TabSet/getTab.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabSet/getTab.java
diff -N gnu/testlet/javax/swing/text/TabSet/getTab.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabSet/getTab.java 25 Jul 2006 09:20:39 -0000
@@ -0,0 +1,71 @@
+/* getTab.java -- some checks for the getTab() method in the TabSet 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: JDK1.4
+
+package gnu.testlet.javax.swing.text.TabSet;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+public class getTab implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabStop ts1 = new TabStop(1.0f);
+ TabStop ts2 = new TabStop(2.0f);
+ TabStop ts3 = new TabStop(3.0f);
+ TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
+ TabSet s = new TabSet(tabs);
+ harness.check(s.getTabCount(), 3);
+ harness.check(s.getTab(0), ts1);
+ harness.check(s.getTab(1), ts2);
+ harness.check(s.getTab(2), ts3);
+
+ // try negative
+ boolean pass = false;
+ try
+ {
+ s.getTab(-1);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try too large
+ pass = false;
+ try
+ {
+ s.getTab(3);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ }
+}
Index: gnu/testlet/javax/swing/text/TabSet/getTabCount.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabSet/getTabCount.java
diff -N gnu/testlet/javax/swing/text/TabSet/getTabCount.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabSet/getTabCount.java 25 Jul 2006 09:20:39 -0000
@@ -0,0 +1,47 @@
+/* getTabCount.java -- some checks for the getTabCount() method in the TabSet
+ 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: JDK1.4
+
+package gnu.testlet.javax.swing.text.TabSet;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+public class getTabCount implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabStop ts1 = new TabStop(1.0f);
+ TabStop ts2 = new TabStop(2.0f);
+ TabStop ts3 = new TabStop(3.0f);
+ TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
+ TabSet s = new TabSet(tabs);
+ harness.check(s.getTabCount(), 3);
+
+ harness.check(new TabSet(null).getTabCount(), 0);
+ }
+
+}
Index: gnu/testlet/javax/swing/text/TabSet/getTabIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabSet/getTabIndex.java
diff -N gnu/testlet/javax/swing/text/TabSet/getTabIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabSet/getTabIndex.java 25 Jul 2006 09:20:39 -0000
@@ -0,0 +1,50 @@
+/* getTabIndex.java -- some checks for the getTabIndex() method in the TabSet
+ 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: JDK1.4
+
+package gnu.testlet.javax.swing.text.TabSet;
+
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getTabIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabStop ts1 = new TabStop(1.0f);
+ TabStop ts2 = new TabStop(2.0f);
+ TabStop ts3 = new TabStop(3.0f);
+ TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
+ TabSet s = new TabSet(tabs);
+ harness.check(s.getTabIndex(ts1), 0);
+ harness.check(s.getTabIndex(ts2), 1);
+ harness.check(s.getTabIndex(ts3), 2);
+
+ harness.check(s.getTabIndex(new TabStop(2.0f)), -1);
+
+ harness.check(s.getTabIndex(null), -1);
+ }
+}
Index: gnu/testlet/javax/swing/text/TabSet/getTabIndexAfter.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabSet/getTabIndexAfter.java
diff -N gnu/testlet/javax/swing/text/TabSet/getTabIndexAfter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabSet/getTabIndexAfter.java 25 Jul 2006 09:20:40 -0000
@@ -0,0 +1,52 @@
+/* getTabIndexAfter.java -- some checks for the getTabIndexAfter() method in
+ the TabSet 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: JDK1.4
+
+package gnu.testlet.javax.swing.text.TabSet;
+
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class getTabIndexAfter implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabStop ts1 = new TabStop(1.0f);
+ TabStop ts2 = new TabStop(2.0f);
+ TabStop ts3 = new TabStop(3.0f);
+ TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
+ TabSet s = new TabSet(tabs);
+ harness.check(s.getTabIndexAfter(-1.0f), 0);
+ harness.check(s.getTabIndexAfter(0.0f), 0);
+ harness.check(s.getTabIndexAfter(0.5f), 0);
+ harness.check(s.getTabIndexAfter(1.0f), 0);
+ harness.check(s.getTabIndexAfter(1.5f), 1);
+ harness.check(s.getTabIndexAfter(2.0f), 1);
+ harness.check(s.getTabIndexAfter(2.5f), 2);
+ harness.check(s.getTabIndexAfter(3.0f), 2);
+ harness.check(s.getTabIndexAfter(3.5f), -1);
+ }
+}
Index: gnu/testlet/javax/swing/text/TabSet/toString.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabSet/toString.java
diff -N gnu/testlet/javax/swing/text/TabSet/toString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabSet/toString.java 25 Jul 2006 09:20:40 -0000
@@ -0,0 +1,48 @@
+/* toString.java -- some checks for the toString() method in the TabSet 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: JDK1.4
+
+package gnu.testlet.javax.swing.text.TabSet;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+public class toString implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabSet s = new TabSet(null);
+ harness.check(s.toString(), "[ ]");
+
+ s = new TabSet(new TabStop[] {});
+ harness.check(s.toString(), "[ ]");
+
+ s = new TabSet(new TabStop[] {new TabStop(1.0f)});
+ harness.check(s.toString(), "[ tab @1.0 ]");
+
+ s = new TabSet(new TabStop[] {new TabStop(1.0f), new TabStop(2.0f)});
+ harness.check(s.toString(), "[ tab @1.0 - tab @2.0 ]");
+ }
+}
Index: gnu/testlet/javax/swing/text/TabStop/constructors.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabStop/constructors.java
diff -N gnu/testlet/javax/swing/text/TabStop/constructors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabStop/constructors.java 25 Jul 2006 09:20:40 -0000
@@ -0,0 +1,73 @@
+/* constructors.java -- some checks for the constructors in the TabStop 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: JDK1.4
+
+package gnu.testlet.javax.swing.text.TabStop;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.TabStop;
+
+public class constructors implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ testConstructor1(harness);
+ testConstructor2(harness);
+ }
+
+ public void testConstructor1(TestHarness harness)
+ {
+ harness.checkPoint("(float)");
+ TabStop ts1 = new TabStop(1.0f);
+ harness.check(ts1.getPosition(), 1.0f);
+ harness.check(ts1.getAlignment(), TabStop.ALIGN_LEFT);
+ harness.check(ts1.getLeader(), TabStop.LEAD_NONE);
+
+ // try negative
+ ts1 = new TabStop(-1.0f);
+ harness.check(ts1.getPosition(), -1.0f);
+ }
+
+ public void testConstructor2(TestHarness harness)
+ {
+ harness.checkPoint("(float, int, int)");
+ TabStop ts1 = new TabStop(1.0f, TabStop.ALIGN_DECIMAL, TabStop.LEAD_DOTS);
+ harness.check(ts1.getPosition(), 1.0f);
+ harness.check(ts1.getAlignment(), TabStop.ALIGN_DECIMAL);
+ harness.check(ts1.getLeader(), TabStop.LEAD_DOTS);
+
+ // try bad alignment
+ ts1 = new TabStop(1.0f, 99, TabStop.LEAD_DOTS);
+ harness.check(ts1.getPosition(), 1.0f);
+ harness.check(ts1.getAlignment(), 99);
+ harness.check(ts1.getLeader(), TabStop.LEAD_DOTS);
+
+ // try bad lead
+ ts1 = new TabStop(1.0f, TabStop.ALIGN_DECIMAL, 99);
+ harness.check(ts1.getPosition(), 1.0f);
+ harness.check(ts1.getAlignment(), TabStop.ALIGN_DECIMAL);
+ harness.check(ts1.getLeader(), 99);
+ }
+
+}
Index: gnu/testlet/javax/swing/text/TabStop/toString.java
===================================================================
RCS file: gnu/testlet/javax/swing/text/TabStop/toString.java
diff -N gnu/testlet/javax/swing/text/TabStop/toString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/text/TabStop/toString.java 25 Jul 2006 09:20:40 -0000
@@ -0,0 +1,48 @@
+/* toString.java -- some checks for the toString() method in the TabStop 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: JDK1.4
+
+package gnu.testlet.javax.swing.text.TabStop;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.text.TabStop;
+
+public class toString implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ TabStop ts1 = new TabStop(1.0f);
+ harness.check(ts1.toString(), "tab @1.0");
+ ts1 = new TabStop(2.0f, TabStop.ALIGN_RIGHT, TabStop.LEAD_EQUALS);
+ harness.check(ts1.toString(), "right tab @2.0 (w/leaders)");
+ ts1 = new TabStop(10.999f, TabStop.ALIGN_CENTER, TabStop.LEAD_HYPHENS);
+ harness.check(ts1.toString(), "center tab @10.999 (w/leaders)");
+ ts1 = new TabStop(3.3f, TabStop.ALIGN_BAR, TabStop.LEAD_NONE);
+ harness.check(ts1.toString(), "bar tab @3.3");
+ ts1 = new TabStop(3.3f, TabStop.ALIGN_DECIMAL, TabStop.LEAD_UNDERLINE);
+ harness.check(ts1.toString(), "decimal tab @3.3 (w/leaders)");
+ ts1 = new TabStop(3.3f, 99, 666);
+ harness.check(ts1.toString(), "tab @3.3 (w/leaders)");
+ }
+}