Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/text/Bidi/Bug7051769.java
38813 views
/*1* Copyright (c) 2011, 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 705176926* @summary verify that Bidi.toString() returns the corect result.27*/28import java.awt.font.*;29import java.text.*;30import java.util.*;3132public class Bug7051769 {3334private static boolean err = false;3536public static void main(String[] args) {37testNumericShaping();3839if (err) {40throw new RuntimeException("Failed");41} else {42System.out.println("Passed.");43}44}4546private static void testNumericShaping() {47Map attrNS = new HashMap();48attrNS.put(TextAttribute.NUMERIC_SHAPING,49NumericShaper.getContextualShaper(NumericShaper.ARABIC));50attrNS.put(TextAttribute.RUN_DIRECTION,51TextAttribute.RUN_DIRECTION_RTL);5253String text = "\u0623\u0643\u062a\u0648\u0628\u0631 10";54String expected = "sun.text.bidi.BidiBase[dir: 2 baselevel: 1 length: 9 runs: [1 1 1 1 1 1 1 2 2] text: [0x623 0x643 0x62a 0x648 0x628 0x631 0x20 0x661 0x660]]";5556AttributedString as = new AttributedString(text, attrNS);57AttributedCharacterIterator itr = as.getIterator();58itr.last();59itr.next();60Bidi bidi = new Bidi(itr);61String got = bidi.toString();6263if (!got.equals(expected)) {64err = true;65System.err.println("Wrong toString() output: " +66"\n\tExpected=" + expected +67"\n\tGot=" + got);68}69}7071}727374