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