01: /*
02: *******************************************************************************
03: * Copyright (C) 2005, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: */
07:
08: package com.ibm.icu.dev.test.normalizer;
09:
10: import com.ibm.icu.dev.test.TestFmwk;
11: import com.ibm.icu.text.Normalizer;
12:
13: public class NormalizerRegressionTests extends TestFmwk {
14: public static void main(String[] args) throws Exception {
15: new NormalizerRegressionTests().run(args);
16: }
17:
18: public void TestJB4472() {
19: // submitter's test case
20: String tamil = "\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe";
21: logln("Normalized: "
22: + Normalizer.isNormalized(tamil, Normalizer.NFC, 0));
23:
24: // markus's test case
25: // the combining cedilla can't be applied to 'b', so this is in normalized form.
26: // but the isNormalized test identifies the cedilla as a 'maybe' and so tries
27: // to normalize the relevant substring ("b\u0327")and compare the result to the
28: // original. the original code was passing in the start and length of the
29: // substring (3, 5-3 = 2) but the called code was expecting start and limit.
30: // it subtracted the start again to get what it thought was the length, but
31: // ended up with -1. the loop was incrementing an index from 0 and testing
32: // against length, but 0 was never == -1 before it walked off the array end.
33:
34: // a workaround in lieu of this patch is to catch the exception and always
35: // normalize.
36:
37: // this should return true, since the string is normalized (and it should
38: // not throw an exception!)
39: String sample = "aaab\u0327";
40: logln("Normalized: "
41: + Normalizer.isNormalized(sample, Normalizer.NFC, 0));
42:
43: // this should return false, since the string is _not_ normalized (and it should
44: // not throw an exception!)
45: String sample2 = "aaac\u0327";
46: logln("Normalized: "
47: + Normalizer.isNormalized(sample2, Normalizer.NFC, 0));
48: }
49: }
|