jdk/test/sun/text/resources/Collator/Bug4804273.java
author duke
Wed, 05 Jul 2017 16:48:18 +0200
changeset 2092 b86b8d6d48bd
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4804273
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary updating collation tables for swedish
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
public class Bug4804273 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  /********************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  *********************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  public static void main (String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
      int errors=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
      Locale loc = new Locale ("sv", "se");   // Swedish
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
      Locale.setDefault (loc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
      Collator col = Collator.getInstance ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
      String[] data = {"A",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                       "Aa",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
                       "Ae",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                       "B",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
                       "Y",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
                       "U\u0308", // U-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                       "Z",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                       "A\u030a", // A-ring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                       "A\u0308", // A-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                       "\u00c6", // AE ligature
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                       "O\u0308", // O-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                       "a\u030b", // a-double-acute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                       "\u00d8", // O-stroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                       "a",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                       "aa",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                       "ae",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                       "b",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                       "y",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                       "u\u0308", // u-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                       "z",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                       "A\u030b", // A-double-acute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                       "a\u030a", // a-ring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                       "a\u0308", // a-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                       "\u00e6", // ae ligature
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                       "o\u0308", // o-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                       "\u00f8", // o-stroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
      };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
      String[] sortedData = {"a",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                             "A",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                             "aa",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                             "Aa",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                             "ae",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                             "Ae",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                             "b",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                             "B",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                             "y",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                             "Y",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                             "u\u0308", // o-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                             "U\u0308", // o-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                             "z",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                             "Z",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                             "a\u030a", // a-ring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                             "A\u030a", // A-ring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                             "a\u0308", // a-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                             "A\u0308", // A-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                             "a\u030b", // a-double-acute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                             "A\u030b", // A-double-acute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                             "\u00e6", // ae ligature
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                             "\u00c6", // AE ligature
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                             "o\u0308", // o-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                             "O\u0308", // O-umlaut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                             "\u00f8", // o-stroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                             "\u00d8", // O-stroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
      Arrays.sort (data, col);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
      System.out.println ("Using " + loc.getDisplayName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
      for (int i = 0;  i < data.length;  i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
          System.out.println(data[i] + "  :  " + sortedData[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
          if (sortedData[i].compareTo(data[i]) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
              errors++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      }//end for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
      if (errors > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
          throw new RuntimeException("There are " + errors + " words sorted incorrectly!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  }//end main
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
}//end class CollatorTest