This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
Patch: FYI: Bidi tests
- From: Tom Tromey <tromey at redhat dot com>
- To: Mauve Patch List <mauve-patches at sources dot redhat dot com>
- Date: 21 Mar 2006 12:52:38 -0700
- Subject: Patch: FYI: Bidi tests
- Reply-to: tromey at redhat dot com
I'm checking this in.
This adds tests for a couple of java.text.Bidi things.
Tom
2006-03-21 Tom Tromey <tromey@redhat.com>
* gnu/testlet/java/text/Bidi/reorderVisually.java: New file.
* gnu/testlet/java/text/Bidi/Basic.java: New file.
Index: gnu/testlet/java/text/Bidi/Basic.java
===================================================================
RCS file: gnu/testlet/java/text/Bidi/Basic.java
diff -N gnu/testlet/java/text/Bidi/Basic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/Bidi/Basic.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,68 @@
+/* Basic.java -- Tests of main Bidi functionality
+ Copyright (C) 2006 Red Hat, Inc.
+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.java.text.Bidi;
+
+import java.text.Bidi;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class Basic implements Testlet
+{
+ public void testOne(TestHarness harness, Bidi bidi, String expected)
+ {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < bidi.getLength(); ++i)
+ buf.append(bidi.getLevelAt(i));
+ harness.check(buf.toString(), expected);
+ }
+
+ public void test(TestHarness harness)
+ {
+ Bidi b;
+
+ harness.checkPoint("simple");
+ b = new Bidi("hi bob", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+ testOne(harness, b, "000000");
+ harness.check(b.baseIsLeftToRight());
+ harness.check(b.isLeftToRight());
+ harness.check(b.getRunCount(), 1);
+
+ harness.checkPoint("one embedding");
+ b = new Bidi("hi \u202bbob", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+ testOne(harness, b, "0002222");
+
+ harness.checkPoint("override");
+ b = new Bidi("hi \u202ebob", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+ testOne(harness, b, "0001111");
+
+ harness.checkPoint("override and pop");
+ b = new Bidi("car means \u202eCAR\u202c.",
+ Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+ testOne(harness, b, "0000000000111100");
+ b = new Bidi("car \u202eMEANS CAR\u202c.",
+ Bidi.DIRECTION_RIGHT_TO_LEFT);
+ testOne(harness, b, "2221333333333311");
+ }
+}
Index: gnu/testlet/java/text/Bidi/reorderVisually.java
===================================================================
RCS file: gnu/testlet/java/text/Bidi/reorderVisually.java
diff -N gnu/testlet/java/text/Bidi/reorderVisually.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/Bidi/reorderVisually.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,69 @@
+/* reorderVisually.java -- test bidi algorithm
+ Copyright (C) 2006 Red Hat, Inc.
+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.java.text.Bidi;
+
+import java.text.Bidi;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class reorderVisually implements Testlet
+{
+ public void testOne(TestHarness harness, String input, String levels,
+ String expected)
+ {
+ Object[] inputA = new Object[input.length()];
+ byte[] levelsA = new byte[levels.length()];
+
+ for (int i = 0; i < input.length(); ++i)
+ {
+ inputA[i] = input.substring(i, i + 1);
+ levelsA[i] = (byte) (levels.charAt(i) - '0');
+ }
+
+ Bidi.reorderVisually(levelsA, 0, inputA, 0, inputA.length);
+
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < inputA.length; ++i)
+ result.append(inputA[i]);
+
+ harness.check(result.toString(), expected);
+ }
+
+ public void test(TestHarness harness)
+ {
+ // These tests come from unicode.org:
+ // http://www.unicode.org/reports/tr9/
+ testOne(harness, "car means CAR.", "00000000001110",
+ "car means RAC.");
+ testOne(harness, "car MEANS CAR.", "22211111111111",
+ ".RAC SNAEM car");
+ testOne(harness, "he said \"car MEANS CAR.\"",
+ "000000000222111111111100",
+ "he said \"RAC SNAEM car.\"");
+ testOne(harness, "DID YOU SAY 'he said \"car MEANS CAR\"'?",
+ "11111111111112222222224443333333333211",
+ "?'he said \"RAC SNAEM car\"' YAS UOY DID");
+ }
+}