Path: blob/master/test/jdk/java/text/Bidi/Bug7002398.java
41149 views
/*1* Copyright (c) 2010, 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 700239826* @summary Verify that Corrigendum #8 for Unicode 6.0.0 has been applied.27*/28import java.text.*;2930public class Bug7002398 {3132private static final int[] directions = {33Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT,34Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT,35Bidi.DIRECTION_LEFT_TO_RIGHT,36Bidi.DIRECTION_RIGHT_TO_LEFT37};3839/*40* Old Bidi class: AL AN AL AN AL41* New Bidi class: AL42*/43private static final String str = "\u0627\u0660\u0710\u070F\u070D";44private static final int[] expectedLevels = {1, 2, 1, 1, 1};4546public static void main(String[] args) {47boolean err = false;4849for (int dir = 0; dir < directions.length; dir ++) {50Bidi bidi = new Bidi(str, directions[dir]);51for (int index = 0; index < str.length(); index ++) {52int gotLevel = bidi.getLevelAt(index);53if (gotLevel != expectedLevels[index]) {54err = true;55System.err.println("Unexpected level for the character 0x" +56Integer.toHexString(str.charAt(index)).toUpperCase() +57": Expected level = " + expectedLevels[index] +58", actual level = " + bidi.getLevelAt(index) +59" in direction = " + directions[dir] + ".");60}61}62}6364if (err) {65throw new RuntimeException("Failed.");66}67}6869}707172