0N/A/*
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A @test
0N/A @bug 4217441 4533872 4900935
0N/A @summary toLowerCase should lower-case Greek Sigma correctly depending
0N/A on the context (final/non-final). Also it should handle
0N/A Locale specific (lt, tr, and az) lowercasings and supplementary
0N/A characters correctly.
0N/A*/
0N/A
0N/Aimport java.util.Locale;
0N/A
0N/Apublic class ToLowerCase {
0N/A
0N/A public static void main(String[] args) {
0N/A Locale turkish = new Locale("tr", "TR");
0N/A Locale lt = new Locale("lt"); // Lithanian
0N/A Locale az = new Locale("az"); // Azeri
0N/A
0N/A // Greek Sigma final/non-final tests
0N/A test("\u03A3", Locale.US, "\u03C3");
0N/A test("LAST\u03A3", Locale.US, "last\u03C2");
0N/A test("MID\u03A3DLE", Locale.US, "mid\u03C3dle");
0N/A test("WORD1 \u03A3 WORD3", Locale.US, "word1 \u03C3 word3");
0N/A test("WORD1 LAST\u03A3 WORD3", Locale.US, "word1 last\u03C2 word3");
0N/A test("WORD1 MID\u03A3DLE WORD3", Locale.US, "word1 mid\u03C3dle word3");
0N/A test("\u0399\u0395\u03a3\u03a5\u03a3 \u03a7\u03a1\u0399\u03a3\u03a4\u039f\u03a3", Locale.US,
0N/A "\u03b9\u03b5\u03c3\u03c5\u03c2 \u03c7\u03c1\u03b9\u03c3\u03c4\u03bf\u03c2"); // "IESUS XRISTOS"
0N/A
0N/A // Explicit dot above for I's and J's whenever there are more accents above (Lithanian)
0N/A test("I", lt, "i");
0N/A test("I\u0300", lt, "i\u0307\u0300"); // "I" followed by COMBINING GRAVE ACCENT (cc==230)
0N/A test("I\u0316", lt, "i\u0316"); // "I" followed by COMBINING GRAVE ACCENT BELOW (cc!=230)
0N/A test("J", lt, "j");
0N/A test("J\u0300", lt, "j\u0307\u0300"); // "J" followed by COMBINING GRAVE ACCENT (cc==230)
0N/A test("J\u0316", lt, "j\u0316"); // "J" followed by COMBINING GRAVE ACCENT BELOW (cc!=230)
0N/A test("\u012E", lt, "\u012F");
0N/A test("\u012E\u0300", lt, "\u012F\u0307\u0300"); // "I (w/ OGONEK)" followed by COMBINING GRAVE ACCENT (cc==230)
0N/A test("\u012E\u0316", lt, "\u012F\u0316"); // "I (w/ OGONEK)" followed by COMBINING GRAVE ACCENT BELOW (cc!=230)
0N/A test("\u00CC", lt, "i\u0307\u0300");
0N/A test("\u00CD", lt, "i\u0307\u0301");
0N/A test("\u0128", lt, "i\u0307\u0303");
0N/A test("I\u0300", Locale.US, "i\u0300"); // "I" followed by COMBINING GRAVE ACCENT (cc==230)
0N/A test("J\u0300", Locale.US, "j\u0300"); // "J" followed by COMBINING GRAVE ACCENT (cc==230)
0N/A test("\u012E\u0300", Locale.US, "\u012F\u0300"); // "I (w/ OGONEK)" followed by COMBINING GRAVE ACCENT (cc==230)
0N/A test("\u00CC", Locale.US, "\u00EC");
0N/A test("\u00CD", Locale.US, "\u00ED");
0N/A test("\u0128", Locale.US, "\u0129");
0N/A
0N/A // I-dot tests (Turkish and Azeri)
0N/A test("\u0130", turkish, "i");
0N/A test("\u0130", az, "i");
1091N/A test("\u0130", Locale.US, "i\u0307");
0N/A
0N/A // Remove dot_above in the sequence I + dot_above (Turkish and Azeri)
0N/A test("I\u0307", turkish, "i");
0N/A test("I\u0307", az, "i");
0N/A test("J\u0307", turkish, "j\u0307");
0N/A test("J\u0307", az, "j\u0307");
0N/A
0N/A // Unless an I is before a dot_above, it turns into a dotless i (Turkish and Azeri)
0N/A test("I", turkish, "\u0131");
0N/A test("I", az, "\u0131");
0N/A test("I", Locale.US, "i");
0N/A test("IABC", turkish, "\u0131abc");
0N/A test("IABC", az, "\u0131abc");
0N/A test("IABC", Locale.US, "iabc");
0N/A
0N/A // Supplementary character tests
0N/A //
0N/A // U+10400 ("\uD801\uDC00"): DESERET CAPITAL LETTER LONG I
0N/A // U+10401 ("\uD801\uDC01"): DESERET CAPITAL LETTER LONG E
0N/A // U+10402 ("\uD801\uDC02"): DESERET CAPITAL LETTER LONG A
0N/A // U+10428 ("\uD801\uDC28"): DESERET SMALL LETTER LONG I
0N/A // U+10429 ("\uD801\uDC29"): DESERET SMALL LETTER LONG E
0N/A // U+1042A ("\uD801\uDC2A"): DESERET SMALL LETTER LONG A
0N/A //
0N/A // valid code point tests:
0N/A test("\uD801\uDC00\uD801\uDC01\uD801\uDC02", Locale.US, "\uD801\uDC28\uD801\uDC29\uD801\uDC2A");
0N/A test("\uD801\uDC00A\uD801\uDC01B\uD801\uDC02C", Locale.US, "\uD801\uDC28a\uD801\uDC29b\uD801\uDC2Ac");
0N/A // invalid code point tests:
0N/A test("\uD800\uD800\uD801A\uDC00\uDC00\uDC00B", Locale.US, "\uD800\uD800\uD801a\uDC00\uDC00\uDC00b");
0N/A
0N/A }
0N/A
0N/A static void test(String in, Locale locale, String expected) {
0N/A String result = in.toLowerCase(locale);
0N/A if (!result.equals(expected)) {
0N/A System.err.println("input: " + in + ", locale: " + locale +
0N/A ", expected: " + expected + ", actual: " + result);
0N/A throw new RuntimeException();
0N/A }
0N/A }
0N/A}