Path: blob/master/test/jdk/java/text/Collator/Bug5047314.java
41149 views
/*1* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 504731426* @summary verify that compare() and getCollationKey() don't go into an infinite loop for unfinished Thai/Lao text.27* @run main/timeout=60 Bug504731428*/29import java.text.Collator;30import java.util.Locale;3132public class Bug5047314 {3334private static Collator colLao = Collator.getInstance(new Locale("lo"));35private static Collator colThai = Collator.getInstance(new Locale("th"));3637private static String[] textLao = {38"\u0ec0", "\u0ec1", "\u0ec2", "\u0ec3", "\u0ec4"39};40private static String[] textThai = {41"\u0e40", "\u0e41", "\u0e42", "\u0e43", "\u0e44"42};4344public static void main(String[] args) {45testLao1();46testLao2();47testThai1();48testThai2();49}5051private static void testLao1() {52System.out.print("Test(Lao 1) .... ");53for (int i = 0; i < textLao.length; i++) {54colLao.compare(textLao[i], textLao[i]);55}56System.out.println("Passed.");57}5859private static void testLao2() {60System.out.print("Test(Lao 2) .... ");61for (int i = 0; i < textLao.length; i++) {62colLao.compare(textLao[i], textLao[i]);63}64System.out.println("Passed.");65}6667private static void testThai1() {68System.out.print("Test(Thai 1) .... ");69for (int i = 0; i < textThai.length; i++) {70colThai.compare(textThai[i], textThai[i]);71}72System.out.println("Passed.");73}7475private static void testThai2() {76System.out.print("Test(Thai 2) .... ");77for (int i = 0; i < textThai.length; i++) {78colThai.getCollationKey(textThai[i]);79}80System.out.println("Passed.");81}8283}848586