From 6cbea9f8940290a05e66bb6a8de9c5f9e0b5a09c Mon Sep 17 00:00:00 2001 From: dchandler Date: Mon, 5 Jul 2004 04:10:38 +0000 Subject: [PATCH] Fixed crashing bug reported by Teresa Lam. Added tests so that I'm fairly certain that no more crashing bugs exist. Removed a marker for iffy code after understanding that code via test cases. --- source/org/thdl/tib/input/DuffPaneTest.java | 19 +++++++++++++++++++ .../org/thdl/tib/text/TibetanMachineWeb.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/source/org/thdl/tib/input/DuffPaneTest.java b/source/org/thdl/tib/input/DuffPaneTest.java index 4d7cdcd..1ce6dbe 100644 --- a/source/org/thdl/tib/input/DuffPaneTest.java +++ b/source/org/thdl/tib/input/DuffPaneTest.java @@ -93,6 +93,13 @@ public class DuffPaneTest extends TestCase { ensureKeysGiveCorrectWylie(in, out); } + private void noExceptions(String keys) { + dp.newDocument(); // initialize to a blank canvas. + fireKeysWithoutModifiers(keys); + // no assertion -- if an exception happens, then and only then + // the test fails. + } + private void ensureKeysGiveCorrectWylie(String keys, String wylie) { dp.newDocument(); // initialize to a blank canvas. fireKeysWithoutModifiers(keys); @@ -803,6 +810,18 @@ public class DuffPaneTest extends TestCase { */ } + public void testNoKeysCrashUs() { + /* why 130? because we want to try some extended ASCII + characters to make sure that they don't crash us either */ + char max = (char)130; + for (char ch = 0; ch < max; ch++) { + noExceptions("" + ch); + for (char ch2 = 0; ch2 < max; ch2++) { + noExceptions("" + ch + ch2); + } + } + } + public void testDisambiguation() { ensureKeysGiveCorrectWylie("gya"); ensureKeysGiveCorrectWylie("g.ya"); diff --git a/source/org/thdl/tib/text/TibetanMachineWeb.java b/source/org/thdl/tib/text/TibetanMachineWeb.java index dc86df4..521597e 100644 --- a/source/org/thdl/tib/text/TibetanMachineWeb.java +++ b/source/org/thdl/tib/text/TibetanMachineWeb.java @@ -212,7 +212,7 @@ public class TibetanMachineWeb implements THDLWylieConstants { /** comma-delimited list of supported punctuation and miscellaneous characters: */ private static final String others - = "_, ,/,|,!,:,;,@,#,$,%,(,),H,M,&,@#,?,=,[,],{,},*,~X,X"; // FIXME: not yet supporting all these... + = "_, ,/,|,!,:,;,@,#,$,%,(,),H,M,&,@#,?,=,{,},*,~X,X"; // FIXME: not yet supporting all these... /** comma-delimited list of supported vowels: */ private static final String vowels