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