* FYI: AttributedCharacterIterator/AttributedString
@ 2005-10-24 9:11 David Gilbert
0 siblings, 0 replies; only message in thread
From: David Gilbert @ 2005-10-24 9:11 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 619 bytes --]
I committed these new tests / test updates:
2005-10-24 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/java/text/AttributedCharacterIterator/getAttribute.java:
New test,
* gnu/testlet/java/text/AttributedCharacterIterator/getRunStart.java:
New test,
* gnu/testlet/java/text/AttributedString/addAttribute.java: updated
FSF address,
(test2): use int check rather than '==',
* gnu/testlet/java/text/AttributedString/constructors.java: updated
FSF address,
(testConstructor1): check null argument,
(testConstructor2): check illegal arguments.
Regards,
Dave
[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 10735 bytes --]
Index: gnu/testlet/java/text/AttributedCharacterIterator/getAttribute.java
===================================================================
RCS file: gnu/testlet/java/text/AttributedCharacterIterator/getAttribute.java
diff -N gnu/testlet/java/text/AttributedCharacterIterator/getAttribute.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/AttributedCharacterIterator/getAttribute.java 24 Oct 2005 08:59:32 -0000
@@ -0,0 +1,58 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.java.text.AttributedCharacterIterator;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.font.TextAttribute;
+import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
+
+/**
+ * Some checks for the getAttribute() methods in the
+ * {@link AttributedCharacterIterator} interface.
+ */
+public class getAttribute implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not allowed).
+ */
+ public void test(TestHarness harness)
+ {
+ harness.checkPoint("getAttribute(AttributedCharacterIterator.Attribute);");
+
+ AttributedString as = new AttributedString("ABCDEFG");
+ as.addAttribute(TextAttribute.LANGUAGE, "English");
+ AttributedCharacterIterator aci = as.getIterator();
+
+ harness.check(aci.getAttribute(TextAttribute.LANGUAGE), "English");
+ harness.check(aci.getAttribute(TextAttribute.FONT), null);
+
+ // try null attribute
+ harness.check(aci.getAttribute(null), null);
+ }
+
+}
Index: gnu/testlet/java/text/AttributedCharacterIterator/getRunStart.java
===================================================================
RCS file: gnu/testlet/java/text/AttributedCharacterIterator/getRunStart.java
diff -N gnu/testlet/java/text/AttributedCharacterIterator/getRunStart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/AttributedCharacterIterator/getRunStart.java 24 Oct 2005 08:59:33 -0000
@@ -0,0 +1,90 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.java.text.AttributedCharacterIterator;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.awt.font.TextAttribute;
+import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
+import java.util.Set;
+
+/**
+ * Some checks for the getRunStart() methods in the
+ * {@link AttributedCharacterIterator} interface.
+ */
+public class getRunStart implements Testlet
+{
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not allowed).
+ */
+ public void test(TestHarness harness)
+ {
+ test1(harness);
+ test2(harness);
+ test3(harness);
+ }
+
+ private void test1(TestHarness harness)
+ {
+ harness.checkPoint("getRunStart();");
+ AttributedString as = new AttributedString("ABCDEFG");
+ as.addAttribute(TextAttribute.LANGUAGE, "English");
+ as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4);
+ AttributedCharacterIterator aci = as.getIterator();
+ harness.check(aci.getRunStart(), 0);
+ aci.setIndex(3);
+ harness.check(aci.getRunStart(), 2);
+ }
+
+ private void test2(TestHarness harness)
+ {
+ harness.checkPoint("getRunStart(AttributedCharacterIterator.Attribute);");
+ AttributedString as = new AttributedString("ABCDEFG");
+ as.addAttribute(TextAttribute.LANGUAGE, "English");
+ as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4);
+ AttributedCharacterIterator aci = as.getIterator();
+ harness.check(aci.getRunStart(TextAttribute.LANGUAGE), 0);
+ aci.setIndex(3);
+ harness.check(aci.getRunStart(TextAttribute.FOREGROUND), 2);
+ }
+
+ private void test3(TestHarness harness)
+ {
+ harness.checkPoint("getRunStart(Set);");
+ AttributedString as = new AttributedString("ABCDEFG");
+ as.addAttribute(TextAttribute.LANGUAGE, "English");
+ AttributedCharacterIterator aci = as.getIterator();
+
+ // try null set
+ harness.check(aci.getRunStart((Set) null), 0);
+
+ AttributedCharacterIterator aci2 = as.getIterator(null, 4, 7);
+ harness.check(aci2.getRunStart((Set) null), 4);
+ }
+
+}
Index: gnu/testlet/java/text/AttributedString/addAttribute.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/AttributedString/addAttribute.java,v
retrieving revision 1.1
diff -u -r1.1 addAttribute.java
--- gnu/testlet/java/text/AttributedString/addAttribute.java 14 Jun 2005 12:49:48 -0000 1.1
+++ gnu/testlet/java/text/AttributedString/addAttribute.java 24 Oct 2005 08:59:33 -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.java.text.AttributedString;
@@ -92,13 +92,13 @@
AttributedString as = new AttributedString("ABCDEFG");
as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "Unknown", 2, 4);
AttributedCharacterIterator aci = as.getIterator();
- harness.check(aci.getRunStart(AttributedCharacterIterator.Attribute.LANGUAGE) == 0);
- harness.check(aci.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE) == 2);
+ harness.check(aci.getRunStart(AttributedCharacterIterator.Attribute.LANGUAGE), 0);
+ harness.check(aci.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE), 2);
aci.next();
aci.next();
aci.next();
- harness.check(aci.getRunStart(AttributedCharacterIterator.Attribute.LANGUAGE) == 2);
- harness.check(aci.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE) == 4);
+ harness.check(aci.getRunStart(AttributedCharacterIterator.Attribute.LANGUAGE), 2);
+ harness.check(aci.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE), 4);
// if beginIndex < 0, there should be an IllegalArgumentException
boolean pass = false;
Index: gnu/testlet/java/text/AttributedString/constructors.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/AttributedString/constructors.java,v
retrieving revision 1.1
diff -u -r1.1 constructors.java
--- gnu/testlet/java/text/AttributedString/constructors.java 14 Jun 2005 12:49:48 -0000 1.1
+++ gnu/testlet/java/text/AttributedString/constructors.java 24 Oct 2005 08:59:33 -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.java.text.AttributedString;
@@ -50,12 +50,68 @@
private void testConstructor1(TestHarness harness)
{
- harness.checkPoint("AttributedString(AttributedCharacterIterator);");
+ harness.checkPoint("AttributedString(AttributedCharacterIterator);");
+
+ // it isn't specified, but we assume a NullPointerException if the iterator
+ // is null
+ boolean pass = false;
+ try
+ {
+ /* AttributedString as = */
+ new AttributedString((AttributedCharacterIterator) null);
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
}
private void testConstructor2(TestHarness harness)
{
- harness.checkPoint("AttributedString(AttributedCharacterIterator, int, int);");
+ harness.checkPoint("AttributedString(AttributedCharacterIterator, int, int);");
+ AttributedString source = new AttributedString("ABCDEFGHIJ");
+ AttributedCharacterIterator sourceACI = source.getIterator();
+
+ // should get an IllegalArgumentException if the start index is outside the
+ // valid range
+ boolean pass = false;
+ try
+ {
+ /*AttributedString as =*/ new AttributedString(sourceACI, -1, 2);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // should get an IllegalArgumentException if the end index is outside the
+ // valid range
+ pass = false;
+ try
+ {
+ /*AttributedString as =*/ new AttributedString(sourceACI, 2, 12);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // it isn't specified, but we assume a NullPointerException if the iterator
+ // is null
+ pass = false;
+ try
+ {
+ /* AttributedString as = */
+ new AttributedString((AttributedCharacterIterator) null, 1, 5);
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
}
private void testConstructor3(TestHarness harness)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-24 9:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-24 9:11 FYI: AttributedCharacterIterator/AttributedString 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).