1 /*
  2  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 4930708 4174436 5008498
 27  * @library /java/text/testlib
 28  * @summary test Danish Collation
 29  * @modules jdk.localedata
 30  * @run junit DanishTest
 31  */
 32 /*
 33 (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
 34 (C) Copyright IBM Corp. 1996 - All Rights Reserved
 35 
 36   The original version of this source code and documentation is copyrighted and
 37 owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
 38 provided under terms of a License Agreement between Taligent and Sun. This
 39 technology is protected by multiple US and International patents. This notice and
 40 attribution to Taligent may not be removed.
 41   Taligent is a registered trademark of Taligent, Inc.
 42 */
 43 
 44 import java.util.Locale;
 45 import java.text.Collator;
 46 
 47 import org.junit.jupiter.api.Test;
 48 
 49 import static org.junit.jupiter.api.Assertions.fail;
 50 
 51 // Quick dummy program for printing out test results
 52 public class DanishTest {
 53 
 54     /*
 55      * Data for TestPrimary()
 56      */
 57     private static final String[] primarySourceData = {
 58         "Lvi",
 59         "L\u00E4vi",
 60         "L\u00FCbeck",
 61         "ANDR\u00C9",
 62         "ANDRE",
 63         "ANNONCERER"
 64     };
 65 
 66     private static final String[] primaryTargetData = {
 67             "Lwi",
 68             "L\u00F6wi",
 69             "Lybeck",
 70             "ANDR\u00E9",
 71             "ANDR\u00C9",
 72             "ANN\u00D3NCERER"
 73     };
 74 
 75     private static final int[] primaryResults = {
 76             -1, -1, 0, 0, 0, 0
 77     };
 78 
 79     /*
 80      * Data for TestTertiary()
 81      */
 82     private static final String[] tertiarySourceData = {
 83             "Luc",
 84             "luck",
 85             "L\u00FCbeck",
 86             "L\u00E4vi",
 87             "L\u00F6ww"
 88     };
 89 
 90     private static final String[] tertiaryTargetData = {
 91             "luck",
 92             "L\u00FCbeck",
 93             "lybeck",
 94             "L\u00F6we",
 95             "mast"
 96     };
 97 
 98     private static final int[] tertiaryResults = {
 99             -1, -1,  1, -1, -1
100     };
101 
102     /*
103      * Data for TestExtra()
104      */
105     private static final String[] testData = {
106             "A/S",
107             "ANDRE",
108             "ANDR\u00C9", // E-acute
109             "ANDR\u00C8", // E-grave
110             "ANDR\u00E9", // e-acute
111             "ANDR\u00EA", // e-circ
112             "Andre",
113             "Andr\u00E9", // e-acute
114             "\u00C1NDRE", // A-acute
115             "\u00C0NDRE", // A-grave
116             "andre",
117             "\u00E1ndre", // a-acute
118             "\u00E0ndre", // a-grave
119             "ANDREAS",
120             "ANNONCERER",
121             "ANN\u00D3NCERER", // O-acute
122             "annoncerer",
123             "ann\u00F3ncerer", // o-acute
124             "AS",
125             "A\u00e6RO", // ae-ligature
126             "CA",
127             "\u00C7A", // C-cedilla
128             "CB",
129             "\u00C7C", // C-cedilla
130             "D.S.B.",
131             "DA",
132             "DB",
133             "\u00D0ORA", // capital eth
134             "DSB",
135             "\u00D0SB", // capital eth
136             "DSC",
137             "EKSTRA_ARBEJDE",
138             "EKSTRABUD",
139             "H\u00D8ST",  // could the 0x00D8 be 0x2205?
140             "HAAG",
141             "H\u00C5NDBOG", // A-ring
142             "HAANDV\u00C6RKSBANKEN", // AE-ligature
143             "INTERNETFORBINDELSE",
144             "Internetforbindelse",
145             "\u00CDNTERNETFORBINDELSE", // I-acute
146             "internetforbindelse",
147             "\u00EDnternetforbindelse", // i-acute
148             "Karl",
149             "karl",
150             "NIELSEN",
151             "NIELS J\u00D8RGEN", // O-slash
152             "NIELS-J\u00D8RGEN", // O-slash
153             "OERVAL",
154             "\u0152RVAL", // OE-ligature
155             "\u0153RVAL", // oe-ligature
156             "R\u00C9E, A", // E-acute
157             "REE, B",
158             "R\u00C9E, L", // E-acute
159             "REE, V",
160             "SCHYTT, B",
161             "SCHYTT, H",
162             "SCH\u00DCTT, H", // U-diaeresis
163             "SCHYTT, L",
164             "SCH\u00DCTT, M", // U-diaeresis
165             "SS",
166             "ss",
167             "\u00DF", // sharp S
168             "SSA",
169             "\u00DFA", // sharp S
170             "STOREK\u00C6R", // AE-ligature
171             "STORE VILDMOSE",
172             "STORMLY",
173             "STORM PETERSEN",
174             "THORVALD",
175             "THORVARDUR",
176             "\u00DEORVAR\u0110UR", //  capital thorn, capital d-stroke(like eth) (sami)
177             "THYGESEN",
178             "VESTERG\u00C5RD, A",
179             "VESTERGAARD, A",
180             "VESTERG\u00C5RD, B",                // 50
181             "Westmalle",
182             "YALLE",
183             "Yderligere",
184             "\u00DDderligere", // Y-acute
185             "\u00DCderligere", // U-diaeresis
186             "\u00FDderligere", // y-acute
187             "\u00FCderligere", // u-diaeresis
188             "U\u0308ruk-hai",
189             "ZORO",
190             "\u00C6BLE",  // AE-ligature
191             "\u00E6BLE",  // ae-ligature
192             "\u00C4BLE",  // A-diaeresis
193             "\u00E4BLE",  // a-diaeresis
194             "\u00D8BERG", // O-stroke
195             "\u00F8BERG", // o-stroke
196             "\u00D6BERG", // O-diaeresis
197             "\u00F6BERG"  // o-diaeresis
198     };
199 
200     @Test
201     public void TestPrimary() {
202         TestUtils.doCollatorTest(myCollation, Collator.PRIMARY,
203                primarySourceData, primaryTargetData, primaryResults);
204     }
205 
206     @Test
207     public void TestTertiary() {
208         TestUtils.doCollatorTest(myCollation, Collator.TERTIARY,
209                tertiarySourceData, tertiaryTargetData, tertiaryResults);
210 
211         for (int i = 0; i < testData.length-1; i++) {
212             for (int j = i+1; j < testData.length; j++) {
213                 TestUtils.doCollatorTest(myCollation, testData[i], testData[j], -1);
214             }
215         }
216     }
217 
218     private final Collator myCollation = Collator.getInstance(Locale.of("da"));
219 }