3088N/A/*
3088N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3088N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3088N/A *
3088N/A * This code is free software; you can redistribute it and/or modify it
3088N/A * under the terms of the GNU General Public License version 2 only, as
3088N/A * published by the Free Software Foundation.
3088N/A *
3088N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3088N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3088N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3088N/A * version 2 for more details (a copy is included in the LICENSE file that
3088N/A * accompanied this code).
3088N/A *
3088N/A * You should have received a copy of the GNU General Public License version
3088N/A * 2 along with this work; if not, write to the Free Software Foundation,
3088N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3088N/A *
3088N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3088N/A * or visit www.oracle.com if you need additional information or have any
3088N/A * questions.
3088N/A */
3088N/A
3088N/A/*
3088N/A * @test
3088N/A * @bug 7002398
3088N/A * @summary Verify that Corrigendum #8 for Unicode 6.0.0 has been applied.
3088N/A */
3088N/Aimport java.text.*;
3088N/A
3088N/Apublic class Bug7002398 {
3088N/A
3088N/A private static final int[] directions = {
3088N/A Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT,
3088N/A Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT,
3088N/A Bidi.DIRECTION_LEFT_TO_RIGHT,
3088N/A Bidi.DIRECTION_RIGHT_TO_LEFT
3088N/A };
3088N/A
3088N/A /*
3088N/A * Old Bidi class: AL AN AL AN AL
3088N/A * New Bidi class: AL
3088N/A */
3088N/A private static final String str = "\u0627\u0660\u0710\u070F\u070D";
3088N/A private static final int[] expectedLevels = {1, 2, 1, 1, 1};
3088N/A
3088N/A public static void main(String[] args) {
3088N/A boolean err = false;
3088N/A
3088N/A for (int dir = 0; dir < directions.length; dir ++) {
3088N/A Bidi bidi = new Bidi(str, directions[dir]);
3088N/A for (int index = 0; index < str.length(); index ++) {
3088N/A int gotLevel = bidi.getLevelAt(index);
3088N/A if (gotLevel != expectedLevels[index]) {
3088N/A err = true;
3088N/A System.err.println("Unexpected level for the character 0x" +
3088N/A Integer.toHexString(str.charAt(index)).toUpperCase() +
3088N/A ": Expected level = " + expectedLevels[index] +
3088N/A ", actual level = " + bidi.getLevelAt(index) +
3088N/A " in direction = " + directions[dir] + ".");
3088N/A }
3088N/A }
3088N/A }
3088N/A
3088N/A if (err) {
3088N/A throw new RuntimeException("Failed.");
3088N/A }
3088N/A }
3088N/A
3088N/A}