1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/********************************************************************
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * COPYRIGHT:
38393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * Copyright (c) 1997-2013, International Business Machines Corporation and
4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * others. All Rights Reserved.
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ********************************************************************/
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "loctest.h"
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/decimfmt.h"
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/ucurr.h"
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/smpdtfmt.h"
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/dtfmtsym.h"
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/brkiter.h"
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/coll.h"
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cstring.h"
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <stdio.h>
16b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include <string.h>
17c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "putilimp.h"
18c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "unicode/ustring.h"
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic const char* const rawData[33][8] = {
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // language code
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "en",   "fr",   "ca",   "el",   "no",   "it",   "xx",   "zh"  },
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // script code
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "",     "",     "",     "",     "",     "",     "",     "Hans" },
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // country code
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "US",   "FR",   "ES",   "GR",   "NO",   "",     "YY",   "CN"  },
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // variant code
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "",     "",     "",     "",     "NY",   "",     "",   ""    },
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // full name
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "en_US",    "fr_FR",    "ca_ES",    "el_GR",    "no_NO_NY", "it",   "xx_YY",   "zh_Hans_CN" },
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // ISO-3 language
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "eng",  "fra",  "cat",  "ell",  "nor",  "ita",  "",   "zho"   },
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // ISO-3 country
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "USA",  "FRA",  "ESP",  "GRC",  "NOR",  "",     "",   "CHN"   },
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // LCID
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "409", "40c", "403", "408", "814", "10",     "0",   "804"  },
38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display langage (English)
40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "English",  "French",   "Catalan", "Greek",    "Norwegian",    "Italian",  "xx",   "Chinese" },
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display script (English)
42103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius        {   "",     "",     "",     "",     "",   "",     "",   "Simplified Han" },
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display country (English)
44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "United States",    "France",   "Spain",  "Greece",   "Norway",   "",     "YY",   "China" },
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display variant (English)
46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "",     "",     "",     "",     "NY",   "",     "",   ""},
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display name (English)
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // Updated no_NO_NY English display name for new pattern-based algorithm
49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // (part of Euro support).
50b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        {   "English (United States)", "French (France)", "Catalan (Spain)", "Greek (Greece)", "Norwegian (Norway, NY)", "Italian", "xx (YY)", "Chinese (Simplified, China)" },
51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display langage (French)
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "anglais",  "fran\\u00E7ais",   "catalan", "grec",    "norv\\u00E9gien",    "italien", "xx", "chinois" },
54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display script (French)
5559d709d503bab6e2b61931737e662dd293b40578ccornelius        {   "",     "",     "",     "",     "",     "",     "",   "sinogrammes simplifi\\u00E9s" },
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display country (French)
57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "\\u00C9tats-Unis",    "France",   "Espagne",  "Gr\\u00E8ce",   "Norv\\u00E8ge", "", "YY", "Chine" },
58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display variant (French)
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "",     "",     "",     "",     "NY",     "",     "",   "" },
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display name (French)
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        //{   "anglais (Etats-Unis)", "francais (France)", "catalan (Espagne)", "grec (Grece)", "norvegien (Norvege,Nynorsk)", "italien", "xx (YY)" },
6259d709d503bab6e2b61931737e662dd293b40578ccornelius        {   "anglais (\\u00C9tats-Unis)", "fran\\u00E7ais (France)", "catalan (Espagne)", "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)", "italien", "xx (YY)", "chinois (simplifi\\u00E9, Chine)" },
63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* display language (Catalan) */
66c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        {   "angl\\u00E8s", "franc\\u00E8s", "catal\\u00E0", "grec",  "noruec", "itali\\u00E0", "", "xin\\u00E8s" },
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* display script (Catalan) */
6859d709d503bab6e2b61931737e662dd293b40578ccornelius        {   "", "", "",                    "", "", "", "", "han simplificat" },
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* display country (Catalan) */
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "Estats Units", "Fran\\u00E7a", "Espanya",  "Gr\\u00E8cia", "Noruega", "", "", "Xina" },
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* display variant (Catalan) */
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "", "", "",                    "", "NY", "", "" },
73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* display name (Catalan) */
74b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        {   "angl\\u00E8s (Estats Units)", "franc\\u00E8s (Fran\\u00E7a)", "catal\\u00E0 (Espanya)", "grec (Gr\\u00E8cia)", "noruec (Noruega, NY)", "itali\\u00E0", "", "xin\\u00E8s (simplificat, Xina)" },
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display langage (Greek)[actual values listed below]
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac",
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0393\\u03b1\\u03bb\\u03bb\\u03b9\\u03ba\\u03ac",
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u039a\\u03b1\\u03c4\\u03b1\\u03bb\\u03b1\\u03bd\\u03b9\\u03ba\\u03ac",
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0395\\u03bb\\u03bb\\u03b7\\u03bd\\u03b9\\u03ba\\u03ac",
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03b9\\u03ba\\u03ac",
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0399\\u03c4\\u03b1\\u03bb\\u03b9\\u03ba\\u03ac",
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "",
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC"
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        },
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display script (Greek)
8759d709d503bab6e2b61931737e662dd293b40578ccornelius        {   "", "", "", "", "", "", "", "\\u0391\\u03c0\\u03bb\\u03bf\\u03c0\\u03bf\\u03b9\\u03b7\\u03bc\\u03ad\\u03bd\\u03bf \\u03a7\\u03b1\\u03bd" },
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display country (Greek)[actual values listed below]
8959d709d503bab6e2b61931737e662dd293b40578ccornelius        {   "\\u0397\\u03BD\\u03C9\\u03BC\\u03AD\\u03BD\\u03B5\\u03C2 \\u03A0\\u03BF\\u03BB\\u03B9\\u03C4\\u03B5\\u03AF\\u03B5\\u03C2",
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0393\\u03b1\\u03bb\\u03bb\\u03af\\u03b1",
91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0399\\u03c3\\u03c0\\u03b1\\u03bd\\u03af\\u03b1",
92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0395\\u03bb\\u03bb\\u03ac\\u03b4\\u03b1",
93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03af\\u03b1",
94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "",
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "",
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u039A\\u03AF\\u03BD\\u03B1"
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        },
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display variant (Greek)
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "", "", "", "", "NY", "", "" },
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display name (Greek)[actual values listed below]
10159d709d503bab6e2b61931737e662dd293b40578ccornelius        {   "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac (\\u0397\\u03BD\\u03C9\\u03BC\\u03AD\\u03BD\\u03B5\\u03C2 \\u03A0\\u03BF\\u03BB\\u03B9\\u03C4\\u03B5\\u03AF\\u03B5\\u03C2)",
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0393\\u03b1\\u03bb\\u03bb\\u03b9\\u03ba\\u03ac (\\u0393\\u03b1\\u03bb\\u03bb\\u03af\\u03b1)",
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u039a\\u03b1\\u03c4\\u03b1\\u03bb\\u03b1\\u03bd\\u03b9\\u03ba\\u03ac (\\u0399\\u03c3\\u03c0\\u03b1\\u03bd\\u03af\\u03b1)",
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0395\\u03bb\\u03bb\\u03b7\\u03bd\\u03b9\\u03ba\\u03ac (\\u0395\\u03bb\\u03bb\\u03ac\\u03b4\\u03b1)",
10559d709d503bab6e2b61931737e662dd293b40578ccornelius            "\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03b9\\u03ba\\u03ac (\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03af\\u03b1, NY)",
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "\\u0399\\u03c4\\u03b1\\u03bb\\u03b9\\u03ba\\u03ac",
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "",
10859d709d503bab6e2b61931737e662dd293b40578ccornelius            "\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC (\\u0391\\u03c0\\u03bb\\u03bf\\u03c0\\u03bf\\u03b9\\u03b7\\u03bc\\u03ad\\u03bd\\u03bf, \\u039A\\u03AF\\u03BD\\u03B1)"
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        },
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display langage (<root>)
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "English",  "French",   "Catalan", "Greek",    "Norwegian",    "Italian",  "xx", "" },
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display script (<root>)
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "",     "",     "",     "",     "",   "",     "", ""},
115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display country (<root>)
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "United States",    "France",   "Spain",  "Greece",   "Norway",   "",     "YY", "" },
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display variant (<root>)
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "",     "",     "",     "",     "Nynorsk",   "",     "", ""},
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // display name (<root>)
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        //{   "English (United States)", "French (France)", "Catalan (Spain)", "Greek (Greece)", "Norwegian (Norway,Nynorsk)", "Italian", "xx (YY)" },
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {   "English (United States)", "French (France)", "Catalan (Spain)", "Greek (Greece)", "Norwegian (Norway,NY)", "Italian", "xx (YY)", "" }
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru Usage:
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(    Test (should be TRUE)  )
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru   Example:
130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru       test_assert(i==3);
131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru   the macro is ugly but makes the tests pretty.
133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define test_assert(test) \
136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    { \
137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(!(test)) \
138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: " #test " was not true. In " __FILE__ " on line %d", __LINE__ ); \
139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else \
140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            logln("PASS: asserted " #test); \
141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru Usage:
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert_print(    Test (should be TRUE),  printable  )
146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru   Example:
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru       test_assert(i==3, toString(i));
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru   the macro is ugly but makes the tests pretty.
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define test_assert_print(test,print) \
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    { \
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(!(test)) \
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: " #test " was not true. " + UnicodeString(print) ); \
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else \
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            logln("PASS: asserted " #test "-> " + UnicodeString(print)); \
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define test_dumpLocale(l) { logln(#l " = " + UnicodeString(l.getName(), "")); }
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::LocaleTest()
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru: dataTable(NULL)
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    setUpDataTable();
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::~LocaleTest()
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (dataTable != 0) {
173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (int32_t i = 0; i < 33; i++) {
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            delete []dataTable[i];
175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        delete []dataTable;
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        dataTable = 0;
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    switch (index) {
184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(0, TestBasicGetters);
185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(1, TestSimpleResourceInfo);
186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(2, TestDisplayNames);
187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(3, TestSimpleObjectStuff);
188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(4, TestPOSIXParsing);
189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(5, TestGetAvailableLocales);
190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(6, TestDataDirectory);
191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(7, TestISO3Fallback);
192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(8, TestGetLangsAndCountries);
193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(9, TestSimpleDisplayNames);
194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(10, TestUninstalledISO3Names);
195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(11, TestAtypicalLocales);
196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(12, TestThaiCurrencyFormat);
198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(13, TestEuroSupport);
199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(14, TestToString);
201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(15, Test4139940);
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(16, Test4143951);
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(17, Test4147315);
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(18, Test4147317);
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(19, Test4147552);
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(20, TestVariantParsing);
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(21, Test4105828);
211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(22, TestSetIsBogus);
213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(23, TestParallelAPIValues);
214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(24, TestKeywordVariants);
215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        TESTCASE(25, TestKeywordVariantParsing);
21650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        TESTCASE(26, TestSetKeywordValue);
21750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        TESTCASE(27, TestGetBaseName);
21850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_FILE_IO
21950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        TESTCASE(28, TestGetLocale);
22050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif
22150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        TESTCASE(29, TestVariantWithOutCountry);
22250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        TESTCASE(30, TestCanonicalization);
22350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        TESTCASE(31, TestCurrencyByDate);
22450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho	TESTCASE(32, TestGetVariantWithKeywords);
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // keep the last index in sync with the condition in default:
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        default:
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (index <= 28) { // keep this in sync with the last index!
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                name = "(test omitted by !UCONFIG_NO_FORMATTING)";
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                name = "";
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            break; //needed to end loop
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestBasicGetters() {
239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString   temp;
240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i;
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i <= MAX_LOCALES; i++) {
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale testLocale("");
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (rawData[SCRIPT][i] && rawData[SCRIPT][i][0] != 0) {
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            testLocale = Locale(rawData[LANG][i], rawData[SCRIPT][i], rawData[CTRY][i], rawData[VAR][i]);
246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else {
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            testLocale = Locale(rawData[LANG][i], rawData[CTRY][i], rawData[VAR][i]);
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("Testing " + (UnicodeString)testLocale.getName() + "...");
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getLanguage()) != (dataTable[LANG][i]))
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("  Language code mismatch: " + temp + " versus "
254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[LANG][i]);
255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getScript()) != (dataTable[SCRIPT][i]))
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("  Script code mismatch: " + temp + " versus "
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[SCRIPT][i]);
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getCountry()) != (dataTable[CTRY][i]))
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("  Country code mismatch: " + temp + " versus "
260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[CTRY][i]);
261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getVariant()) != (dataTable[VAR][i]))
262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("  Variant code mismatch: " + temp + " versus "
263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[VAR][i]);
264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getName()) != (dataTable[NAME][i]))
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("  Locale name mismatch: " + temp + " versus "
266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[NAME][i]);
267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("Same thing without variant codes...");
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i <= MAX_LOCALES; i++) {
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale testLocale("");
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (rawData[SCRIPT][i] && rawData[SCRIPT][i][0] != 0) {
273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            testLocale = Locale(rawData[LANG][i], rawData[SCRIPT][i], rawData[CTRY][i]);
274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else {
276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            testLocale = Locale(rawData[LANG][i], rawData[CTRY][i]);
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("Testing " + (temp=testLocale.getName()) + "...");
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getLanguage()) != (dataTable[LANG][i]))
281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Language code mismatch: " + temp + " versus "
282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[LANG][i]);
283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getScript()) != (dataTable[SCRIPT][i]))
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Script code mismatch: " + temp + " versus "
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[SCRIPT][i]);
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getCountry()) != (dataTable[CTRY][i]))
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Country code mismatch: " + temp + " versus "
288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + dataTable[CTRY][i]);
289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testLocale.getVariant()[0] != 0)
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Variant code mismatch: something versus \"\"");
291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("Testing long language names and getters");
294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test8 = Locale::createFromName("x-klingon-latn-zx.utf32be@special");
295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    temp = test8.getLanguage();
297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (temp != UnicodeString("x-klingon") )
298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Language code mismatch: " + temp + "  versus \"x-klingon\"");
299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    temp = test8.getScript();
301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (temp != UnicodeString("Latn") )
302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Script code mismatch: " + temp + "  versus \"Latn\"");
303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    temp = test8.getCountry();
305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (temp != UnicodeString("ZX") )
306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Country code mismatch: " + temp + "  versus \"ZX\"");
307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    temp = test8.getVariant();
309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //if (temp != UnicodeString("SPECIAL") )
310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //    errln("Variant code mismatch: " + temp + "  versus \"SPECIAL\"");
311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // As of 3.0, the "@special" will *not* be parsed by uloc_getName()
312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (temp != UnicodeString("") )
313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Variant code mismatch: " + temp + "  versus \"\"");
314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (Locale::getDefault() != Locale::createFromName(NULL))
316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Locale::getDefault() == Locale::createFromName(NULL)");
317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /*----------*/
319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // NOTE: There used to be a special test for locale names that had language or
320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // country codes that were longer than two letters.  The new version of Locale
321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // doesn't support anything that isn't an officially recognized language or
322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // country code, so we no longer support this feature.
323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale bogusLang("THISISABOGUSLANGUAGE"); // Jitterbug 2864: language code too long
325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(!bogusLang.isBogus()) {
326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Locale(\"THISISABOGUSLANGUAGE\").isBogus()==FALSE");
327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    bogusLang=Locale("eo");
330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( bogusLang.isBogus() ||
331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcmp(bogusLang.getLanguage(), "eo")!=0 ||
332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        *bogusLang.getCountry()!=0 ||
333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        *bogusLang.getVariant()!=0 ||
334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcmp(bogusLang.getName(), "eo")!=0
335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ) {
336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("assignment to bogus Locale does not unbogus it or sets bad data");
337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale a("eo_DE@currency=DEM");
340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale *pb=a.clone();
341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(pb==&a || *pb!=a) {
342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Locale.clone() failed");
343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete pb;
345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestParallelAPIValues() {
348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("Test synchronization between C and C++ API");
349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getChinese().getName(), ULOC_CHINESE) != 0) {
350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_CHINESE Locale");
351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getEnglish().getName(), ULOC_ENGLISH) != 0) {
353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_ENGLISH Locale");
354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getFrench().getName(), ULOC_FRENCH) != 0) {
356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_FRENCH Locale");
357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getGerman().getName(), ULOC_GERMAN) != 0) {
359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_GERMAN Locale");
360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getItalian().getName(), ULOC_ITALIAN) != 0) {
362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_ITALIAN Locale");
363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getJapanese().getName(), ULOC_JAPANESE) != 0) {
365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_JAPANESE Locale");
366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getKorean().getName(), ULOC_KOREAN) != 0) {
368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_KOREAN Locale");
369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getSimplifiedChinese().getName(), ULOC_SIMPLIFIED_CHINESE) != 0) {
371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_SIMPLIFIED_CHINESE Locale");
372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getTraditionalChinese().getName(), ULOC_TRADITIONAL_CHINESE) != 0) {
374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_TRADITIONAL_CHINESE Locale");
375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getCanada().getName(), ULOC_CANADA) != 0) {
379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_CANADA Locale");
380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getCanadaFrench().getName(), ULOC_CANADA_FRENCH) != 0) {
382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_CANADA_FRENCH Locale");
383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getChina().getName(), ULOC_CHINA) != 0) {
385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_CHINA Locale");
386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getPRC().getName(), ULOC_PRC) != 0) {
388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_PRC Locale");
389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getFrance().getName(), ULOC_FRANCE) != 0) {
391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_FRANCE Locale");
392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getGermany().getName(), ULOC_GERMANY) != 0) {
394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_GERMANY Locale");
395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getItaly().getName(), ULOC_ITALY) != 0) {
397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_ITALY Locale");
398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getJapan().getName(), ULOC_JAPAN) != 0) {
400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_JAPAN Locale");
401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getKorea().getName(), ULOC_KOREA) != 0) {
403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_KOREA Locale");
404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getTaiwan().getName(), ULOC_TAIWAN) != 0) {
406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_TAIWAN Locale");
407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getUK().getName(), ULOC_UK) != 0) {
409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_UK Locale");
410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (strcmp(Locale::getUS().getName(), ULOC_US) != 0) {
412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Differences for ULOC_US Locale");
413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestSimpleResourceInfo() {
418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString   temp;
419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char            temp2[20];
420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode err = U_ZERO_ERROR;
421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i = 0;
422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i <= MAX_LOCALES; i++) {
424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale testLocale(rawData[LANG][i], rawData[CTRY][i], rawData[VAR][i]);
425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("Testing " + (temp=testLocale.getName()) + "...");
426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getISO3Language()) != (dataTable[LANG3][i]))
428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("  ISO-3 language code mismatch: " + temp
429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                + " versus " + dataTable[LANG3][i]);
430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (temp=testLocale.getISO3Country()) != (dataTable[CTRY3][i]))
431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("  ISO-3 country code mismatch: " + temp
432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                + " versus " + dataTable[CTRY3][i]);
433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        sprintf(temp2, "%x", (int)testLocale.getLCID());
435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (UnicodeString(temp2) != dataTable[LCID][i])
436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln((UnicodeString)"  LCID mismatch: " + temp2 + " versus "
437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                + dataTable[LCID][i]);
438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(U_FAILURE(err))
440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln((UnicodeString)"Some error on number " + i + u_errorName(err));
442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        err = U_ZERO_ERROR;
444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale locale("en");
447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(strcmp(locale.getName(), "en") != 0||
448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcmp(locale.getLanguage(), "en") != 0) {
449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("construction of Locale(en) failed\n");
450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /*-----*/
452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Jitterbug 2439 -- markus 20030425
457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The lookup of display names must not fall back through the default
459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * locale because that yields useless results.
460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestDisplayNames()
463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  english("en", "US");
465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  french("fr", "FR");
466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  croatian("ca", "ES");
467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  greek("el", "GR");
468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("  In locale = en_US...");
470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    doTestDisplayNames(english, DLANG_EN);
471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("  In locale = fr_FR...");
472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    doTestDisplayNames(french, DLANG_FR);
473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("  In locale = ca_ES...");
474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    doTestDisplayNames(croatian, DLANG_CA);
475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("  In locale = el_GR...");
476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    doTestDisplayNames(greek, DLANG_EL);
477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString s;
479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    DecimalFormatSymbols symb(status);
483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* Check to see if ICU supports this locale */
484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (symb.getLocale(ULOC_VALID_LOCALE, status) != Locale("root")) {
485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* test that the default locale has a display name for its own language */
48627f654740f2a26ad62a5c155af9199af9e69b889claireho        /* Currently, there is no language information in the "tl" data file so this test will fail if default locale is "tl" */
48727f654740f2a26ad62a5c155af9199af9e69b889claireho        if (uprv_strcmp(Locale().getLanguage(), "tl") != 0) {
48827f654740f2a26ad62a5c155af9199af9e69b889claireho            Locale().getDisplayLanguage(Locale(), s);
48927f654740f2a26ad62a5c155af9199af9e69b889claireho            if(s.length()<=3 && s.charAt(0)<=0x7f) {
49027f654740f2a26ad62a5c155af9199af9e69b889claireho                /* check <=3 to reject getting the language code as a display name */
49127f654740f2a26ad62a5c155af9199af9e69b889claireho                dataerrln("unable to get a display string for the language of the default locale: " + s);
49227f654740f2a26ad62a5c155af9199af9e69b889claireho            }
493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
49427f654740f2a26ad62a5c155af9199af9e69b889claireho            /*
49527f654740f2a26ad62a5c155af9199af9e69b889claireho             * API coverage improvements: call
49627f654740f2a26ad62a5c155af9199af9e69b889claireho             * Locale::getDisplayLanguage(UnicodeString &) and
49727f654740f2a26ad62a5c155af9199af9e69b889claireho             * Locale::getDisplayCountry(UnicodeString &)
49827f654740f2a26ad62a5c155af9199af9e69b889claireho             */
49927f654740f2a26ad62a5c155af9199af9e69b889claireho            s.remove();
50027f654740f2a26ad62a5c155af9199af9e69b889claireho            Locale().getDisplayLanguage(s);
50127f654740f2a26ad62a5c155af9199af9e69b889claireho            if(s.length()<=3 && s.charAt(0)<=0x7f) {
50227f654740f2a26ad62a5c155af9199af9e69b889claireho                dataerrln("unable to get a display string for the language of the default locale [2]: " + s);
50327f654740f2a26ad62a5c155af9199af9e69b889claireho            }
504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("Default locale %s is unsupported by ICU\n", Locale().getName());
508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    s.remove();
510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    french.getDisplayCountry(s);
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(s.isEmpty()) {
514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("unable to get any default-locale display string for the country of fr_FR\n");
515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    s.remove();
517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale("zh", "Hant").getDisplayScript(s);
518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(s.isEmpty()) {
519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("unable to get any default-locale display string for the country of zh_Hant\n");
520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestSimpleObjectStuff() {
524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test1("aa", "AA");
525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test2("aa", "AA");
526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test3(test1);
527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test4("zz", "ZZ");
528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test5("aa", "AA", "");
529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test6("aa", "AA", "ANTARES");
530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test7("aa", "AA", "JUPITER");
531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test8 = Locale::createFromName("aa-aa-jupiTER"); // was "aa-aa.utf8@jupiter" but in 3.0 getName won't normalize that
532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // now list them all for debugging usage.
534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test1);
535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test2);
536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test3);
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test4);
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test5);
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test6);
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test7);
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test8);
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Make sure things compare to themselves!
544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test1 == test1);
545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test2 == test2);
546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test3 == test3);
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test4 == test4);
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test5 == test5);
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 == test6);
550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test7 == test7);
551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test8 == test8);
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // make sure things are not equal to themselves.
554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test1 != test1));
555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test2 != test2));
556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test3 != test3));
557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test4 != test4));
558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test5 != test5));
559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test6 != test6));
560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test7 != test7));
561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test8 != test8));
562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // make sure things that are equal to each other don't show up as unequal.
564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test1 != test2));
565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test2 != test1));
566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test1 != test3));
567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test2 != test3));
568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test5 == test1);
569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 != test2);
570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 != test5);
571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 != test7);
573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // test for things that shouldn't compare equal.
575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test1 == test4));
576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test2 == test4));
577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test3 == test4));
578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test7 == test8);
580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // test for hash codes to be the same.
582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t hash1 = test1.hashCode();
583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t hash2 = test2.hashCode();
584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t hash3 = test3.hashCode();
585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(hash1 == hash2);
587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(hash1 == hash3);
588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(hash2 == hash3);
589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // test that the assignment operator works.
591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test4 = test1;
592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("test4=test1;");
593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test4);
594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test4 == test4);
595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test1 != test4));
597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test2 != test4));
598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(!(test3 != test4));
599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test1 == test4);
600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test4 == test1);
601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // test assignments with a variant
603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("test7 = test6");
604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test7 = test6;
605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test7);
606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test7 == test7);
607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test7 == test6);
608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test7 != test5);
609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("test6 = test1");
611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test6=test1;
612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test6);
613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 != test7);
614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 == test1);
615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 == test6);
616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// A class which exposes constructors that are implemented in terms of the POSIX parsing code.
619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass POSIXLocale : public Locale
620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic:
622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    POSIXLocale(const UnicodeString& l)
623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        :Locale()
624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      char *ch;
626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      ch = new char[l.length() + 1];
627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      ch[l.extract(0, 0x7fffffff, ch, "")] = 0;
628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      setFromPOSIXID(ch);
629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      delete [] ch;
630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    POSIXLocale(const char *l)
632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        :Locale()
633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        setFromPOSIXID(l);
635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestPOSIXParsing()
639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    POSIXLocale  test1("ab_AB");
641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    POSIXLocale  test2(UnicodeString("ab_AB"));
642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test3("ab","AB");
643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    POSIXLocale test4("ab_AB_Antares");
645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    POSIXLocale test5(UnicodeString("ab_AB_Antares"));
646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test6("ab", "AB", "Antares");
647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test1);
649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test2);
650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test3);
651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test4);
652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test5);
653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_dumpLocale(test6);
654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test1 == test1);
656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test1 == test2);
658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test2 == test3);
659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test3 == test1);
660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test4 == test5);
662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test5 == test6);
663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test6 == test4);
664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test1 != test4);
666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test5 != test3);
667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(test5 != test2);
668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t hash1 = test1.hashCode();
670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t hash2 = test2.hashCode();
671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t hash3 = test3.hashCode();
672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(hash1 == hash2);
674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(hash2 == hash3);
675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test_assert(hash3 == hash1);
676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestGetAvailableLocales()
679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t locCount = 0;
681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const Locale* locList = Locale::getAvailableLocales(locCount);
682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (locCount == 0)
6846d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("getAvailableLocales() returned an empty list!");
685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(UnicodeString("Number of locales returned = ") + locCount);
687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString temp;
688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for(int32_t i = 0; i < locCount; ++i)
689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            logln(locList[i].getName());
690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // I have no idea how to test this function...
692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// This test isn't applicable anymore - getISO3Language is
695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// independent of the data directory
696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestDataDirectory()
697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char            oldDirectory[80];
700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char*     temp;
701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode       err = U_ZERO_ERROR;
702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString   testValue;
703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    temp = Locale::getDataDirectory();
705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    strcpy(oldDirectory, temp);
706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln(UnicodeString("oldDirectory = ") + oldDirectory);
707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale  test(Locale::US);
709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test.getISO3Language(testValue);
710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("first fetch of language retrieved " + testValue);
711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (testValue != "eng")
712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Initial check of ISO3 language failed: expected \"eng\", got \"" + testValue + "\"");
713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char *path;
716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        path=IntlTest::getTestDirectory();
717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale::setDataDirectory( path );
718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test.getISO3Language(testValue);
721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("second fetch of language retrieved " + testValue);
722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (testValue != "xxx")
723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("setDataDirectory() failed: expected \"xxx\", got \"" + testValue + "\"");
724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale::setDataDirectory(oldDirectory);
726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test.getISO3Language(testValue);
727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("third fetch of language retrieved " + testValue);
728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (testValue != "eng")
729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("get/setDataDirectory() failed: expected \"eng\", got \"" + testValue + "\"");
730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//===========================================================
734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::doTestDisplayNames(Locale& displayLocale, int32_t compareIndex) {
736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString   temp;
737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (int32_t i = 0; i <= MAX_LOCALES; i++) {
739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale testLocale("");
740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (rawData[SCRIPT][i] && rawData[SCRIPT][i][0] != 0) {
741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            testLocale = Locale(rawData[LANG][i], rawData[SCRIPT][i], rawData[CTRY][i], rawData[VAR][i]);
742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else {
744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            testLocale = Locale(rawData[LANG][i], rawData[CTRY][i], rawData[VAR][i]);
745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("  Testing " + (temp=testLocale.getName()) + "...");
747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  testLang;
749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  testScript;
750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  testCtry;
751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  testVar;
752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  testName;
753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testLocale.getDisplayLanguage(displayLocale, testLang);
755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testLocale.getDisplayScript(displayLocale, testScript);
756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testLocale.getDisplayCountry(displayLocale, testCtry);
757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testLocale.getDisplayVariant(displayLocale, testVar);
758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testLocale.getDisplayName(displayLocale, testName);
759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  expectedLang;
761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  expectedScript;
762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  expectedCtry;
763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  expectedVar;
764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString  expectedName;
765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        expectedLang = dataTable[compareIndex][i];
767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (expectedLang.length() == 0)
768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            expectedLang = dataTable[DLANG_EN][i];
769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        expectedScript = dataTable[compareIndex + 1][i];
771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (expectedScript.length() == 0)
772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            expectedScript = dataTable[DSCRIPT_EN][i];
773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        expectedCtry = dataTable[compareIndex + 2][i];
775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (expectedCtry.length() == 0)
776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            expectedCtry = dataTable[DCTRY_EN][i];
777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        expectedVar = dataTable[compareIndex + 3][i];
779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (expectedVar.length() == 0)
780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            expectedVar = dataTable[DVAR_EN][i];
781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        expectedName = dataTable[compareIndex + 4][i];
783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (expectedName.length() == 0)
784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            expectedName = dataTable[DNAME_EN][i];
785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testLang != expectedLang)
7876d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Display language (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testLang + " expected " + expectedLang);
788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testScript != expectedScript)
7896d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Display script (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testScript + " expected " + expectedScript);
790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testCtry != expectedCtry)
7916d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Display country (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testCtry + " expected " + expectedCtry);
792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testVar != expectedVar)
7936d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Display variant (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testVar + " expected " + expectedVar);
794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testName != expectedName)
7956d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Display name (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testName + " expected " + expectedName);
796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//---------------------------------------------------
800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// table of valid data
801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//---------------------------------------------------
802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::setUpDataTable()
806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (dataTable == 0) {
808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        dataTable = new UnicodeString*[33];
809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (int32_t i = 0; i < 33; i++) {
811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            dataTable[i] = new UnicodeString[8];
812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            for (int32_t j = 0; j < 8; j++) {
813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                dataTable[i][j] = CharsToUnicodeString(rawData[i][j]);
814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// ====================
820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4011756 4011380
824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestISO3Fallback()
827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale test("xx", "YY");
829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char * result;
831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    result = test.getISO3Language();
833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Conform to C API usage
835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!result || (result[0] != 0))
837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("getISO3Language() on xx_YY returned " + UnicodeString(result) + " instead of \"\"");
838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    result = test.getISO3Country();
840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!result || (result[0] != 0))
842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("getISO3Country() on xx_YY returned " + UnicodeString(result) + " instead of \"\"");
843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4106155 4118587
847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestGetLangsAndCountries()
850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // It didn't seem right to just do an exhaustive test of everything here, so I check
852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // for the following things:
853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // 1) Does each list have the right total number of entries?
854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // 2) Does each list contain certain language and country codes we think are important
855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //     (the G7 countries, plus a couple others)?
856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // 3) Does each list have every entry formatted correctly? (i.e., two characters,
857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //     all lower case for the language codes, all upper case for the country codes)
858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // 4) Is each list in sorted order?
859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t testCount = 0;
860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char * const * test = Locale::getISOLanguages();
861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char spotCheck1[ ][4] = { "en", "es", "fr", "de", "it",
862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "ja", "ko", "zh", "th", "he",
863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "id", "iu", "ug", "yi", "za" };
864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i;
866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(testCount = 0;test[testCount];testCount++)
868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      ;
869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* TODO: Change this test to be more like the cloctst version? */
87159d709d503bab6e2b61931737e662dd293b40578ccornelius    if (testCount != 560)
87259d709d503bab6e2b61931737e662dd293b40578ccornelius        errln("Expected getISOLanguages() to return 560 languages; it returned %d", testCount);
873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (i = 0; i < 15; i++) {
875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            int32_t j;
876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            for (j = 0; j < testCount; j++)
877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              if (uprv_strcmp(test[j],spotCheck1[i])== 0)
878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    break;
879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (j == testCount || (uprv_strcmp(test[j],spotCheck1[i])!=0))
880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("Couldn't find " + (UnicodeString)spotCheck1[i] + " in language list.");
881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < testCount; i++) {
884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString testee(test[i],"");
885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString lc(test[i],"");
886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testee != lc.toLower())
887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln(lc + " is not all lower case.");
888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ( (testee.length() != 2) && (testee.length() != 3))
889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln(testee + " is not two or three characters long.");
890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (i > 0 && testee.compare(test[i - 1]) <= 0)
891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln(testee + " appears in an out-of-order position in the list.");
892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    test = Locale::getISOCountries();
895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString spotCheck2 [] = { "US", "CA", "GB", "FR", "DE",
896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "IT", "JP", "KR", "CN", "TW",
897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "TH" };
898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t spot2Len = 11;
899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(testCount=0;test[testCount];testCount++)
900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      ;
901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
9028393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    if (testCount != 249){
9038393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius        errln("Expected getISOCountries to return 249 countries; it returned %d", testCount);
904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }else {
905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (i = 0; i < spot2Len; i++) {
906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            int32_t j;
907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            for (j = 0; j < testCount; j++)
908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              {
909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UnicodeString testee(test[j],"");
910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if (testee == spotCheck2[i])
912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    break;
913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              }
914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UnicodeString testee(test[j],"");
915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (j == testCount || testee != spotCheck2[i])
916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("Couldn't find " + spotCheck2[i] + " in country list.");
917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
919b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    for (i = 0; i < testCount; i++) {
920b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        UnicodeString testee(test[i],"");
921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString uc(test[i],"");
922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testee != uc.toUpper())
923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln(testee + " is not all upper case.");
924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (testee.length() != 2)
925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln(testee + " is not two characters long.");
926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (i > 0 && testee.compare(test[i - 1]) <= 0)
927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln(testee + " appears in an out-of-order position in the list.");
928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
929b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
930b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    // This getAvailableLocales and getISO3Language
931b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    {
932b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        int32_t numOfLocales;
933b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        Locale  enLoc ("en");
934b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        const Locale *pLocales = Locale::getAvailableLocales(numOfLocales);
935b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
936b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        for (int i = 0; i < numOfLocales; i++) {
937b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho            const Locale    &loc(pLocales[i]);
938b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho            UnicodeString   name;
939b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho            char        szName[200];
940b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
941b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho            loc.getDisplayName (enLoc, name);
942b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho            name.extract (0, 200, szName, sizeof(szName));
943b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
944b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho            if (strlen(loc.getISO3Language()) == 0) {
945b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                errln("getISO3Language() returned an empty string for: " + name);
946b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho            }
947b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho        }
948b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    }
949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4118587
953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestSimpleDisplayNames()
956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // This test is different from TestDisplayNames because TestDisplayNames checks
958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // fallback behavior, combination of language and country names to form locale
959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // names, and other stuff like that.  This test just checks specific language
960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // and country codes to make sure we have the correct names for them.
961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char languageCodes[] [4] = { "he", "id", "iu", "ug", "yi", "za" };
9628393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    UnicodeString languageNames [] = { "Hebrew", "Indonesian", "Inuktitut", "Uyghur", "Yiddish",
963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                               "Zhuang" };
964b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (int32_t i = 0; i < 6; i++) {
966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString test;
967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale l(languageCodes[i], "", "");
968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        l.getDisplayLanguage(Locale::getUS(), test);
969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (test != languageNames[i])
9706d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Got wrong display name for " + UnicodeString(languageCodes[i]) + ": Expected \"" +
971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  languageNames[i] + "\", got \"" + test + "\".");
972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4118595
977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestUninstalledISO3Names()
980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // This test checks to make sure getISO3Language and getISO3Country work right
982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // even for locales that are not installed.
983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char iso2Languages [][4] = {     "am", "ba", "fy", "mr", "rn",
984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                        "ss", "tw", "zu" };
985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char iso3Languages [][5] = {     "amh", "bak", "fry", "mar", "run",
986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                        "ssw", "twi", "zul" };
987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i;
989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < 8; i++) {
991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UErrorCode err = U_ZERO_ERROR;
992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UnicodeString test;
994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale l(iso2Languages[i], "", "");
995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        test = l.getISO3Language();
996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if((test != iso3Languages[i]) || U_FAILURE(err))
997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Got wrong ISO3 code for " + UnicodeString(iso2Languages[i]) + ": Expected \"" +
998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    iso3Languages[i] + "\", got \"" + test + "\"." + UnicodeString(u_errorName(err)));
999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char iso2Countries [][4] = {     "AF", "BW", "KZ", "MO", "MN",
1002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                        "SB", "TC", "ZW" };
1003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char iso3Countries [][4] = {     "AFG", "BWA", "KAZ", "MAC", "MNG",
1004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                        "SLB", "TCA", "ZWE" };
1005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < 8; i++) {
1007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      UErrorCode err = U_ZERO_ERROR;
1008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale l("", iso2Countries[i], "");
1009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString test(l.getISO3Country(), "");
1010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (test != iso3Countries[i])
1011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Got wrong ISO3 code for " + UnicodeString(iso2Countries[i]) + ": Expected \"" +
1012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    UnicodeString(iso3Countries[i]) + "\", got \"" + test + "\"." + u_errorName(err));
1013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4092475
1018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * I could not reproduce this bug.  I'm pretty convinced it was fixed with the
1019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * big locale-data reorg of 10/28/97.  The lookup logic for language and country
1020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * display names was also changed at that time in that check-in.    --rtg 3/20/98
1021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestAtypicalLocales()
1024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale localesToTest [] = { Locale("de", "CA"),
1026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                  Locale("ja", "ZA"),
1027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                   Locale("ru", "MX"),
1028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                   Locale("en", "FR"),
1029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                   Locale("es", "DE"),
1030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                   Locale("", "HR"),
1031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                   Locale("", "SE"),
1032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                   Locale("", "DO"),
1033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                   Locale("", "BE") };
1034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString englishDisplayNames [] = { "German (Canada)",
1036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Japanese (South Africa)",
1037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Russian (Mexico)",
1038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "English (France)",
1039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Spanish (Germany)",
1040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Croatia",
1041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Sweden",
1042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Dominican Republic",
1043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Belgium" };
1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString frenchDisplayNames []= { "allemand (Canada)",
1045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "japonais (Afrique du Sud)",
1046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "russe (Mexique)",
1047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "anglais (France)",
1048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "espagnol (Allemagne)",
1049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "Croatie",
1050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    CharsToUnicodeString("Su\\u00E8de"),
1051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    CharsToUnicodeString("R\\u00E9publique dominicaine"),
1052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                    "Belgique" };
1053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString spanishDisplayNames [] = {
1054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     CharsToUnicodeString("alem\\u00E1n (Canad\\u00E1)"),
1055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     CharsToUnicodeString("japon\\u00E9s (Sud\\u00E1frica)"),
1056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     CharsToUnicodeString("ruso (M\\u00E9xico)"),
1057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     CharsToUnicodeString("ingl\\u00E9s (Francia)"),
1058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     CharsToUnicodeString("espa\\u00F1ol (Alemania)"),
1059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Croacia",
1060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Suecia",
1061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     CharsToUnicodeString("Rep\\u00FAblica Dominicana"),
1062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     CharsToUnicodeString("B\\u00E9lgica") };
1063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // De-Anglicizing root required the change from
1064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // English display names to ISO Codes - ram 2003/09/26
1065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString invDisplayNames [] = { "German (Canada)",
1066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Japanese (South Africa)",
1067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Russian (Mexico)",
1068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "English (France)",
1069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Spanish (Germany)",
1070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Croatia",
1071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Sweden",
1072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Dominican Republic",
1073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                     "Belgium" };
1074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i;
1076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale saveLocale;
1078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale::setDefault(Locale::getUS(), status);
1079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < 9; ++i) {
1080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString name;
1081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        localesToTest[i].getDisplayName(Locale::getUS(), name);
1082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(name);
1083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (name != englishDisplayNames[i])
1084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
10856d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Lookup in English failed: expected \"" + englishDisplayNames[i]
1086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + "\", got \"" + name + "\"");
1087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            logln("Locale name was-> " + (name=localesToTest[i].getName()));
1088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < 9; i++) {
1092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString name;
1093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        localesToTest[i].getDisplayName(Locale("es", "ES"), name);
1094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(name);
1095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (name != spanishDisplayNames[i])
10966d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Lookup in Spanish failed: expected \"" + spanishDisplayNames[i]
1097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + "\", got \"" + name + "\"");
1098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < 9; i++) {
1101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString name;
1102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        localesToTest[i].getDisplayName(Locale::getFrance(), name);
1103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(name);
1104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (name != frenchDisplayNames[i])
11056d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Lookup in French failed: expected \"" + frenchDisplayNames[i]
1106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + "\", got \"" + name + "\"");
1107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < 9; i++) {
1110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString name;
1111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        localesToTest[i].getDisplayName(Locale("inv", "IN"), name);
1112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(name + " Locale fallback to be, and data fallback to root");
1113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (name != invDisplayNames[i])
11146d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Lookup in INV failed: expected \"" + prettify(invDisplayNames[i])
1115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + "\", got \"" + prettify(name) + "\"");
1116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        localesToTest[i].getDisplayName(Locale("inv", "BD"), name);
1117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(name + " Data fallback to root");
1118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (name != invDisplayNames[i])
11196d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Lookup in INV failed: expected \"" + prettify(invDisplayNames[i])
1120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        + "\", got \"" + prettify(name )+ "\"");
1121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale::setDefault(saveLocale, status);
1123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4135752
1129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This would be better tested by the LocaleDataTest.  Will move it when I
1130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * get the LocaleDataTest working again.
1131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestThaiCurrencyFormat()
1134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    DecimalFormat *thaiCurrency = (DecimalFormat*)NumberFormat::createCurrencyInstance(
1137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    Locale("th", "TH"), status);
1138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar posPrefix = 0x0e3f;
1139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString temp;
1140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(U_FAILURE(status) || !thaiCurrency)
1142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
11436d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("Couldn't get th_TH currency -> " + UnicodeString(u_errorName(status)));
1144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return;
1145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (thaiCurrency->getPositivePrefix(temp) != UnicodeString(&posPrefix, 1, 1))
1147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Thai currency prefix wrong: expected 0x0e3f, got \"" +
1148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        thaiCurrency->getPositivePrefix(temp) + "\"");
1149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (thaiCurrency->getPositiveSuffix(temp) != "")
1150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Thai currency suffix wrong: expected \"\", got \"" +
1151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        thaiCurrency->getPositiveSuffix(temp) + "\"");
1152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete thaiCurrency;
1154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4122371
1158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Confirm that Euro support works.  This test is pretty rudimentary; all it does
1159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is check that any locales with the EURO variant format a number using the
1160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Euro currency symbol.
1161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ASSUME: All locales encode the Euro character "\u20AC".
1163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this is changed to use the single-character Euro symbol, this
1164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * test must be updated.
1165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestEuroSupport()
1169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar euro = 0x20ac;
1171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const UnicodeString EURO_CURRENCY(&euro, 1, 1); // Look for this UnicodeString in formatted Euro currency
1172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char* localeArr[] = {
1173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "ca_ES",
1174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "de_AT",
1175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "de_DE",
1176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "de_LU",
1177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "el_GR",
1178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "en_BE",
1179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "en_IE",
1180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "en_GB_EURO",
1181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "en_US_EURO",
1182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "es_ES",
1183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "eu_ES",
1184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "fi_FI",
1185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "fr_BE",
1186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "fr_FR",
1187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "fr_LU",
1188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "ga_IE",
1189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "gl_ES",
1190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "it_IT",
1191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "nl_BE",
1192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "nl_NL",
1193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            "pt_PT",
1194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            NULL
1195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        };
1196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char** locales = localeArr;
1197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString temp;
1201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (;*locales!=NULL;locales++) {
1203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale loc (*locales);
1204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString temp;
1205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        NumberFormat *nf = NumberFormat::createCurrencyInstance(loc, status);
1206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString pos;
1207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(status)) {
1209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            dataerrln("Error calling NumberFormat::createCurrencyInstance(%s)", *locales);
1210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            continue;
1211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        nf->format(271828.182845, pos);
1214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString neg;
1215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        nf->format(-271828.182845, neg);
1216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (pos.indexOf(EURO_CURRENCY) >= 0 &&
1217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            neg.indexOf(EURO_CURRENCY) >= 0) {
1218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            logln("Ok: " + (temp=loc.getName()) +
1219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                ": " + pos + " / " + neg);
1220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else {
1222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Fail: " + (temp=loc.getName()) +
1223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                " formats without " + EURO_CURRENCY +
1224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                ": " + pos + " / " + neg +
1225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "\n*** THIS FAILURE MAY ONLY MEAN THAT LOCALE DATA HAS CHANGED ***");
1226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        delete nf;
1229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString dollarStr("USD", ""), euroStr("EUR", ""), genericStr((UChar)0x00a4), resultStr;
1232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar tmp[4];
1233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    status = U_ZERO_ERROR;
1234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ucurr_forLocale("en_US", tmp, 4, &status);
1236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    resultStr.setTo(tmp);
1237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (dollarStr != resultStr) {
12386d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "Fail: en_US didn't return USD - %s", u_errorName(status));
1239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ucurr_forLocale("en_US_EURO", tmp, 4, &status);
1241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    resultStr.setTo(tmp);
1242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (euroStr != resultStr) {
12436d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "Fail: en_US_EURO didn't return EUR - %s", u_errorName(status));
1244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ucurr_forLocale("en_GB_EURO", tmp, 4, &status);
1246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    resultStr.setTo(tmp);
1247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (euroStr != resultStr) {
12486d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "Fail: en_GB_EURO didn't return EUR - %s", u_errorName(status));
1249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ucurr_forLocale("en_US_PREEURO", tmp, 4, &status);
1251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    resultStr.setTo(tmp);
1252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (dollarStr != resultStr) {
12536d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "Fail: en_US_PREEURO didn't fallback to en_US - %s", u_errorName(status));
1254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ucurr_forLocale("en_US_Q", tmp, 4, &status);
1256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    resultStr.setTo(tmp);
1257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (dollarStr != resultStr) {
12586d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "Fail: en_US_Q didn't fallback to en_US - %s", u_errorName(status));
1259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t invalidLen = ucurr_forLocale("en_QQ", tmp, 4, &status);
1261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (invalidLen || U_SUCCESS(status)) {
1262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Fail: en_QQ didn't return NULL");
1263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4139504
1270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * toString() doesn't work with language_VARIANT.
1271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestToString() {
1274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale DATA [] = {
1275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale("xx", "", ""),
1276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale("", "YY", ""),
1277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale("", "", "ZZ"),
1278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale("xx", "YY", ""),
1279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale("xx", "", "ZZ"),
1280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale("", "YY", "ZZ"),
1281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale("xx", "YY", "ZZ"),
1282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char DATA_S [][20] = {
1285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        "xx",
1286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        "_YY",
1287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        "__ZZ",
1288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        "xx_YY",
1289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        "xx__ZZ",
1290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        "_YY_ZZ",
1291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        "xx_YY_ZZ",
1292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (int32_t i=0; i < 7; ++i) {
1295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      const char *name;
1296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      name = DATA[i].getName();
1297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      if (strcmp(name, DATA_S[i]) != 0)
1299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
1300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("Fail: Locale.getName(), got:" + UnicodeString(name) + ", expected: " + DATA_S[i]);
1301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else
1303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            logln("Pass: Locale.getName(), got:" + UnicodeString(name) );
1304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4139940
1311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Couldn't reproduce this bug -- probably was fixed earlier.
1312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ORIGINAL BUG REPORT:
1314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * -- basically, hungarian for monday shouldn't have an \u00f4
1315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (o circumflex)in it instead it should be an o with 2 inclined
1316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (right) lines over it..
1317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * You may wonder -- why do all this -- why not just add a line to
1319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * LocaleData?  Well, I could see by inspection that the locale file had the
1320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * right character in it, so I wanted to check the rest of the pipeline -- a
1321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * very remote possibility, but I wanted to be sure.  The other possibility
1322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is that something is wrong with the font mapping subsystem, but we can't
1323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * test that here.
1324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::Test4139940()
1327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale mylocale("hu", "", "");
1329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UDate mydate = date(98,3,13); // A Monday
1330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    SimpleDateFormat df_full("EEEE", mylocale, status);
1332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(U_FAILURE(status)){
133350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        dataerrln(UnicodeString("Could not create SimpleDateFormat object for locale hu. Error: ") + UnicodeString(u_errorName(status)));
1334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return;
1335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString str;
1337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    FieldPosition pos(FieldPosition::DONT_CARE);
1338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    df_full.format(mydate, str, pos);
1339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Make sure that o circumflex (\u00F4) is NOT there, and
1340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // o double acute (\u0151) IS.
1341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar ocf = 0x00f4;
1342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar oda = 0x0151;
1343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (str.indexOf(oda) < 0 || str.indexOf(ocf) >= 0) {
134427f654740f2a26ad62a5c155af9199af9e69b889claireho      /* If the default locale is "th" this test will fail because of the buddhist calendar. */
134527f654740f2a26ad62a5c155af9199af9e69b889claireho      if (strcmp(Locale::getDefault().getLanguage(), "th") != 0) {
134627f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("Fail: Monday in Hungarian is wrong - oda's index is %d and ocf's is %d",
134727f654740f2a26ad62a5c155af9199af9e69b889claireho              str.indexOf(oda), str.indexOf(ocf));
134827f654740f2a26ad62a5c155af9199af9e69b889claireho      } else {
134927f654740f2a26ad62a5c155af9199af9e69b889claireho        logln(UnicodeString("An error is produce in buddhist calendar."));
135027f654740f2a26ad62a5c155af9199af9e69b889claireho      }
1351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      logln(UnicodeString("String is: ") + str );
1352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUDate
1356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::date(int32_t y, int32_t m, int32_t d, int32_t hr, int32_t min, int32_t sec)
1357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar *cal = Calendar::createInstance(status);
1360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (cal == 0)
1361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return 0.0;
1362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    cal->clear();
1363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    cal->set(1900 + y, m, d, hr, min, sec); // Add 1900 to follow java.util.Date protocol
1364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UDate dt = cal->getTime(status);
1365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(status))
1366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return 0.0;
1367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete cal;
1369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return dt;
1370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4143951
1374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Russian first day of week should be Monday. Confirmed.
1375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::Test4143951()
1378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar *cal = Calendar::createInstance(Locale("ru", "", ""), status);
1381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(U_SUCCESS(status)) {
1382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      if (cal->getFirstDayOfWeek(status) != UCAL_MONDAY) {
13836d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru          dataerrln("Fail: First day of week in Russia should be Monday");
1384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      }
1385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete cal;
1387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4147315
1393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * java.util.Locale.getISO3Country() works wrong for non ISO-3166 codes.
1394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Should throw an exception for unknown locales
1395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::Test4147315()
1398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  UnicodeString temp;
1400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Try with codes that are the wrong length but happen to match text
1401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // at a valid offset in the mapping table
14028393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    Locale locale("xxx", "CCC");
1403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *result = locale.getISO3Country();
1405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Change to conform to C api usage
1407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if((result==NULL)||(result[0] != 0))
1408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      errln("ERROR: getISO3Country() returns: " + UnicodeString(result,"") +
1409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                " for locale '" + (temp=locale.getName()) + "' rather than exception" );
1410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4147317
1414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * java.util.Locale.getISO3Language() works wrong for non ISO-3166 codes.
1415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Should throw an exception for unknown locales
1416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::Test4147317()
1419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString temp;
1421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Try with codes that are the wrong length but happen to match text
1422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // at a valid offset in the mapping table
14238393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    Locale locale("xxx", "CCC");
1424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *result = locale.getISO3Language();
1426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Change to conform to C api usage
1428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if((result==NULL)||(result[0] != 0))
1429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      errln("ERROR: getISO3Language() returns: " + UnicodeString(result,"") +
1430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                " for locale '" + (temp=locale.getName()) + "' rather than exception" );
1431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
1434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4147552
1435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::Test4147552()
1438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale locales [] = {     Locale("no", "NO"),
1440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            Locale("no", "NO", "B"),
1441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             Locale("no", "NO", "NY")
1442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString edn("Norwegian (Norway, B)");
1445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString englishDisplayNames [] = {
1446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                "Norwegian (Norway)",
1447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                 edn,
1448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                 // "Norwegian (Norway,B)",
1449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                 //"Norwegian (Norway,NY)"
1450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                 "Norwegian (Norway, NY)"
1451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString ndn("norsk (Norge, B");
1453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString norwegianDisplayNames [] = {
1454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                "norsk (Norge)",
1455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                "norsk (Norge, B)",
1456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                //ndn,
1457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                 "norsk (Noreg, NY)"
1458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                 //"Norsk (Noreg, Nynorsk)"
1459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale saveLocale;
1463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale::setDefault(Locale::getEnglish(), status);
1464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (int32_t i = 0; i < 3; ++i) {
1465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale loc = locales[i];
1466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString temp;
1467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (loc.getDisplayName(temp) != englishDisplayNames[i])
14686d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru           dataerrln("English display-name mismatch: expected " +
1469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   englishDisplayNames[i] + ", got " + loc.getDisplayName(temp));
1470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (loc.getDisplayName(loc, temp) != norwegianDisplayNames[i])
14716d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Norwegian display-name mismatch: expected " +
1472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   norwegianDisplayNames[i] + ", got " +
1473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   loc.getDisplayName(loc, temp));
1474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale::setDefault(saveLocale, status);
1476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestVariantParsing()
1480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale en_US_custom("en", "US", "De Anza_Cupertino_California_United States_Earth");
1482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString dispName("English (United States, DE ANZA_CUPERTINO_CALIFORNIA_UNITED STATES_EARTH)");
1484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString dispVar("DE ANZA_CUPERTINO_CALIFORNIA_UNITED STATES_EARTH");
1485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString got;
1487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    en_US_custom.getDisplayVariant(Locale::getUS(), got);
1489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(got != dispVar) {
1490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("FAIL: getDisplayVariant()");
1491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Wanted: " + dispVar);
1492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Got   : " + got);
1493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    en_US_custom.getDisplayName(Locale::getUS(), got);
1496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(got != dispName) {
14976d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("FAIL: getDisplayName()");
14986d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("Wanted: " + dispName);
14996d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("Got   : " + got);
1500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale shortVariant("fr", "FR", "foo");
1503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    shortVariant.getDisplayVariant(got);
1504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(got != "FOO") {
1506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("FAIL: getDisplayVariant()");
1507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Wanted: foo");
1508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Got   : " + got);
1509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale bogusVariant("fr", "FR", "_foo");
1512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    bogusVariant.getDisplayVariant(got);
1513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(got != "FOO") {
1515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("FAIL: getDisplayVariant()");
1516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Wanted: foo");
1517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Got   : " + got);
1518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale bogusVariant2("fr", "FR", "foo_");
1521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    bogusVariant2.getDisplayVariant(got);
1522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(got != "FOO") {
1524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("FAIL: getDisplayVariant()");
1525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Wanted: foo");
1526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Got   : " + got);
1527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale bogusVariant3("fr", "FR", "_foo_");
1530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    bogusVariant3.getDisplayVariant(got);
1531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(got != "FOO") {
1533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("FAIL: getDisplayVariant()");
1534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Wanted: foo");
1535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("Got   : " + got);
1536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @bug 4105828
1543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Currency symbol in zh is wrong.  We will test this at the NumberFormat
1544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * end to test the whole pipe.
1545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::Test4105828()
1548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale LOC [] = { Locale::getChinese(),  Locale("zh", "CN", ""),
1550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     Locale("zh", "TW", ""), Locale("zh", "HK", "") };
1551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (int32_t i = 0; i < 4; ++i) {
1553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        NumberFormat *fmt = NumberFormat::createPercentInstance(LOC[i], status);
1554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(U_FAILURE(status)) {
15556d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("Couldn't create NumberFormat - %s", u_errorName(status));
1556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
1557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString result;
1559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        FieldPosition pos(0);
1560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fmt->format((int32_t)1, result, pos);
1561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString temp;
1562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(result != "100%") {
1563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln(UnicodeString("Percent for ") + LOC[i].getDisplayName(temp) + " should be 100%, got " + result);
1564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        delete fmt;
1566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Tests setBogus and isBogus APIs for Locale
1572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Jitterbug 1735
1573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestSetIsBogus() {
1575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale l("en_US");
1576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    l.setToBogus();
1577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(l.isBogus() != TRUE) {
1578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("After setting bogus, didn't return TRUE");
1579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    l = "en_US"; // This should reset bogus
1581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(l.isBogus() != FALSE) {
1582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("After resetting bogus, didn't return FALSE");
1583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestKeywordVariants(void) {
1589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const struct {
1590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *localeID;
1591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *expectedLocaleID;
1592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        //const char *expectedLocaleIDNoKeywords;
1593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        //const char *expectedCanonicalID;
1594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *expectedKeywords[10];
1595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        int32_t numKeywords;
1596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UErrorCode expectedStatus;
1597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } testCases[] = {
1598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
1599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "de_DE@  currency = euro; C o ll A t i o n   = Phonebook   ; C alen dar = buddhist   ",
1600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "de_DE@calendar=buddhist;collation=Phonebook;currency=euro",
1601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            //"de_DE",
1602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            //"de_DE@calendar=buddhist;collation=Phonebook;currency=euro",
1603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            {"calendar", "collation", "currency"},
1604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            3,
1605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            U_ZERO_ERROR
1606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        },
1607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
1608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "de_DE@euro",
1609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "de_DE@euro",
1610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            //"de_DE",
1611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            //"de_DE@currency=EUR",
1612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            {"","","","","","",""},
1613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            0,
1614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            U_INVALID_FORMAT_ERROR /* must have '=' after '@' */
1615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i = 0, j = 0;
1620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *result = NULL;
1621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    StringEnumeration *keywords;
1622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t keyCount = 0;
1623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *keyword = NULL;
1624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const UnicodeString *keywordString;
1625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t keywordLen = 0;
1626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(i = 0; i < (int32_t)(sizeof(testCases)/sizeof(testCases[0])); i++) {
1628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        status = U_ZERO_ERROR;
1629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale l(testCases[i].localeID);
1630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        keywords = l.createKeywords(status);
1631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(status != testCases[i].expectedStatus) {
1633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            err("Expected to get status %s. Got %s instead\n",
1634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                u_errorName(testCases[i].expectedStatus), u_errorName(status));
1635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        status = U_ZERO_ERROR;
1637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(keywords) {
1638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if((keyCount = keywords->count(status)) != testCases[i].numKeywords) {
1639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                err("Expected to get %i keywords, got %i\n", testCases[i].numKeywords, keyCount);
1640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if(keyCount) {
1642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                for(j = 0;;) {
1643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    if((j&1)==0) {
1644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        if((keyword = keywords->next(&keywordLen, status)) == NULL) {
1645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            break;
1646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        }
1647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        if(strcmp(keyword, testCases[i].expectedKeywords[j]) != 0) {
1648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            err("Expected to get keyword value %s, got %s\n", testCases[i].expectedKeywords[j], keyword);
1649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        }
1650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    } else {
1651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        if((keywordString = keywords->snext(status)) == NULL) {
1652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            break;
1653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        }
1654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        if(*keywordString != UnicodeString(testCases[i].expectedKeywords[j], "")) {
1655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            err("Expected to get keyword UnicodeString %s, got %s\n", testCases[i].expectedKeywords[j], keyword);
1656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        }
1657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    }
1658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    j++;
1659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    if(j == keyCount / 2) {
1661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        // replace keywords with a clone of itself
1662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        StringEnumeration *k2 = keywords->clone();
1663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        if(k2 == NULL || keyCount != k2->count(status)) {
1664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            errln("KeywordEnumeration.clone() failed");
1665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        } else {
1666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            delete keywords;
1667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            keywords = k2;
1668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        }
1669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    }
1670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
1671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                keywords->reset(status); // Make sure that reset works.
1672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                for(j = 0;;) {
1673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    if((keyword = keywords->next(&keywordLen, status)) == NULL) {
1674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        break;
1675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    }
1676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    if(strcmp(keyword, testCases[i].expectedKeywords[j]) != 0) {
1677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        err("Expected to get keyword value %s, got %s\n", testCases[i].expectedKeywords[j], keyword);
1678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    }
1679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    j++;
1680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
1681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            delete keywords;
1683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        result = l.getName();
1685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(uprv_strcmp(testCases[i].expectedLocaleID, result) != 0) {
1686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            err("Expected to get \"%s\" from \"%s\". Got \"%s\" instead\n",
1687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                testCases[i].expectedLocaleID, testCases[i].localeID, result);
1688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
1695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestKeywordVariantParsing(void) {
1696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const struct {
1697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *localeID;
1698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *keyword;
1699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *expectedValue;
1700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } testCases[] = {
1701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_DE@  C o ll A t i o n   = Phonebook   ", "collation", "Phonebook" },
1702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_DE", "collation", ""},
1703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_DE@collation= PHONEBOOK", "collation", "PHONEBOOK" },
1704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_DE@ currency = euro   ; CoLLaTion   = PHONEBOOk   ", "collation", "PHONEBOOk" },
1705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
1708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i = 0;
1710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t resultLen = 0;
1711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[256];
1712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(i = 0; i < (int32_t)(sizeof(testCases)/sizeof(testCases[0])); i++) {
1714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        *buffer = 0;
1715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale l(testCases[i].localeID);
1716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        resultLen = l.getKeywordValue(testCases[i].keyword, buffer, 256, status);
171759d709d503bab6e2b61931737e662dd293b40578ccornelius        (void)resultLen;  // Suppress unused variable warning.
1718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(uprv_strcmp(testCases[i].expectedValue, buffer) != 0) {
1719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            err("Expected to extract \"%s\" from \"%s\" for keyword \"%s\". Got \"%s\" instead\n",
1720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                testCases[i].expectedValue, testCases[i].localeID, testCases[i].keyword, buffer);
1721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid
172650294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoLocaleTest::TestSetKeywordValue(void) {
172750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    static const struct {
172850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        const char *keyword;
172950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        const char *value;
173050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    } testCases[] = {
173150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        { "collation", "phonebook" },
173250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        { "currency", "euro" },
173350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        { "calendar", "buddhist" }
173450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    };
173550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
173650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    UErrorCode status = U_ZERO_ERROR;
173750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
173850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int32_t i = 0;
173950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int32_t resultLen = 0;
174050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    char buffer[256];
174150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
174250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    Locale l(Locale::getGerman());
174350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
174450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    for(i = 0; i < (int32_t)(sizeof(testCases)/sizeof(testCases[0])); i++) {
174550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        l.setKeywordValue(testCases[i].keyword, testCases[i].value, status);
174650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        if(U_FAILURE(status)) {
174750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            err("FAIL: Locale::setKeywordValue failed - %s\n", u_errorName(status));
174850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        }
174950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
175050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        *buffer = 0;
175150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        resultLen = l.getKeywordValue(testCases[i].keyword, buffer, 256, status);
175259d709d503bab6e2b61931737e662dd293b40578ccornelius        (void)resultLen;  // Suppress unused variable warning.
175350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        if(uprv_strcmp(testCases[i].value, buffer) != 0) {
175450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            err("Expected to extract \"%s\" for keyword \"%s\". Got \"%s\" instead\n",
175550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                testCases[i].value, testCases[i].keyword, buffer);
175650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        }
175750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    }
175850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho}
175950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
176050294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehovoid
1761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruLocaleTest::TestGetBaseName(void) {
1762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const struct {
1763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *localeID;
1764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *baseName;
1765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } testCases[] = {
1766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_DE@  C o ll A t i o n   = Phonebook   ", "de_DE" },
1767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de@currency = euro; CoLLaTion   = PHONEBOOk", "de" },
1768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "ja@calendar = buddhist", "ja" }
1769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
1770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i = 0;
1772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(i = 0; i < (int32_t)(sizeof(testCases)/sizeof(testCases[0])); i++) {
1774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        Locale loc(testCases[i].localeID);
1775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(strcmp(testCases[i].baseName, loc.getBaseName())) {
1776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("For locale \"%s\" expected baseName \"%s\", but got \"%s\"",
1777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                testCases[i].localeID, testCases[i].baseName, loc.getBaseName());
1778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
1779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two locale IDs.  If they are equal, return 0.  If `string'
1785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starts with `prefix' plus an additional element, that is, string ==
1786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * prefix + '_' + x, then return 1.  Otherwise return a value < 0.
1787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic UBool _loccmp(const char* string, const char* prefix) {
1789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t slen = (int32_t)strlen(string),
1790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            plen = (int32_t)strlen(prefix);
1791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t c = uprv_strncmp(string, prefix, plen);
1792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* 'root' is "less than" everything */
1793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (uprv_strcmp(prefix, "root") == 0) {
1794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return (uprv_strcmp(string, "root") == 0) ? 0 : 1;
1795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (c) return -1; /* mismatch */
1797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (slen == plen) return 0;
1798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (string[plen] == '_') return 1;
1799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return -2; /* false match, e.g. "en_USX" cmp "en_US" */
1800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Check the relationship between requested locales, and report problems.
1804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The caller specifies the expected relationships between requested
1805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and valid (expReqValid) and between valid and actual (expValidActual).
1806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Possible values are:
1807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * "gt" strictly greater than, e.g., en_US > en
1808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * "ge" greater or equal,      e.g., en >= en
1809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * "eq" equal,                 e.g., en == en
1810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::_checklocs(const char* label,
1812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            const char* req,
1813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            const Locale& validLoc,
1814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            const Locale& actualLoc,
1815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            const char* expReqValid,
1816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            const char* expValidActual) {
1817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char* valid = validLoc.getName();
1818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char* actual = actualLoc.getName();
1819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t reqValid = _loccmp(req, valid);
1820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t validActual = _loccmp(valid, actual);
1821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (((0 == uprv_strcmp(expReqValid, "gt") && reqValid > 0) ||
1822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         (0 == uprv_strcmp(expReqValid, "ge") && reqValid >= 0) ||
1823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         (0 == uprv_strcmp(expReqValid, "eq") && reqValid == 0)) &&
1824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ((0 == uprv_strcmp(expValidActual, "gt") && validActual > 0) ||
1825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         (0 == uprv_strcmp(expValidActual, "ge") && validActual >= 0) ||
1826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         (0 == uprv_strcmp(expValidActual, "eq") && validActual == 0))) {
1827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("%s; req=%s, valid=%s, actual=%s",
1828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              label, req, valid, actual);
1829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
18306d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("FAIL: %s; req=%s, valid=%s, actual=%s.  Require (R %s V) and (V %s A)",
1831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              label, req, valid, actual,
1832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              expReqValid, expValidActual);
1833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestGetLocale(void) {
1837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_SERVICE
1838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode ec = U_ZERO_ERROR;
1839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *req;
1840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale valid, actual, reqLoc;
1841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Calendar
1843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    req = "en_US_BROOKLYN";
1845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Calendar* cal = Calendar::createInstance(Locale::createFromName(req), ec);
1846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(ec)) {
184750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        dataerrln("FAIL: Calendar::createInstance failed - %s", u_errorName(ec));
1848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
1849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        valid = cal->getLocale(ULOC_VALID_LOCALE, ec);
1850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        actual = cal->getLocale(ULOC_ACTUAL_LOCALE, ec);
1851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: Calendar::getLocale() failed");
1853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            _checklocs("Calendar", req, valid, actual);
1855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* Make sure that it fails correctly */
1857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ec = U_FILE_ACCESS_ERROR;
1858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (cal->getLocale(ULOC_VALID_LOCALE, ec).getName()[0] != 0) {
1859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: Calendar::getLocale() failed to fail correctly. It should have returned \"\"");
1860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ec = U_ZERO_ERROR;
1862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete cal;
1864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // DecimalFormat, DecimalFormatSymbols
1867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    req = "fr_FR_NICE";
186927f654740f2a26ad62a5c155af9199af9e69b889claireho    NumberFormat* nf = NumberFormat::createInstance(Locale::createFromName(req), ec);
1870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(ec)) {
18716d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("FAIL: NumberFormat::createInstance failed - %s", u_errorName(ec));
1872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
187327f654740f2a26ad62a5c155af9199af9e69b889claireho        DecimalFormat* dec = dynamic_cast<DecimalFormat*>(nf);
187427f654740f2a26ad62a5c155af9199af9e69b889claireho        if (dec == NULL) {
1875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: NumberFormat::createInstance does not return a DecimalFormat");
1876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
1877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        valid = dec->getLocale(ULOC_VALID_LOCALE, ec);
1879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        actual = dec->getLocale(ULOC_ACTUAL_LOCALE, ec);
1880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: DecimalFormat::getLocale() failed");
1882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            _checklocs("DecimalFormat", req, valid, actual);
1884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const DecimalFormatSymbols* sym = dec->getDecimalFormatSymbols();
1887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (sym == NULL) {
1888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: getDecimalFormatSymbols returned NULL");
1889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
1890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        valid = sym->getLocale(ULOC_VALID_LOCALE, ec);
1892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec);
1893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: DecimalFormatSymbols::getLocale() failed");
1895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            _checklocs("DecimalFormatSymbols", req, valid, actual);
1897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
189927f654740f2a26ad62a5c155af9199af9e69b889claireho    delete nf;
1900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // DateFormat, DateFormatSymbols
1903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    req = "de_CH_LUCERNE";
190527f654740f2a26ad62a5c155af9199af9e69b889claireho    DateFormat* df =
1906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        DateFormat::createDateInstance(DateFormat::kDefault,
1907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                       Locale::createFromName(req));
190827f654740f2a26ad62a5c155af9199af9e69b889claireho    if (df == 0){
1909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        dataerrln("Error calling DateFormat::createDateInstance()");
1910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
191127f654740f2a26ad62a5c155af9199af9e69b889claireho        SimpleDateFormat* dat = dynamic_cast<SimpleDateFormat*>(df);
191227f654740f2a26ad62a5c155af9199af9e69b889claireho        if (dat == NULL) {
191327f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("FAIL: DateFormat::createInstance does not return a SimpleDateFormat");
1914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
1915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        valid = dat->getLocale(ULOC_VALID_LOCALE, ec);
1917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        actual = dat->getLocale(ULOC_ACTUAL_LOCALE, ec);
1918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: SimpleDateFormat::getLocale() failed");
1920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            _checklocs("SimpleDateFormat", req, valid, actual);
1922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const DateFormatSymbols* sym = dat->getDateFormatSymbols();
1925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (sym == NULL) {
1926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: getDateFormatSymbols returned NULL");
1927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
1928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        valid = sym->getLocale(ULOC_VALID_LOCALE, ec);
1930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec);
1931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: DateFormatSymbols::getLocale() failed");
1933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            _checklocs("DateFormatSymbols", req, valid, actual);
1935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
193727f654740f2a26ad62a5c155af9199af9e69b889claireho    delete df;
1938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // BreakIterator
1941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_BREAK_ITERATION
1942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    req = "es_ES_BARCELONA";
1943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    reqLoc = Locale::createFromName(req);
1944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    BreakIterator* brk = BreakIterator::createWordInstance(reqLoc, ec);
1945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(ec)) {
19466d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("FAIL: BreakIterator::createWordInstance failed - %s", u_errorName(ec));
1947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
1948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
1949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
1950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: BreakIterator::getLocale() failed");
1952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            _checklocs("BreakIterator", req, valid, actual);
1954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // After registering something, the behavior should be different
1957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        URegistryKey key = BreakIterator::registerInstance(brk, reqLoc, UBRK_WORD, ec);
1958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        brk = 0; // registerInstance adopts
1959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: BreakIterator::registerInstance() failed");
1961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1962b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            brk = BreakIterator::createWordInstance(reqLoc, ec);
1963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (U_FAILURE(ec)) {
1964b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: BreakIterator::createWordInstance failed");
1965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
1966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
1967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
1968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if (U_FAILURE(ec)) {
1969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    errln("FAIL: BreakIterator::getLocale() failed");
1970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                } else {
1971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    // N.B.: now expect valid==actual==req
1972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    _checklocs("BreakIterator(registered)",
1973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                               req, valid, actual, "eq", "eq");
1974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
1975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            // No matter what, unregister
1977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            BreakIterator::unregister(key, ec);
1978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (U_FAILURE(ec)) {
1979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: BreakIterator::unregister() failed");
1980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            delete brk;
1982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            brk = 0;
1983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // After unregistering, should behave normally again
1986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        brk = BreakIterator::createWordInstance(reqLoc, ec);
1987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
1988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: BreakIterator::createWordInstance failed");
1989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
1991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
1992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (U_FAILURE(ec)) {
1993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: BreakIterator::getLocale() failed");
1994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
1995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                _checklocs("BreakIterator(unregistered)", req, valid, actual);
1996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete brk;
2000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
2001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Collator
2003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_COLLATION
2004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    req = "hi_IN_BHOPAL";
2005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    reqLoc = Locale::createFromName(req);
2006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Collator* coll = Collator::createInstance(reqLoc, ec);
2007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(ec)) {
20086d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("FAIL: Collator::createInstance failed - %s", u_errorName(ec));
2009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
2010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
2011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
2012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
2013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: Collator::getLocale() failed");
2014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
2015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            _checklocs("Collator", req, valid, actual);
2016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
2017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // After registering something, the behavior should be different
2019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        URegistryKey key = Collator::registerInstance(coll, reqLoc, ec);
2020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        coll = 0; // registerInstance adopts
2021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
2022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: Collator::registerInstance() failed");
2023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
2024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            coll = Collator::createInstance(reqLoc, ec);
2025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (U_FAILURE(ec)) {
2026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: Collator::createWordInstance failed");
2027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
2028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
2029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
2030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if (U_FAILURE(ec)) {
2031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    errln("FAIL: Collator::getLocale() failed");
2032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                } else {
2033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    // N.B.: now expect valid==actual==req
2034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    _checklocs("Collator(registered)",
2035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                               req, valid, actual, "eq", "eq");
2036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
2037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
2038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            // No matter what, unregister
2039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            Collator::unregister(key, ec);
2040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (U_FAILURE(ec)) {
2041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: Collator::unregister() failed");
2042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
2043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            delete coll;
2044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            coll = 0;
2045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
2046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // After unregistering, should behave normally again
2048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        coll = Collator::createInstance(reqLoc, ec);
2049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_FAILURE(ec)) {
2050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: Collator::createInstance failed");
2051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
2052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
2053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
2054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (U_FAILURE(ec)) {
2055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: Collator::getLocale() failed");
2056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
2057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                _checklocs("Collator(unregistered)", req, valid, actual);
2058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
2059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
2060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete coll;
2062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
2063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
2064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestVariantWithOutCountry(void) {
2067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale loc("en","","POSIX");
2068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (0 != strcmp(loc.getVariant(), "POSIX")) {
2069103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius        errln("FAIL: en__POSIX didn't get parsed correctly - name is %s - expected %s got %s", loc.getName(), "POSIX", loc.getVariant());
2070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale loc2("en","","FOUR");
2072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (0 != strcmp(loc2.getVariant(), "FOUR")) {
2073103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius        errln("FAIL: en__FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc2.getName(), "FOUR", loc2.getVariant());
2074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale loc3("en","Latn","","FOUR");
2076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (0 != strcmp(loc3.getVariant(), "FOUR")) {
2077103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius        errln("FAIL: en_Latn__FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc3.getName(), "FOUR", loc3.getVariant());
2078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale loc4("","Latn","","FOUR");
2080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (0 != strcmp(loc4.getVariant(), "FOUR")) {
2081103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius        errln("FAIL: _Latn__FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc4.getName(), "FOUR", loc4.getVariant());
2082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale loc5("","Latn","US","FOUR");
2084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (0 != strcmp(loc5.getVariant(), "FOUR")) {
2085103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius        errln("FAIL: _Latn_US_FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc5.getName(), "FOUR", loc5.getVariant());
2086103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    }
2087103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    Locale loc6("de-1901");
2088103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    if (0 != strcmp(loc6.getVariant(), "1901")) {
2089103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius        errln("FAIL: de-1901 didn't get parsed correctly - name is %s - expected %s got %s", loc6.getName(), "1901", loc6.getVariant());
2090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic Locale _canonicalize(int32_t selector, /* 0==createFromName, 1==createCanonical, 2==Locale ct */
2094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                            const char* localeID) {
2095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    switch (selector) {
2096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 0:
2097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return Locale::createFromName(localeID);
2098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 1:
2099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return Locale::createCanonical(localeID);
2100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 2:
2101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return Locale(localeID);
2102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    default:
2103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return Locale("");
2104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid LocaleTest::TestCanonicalization(void)
2108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
2109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const struct {
2110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *localeID;    /* input */
2111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *getNameID;   /* expected getName() result */
2112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char *canonicalID; /* expected canonicalize() result */
2113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } testCases[] = {
211427f654740f2a26ad62a5c155af9199af9e69b889claireho        { "", "", "en_US_POSIX" },
211527f654740f2a26ad62a5c155af9199af9e69b889claireho        { "C", "c", "en_US_POSIX" },
211627f654740f2a26ad62a5c155af9199af9e69b889claireho        { "POSIX", "posix", "en_US_POSIX" },
2117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "ca_ES_PREEURO-with-extra-stuff-that really doesn't make any sense-unless-you're trying to increase code coverage",
2118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          "ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE",
2119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          "ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE"},
2120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES@currency=ESP" },
2121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT@currency=ATS" },
2122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE@currency=DEM" },
2123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU@currency=LUF" },
2124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR@currency=GRD" },
2125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE@currency=BEF" },
2126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE@currency=IEP" },
2127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES@currency=ESP" },
2128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES@currency=ESP" },
2129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI@currency=FIM" },
2130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE@currency=BEF" },
2131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR@currency=FRF" },
2132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU@currency=LUF" },
2133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE@currency=IEP" },
2134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES@currency=ESP" },
2135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT@currency=ITL" },
2136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE@currency=BEF" },
2137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL@currency=NLG" },
2138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT@currency=PTE" },
2139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de__PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" },
2140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "en_GB_EURO", "en_GB_EURO", "en_GB@currency=EUR" },
2141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "en_GB@EURO", "en_GB@EURO", "en_GB@currency=EUR" }, /* POSIX ID */
2142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "es__TRADITIONAL", "es__TRADITIONAL", "es@collation=traditional" },
2143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "hi__DIRECT", "hi__DIRECT", "hi@collation=direct" },
2144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" },
2145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" },
2146c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW@collation=stroke" },
2147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "zh__PINYIN", "zh__PINYIN", "zh@collation=pinyin" },
2148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "zh@collation=pinyin", "zh@collation=pinyin", "zh@collation=pinyin" },
2149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "zh_CN@collation=pinyin", "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" },
2150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin" },
2151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "en_US_POSIX", "en_US_POSIX", "en_US_POSIX" },
2152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "hy_AM_REVISED", "hy_AM_REVISED", "hy_AM_REVISED" },
2153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "no_NO_NY", "no_NO_NY", "no_NO_NY" /* not: "nn_NO" [alan ICU3.0] */ },
2154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "no@ny", "no@ny", "no__NY" /* not: "nn" [alan ICU3.0] */ }, /* POSIX ID */
2155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "no-no.utf32@B", "no_NO.utf32@B", "no_NO_B" /* not: "nb_NO_B" [alan ICU3.0] */ }, /* POSIX ID */
2156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "qz-qz@Euro", "qz_QZ@Euro", "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */
2157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // NOTE: uloc_getName() works on en-BOONT, but Locale() parser considers it BOGUS
2158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // TODO: unify this behavior
215954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius        { "en-BOONT", "en__BOONT", "en__BOONT" }, /* registered name */
216054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius        { "de-1901", "de__1901", "de__1901" }, /* registered name */
216154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius        { "de-1906", "de__1906", "de__1906" }, /* registered name */
2162c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_RS" }, /* .NET name */
2163c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_RS" }, /* .NET name */
2164c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_RS" }, /* Linux name */
2165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */
2166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */
2167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */
2168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "zh-CHT", "zh_CHT", "zh_Hant" }, /* .NET name This may change back to zh_Hant */
2169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* posix behavior that used to be performed by getName */
2171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "mr.utf8", "mr.utf8", "mr" },
2172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "de-tv.koi8r", "de_TV.koi8r", "de_TV" },
2173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "x-piglatin_ML.MBE", "x-piglatin_ML.MBE", "x-piglatin_ML" },
2174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "i-cherokee_US.utf7", "i-cherokee_US.utf7", "i-cherokee_US" },
2175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "x-filfli_MT_FILFLA.gb-18030", "x-filfli_MT_FILFLA.gb-18030", "x-filfli_MT_FILFLA" },
2176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "no-no-ny.utf8@B", "no_NO_NY.utf8@B", "no_NO_NY_B" /* not: "nn_NO" [alan ICU3.0] */ }, /* @ ignored unless variant is empty */
2177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* fleshing out canonicalization */
2179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* trim space and sort keywords, ';' is separator so not present at end in canonical form */
2180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "en_Hant_IL_VALLEY_GIRL@ currency = EUR; calendar = Japanese ;", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" },
2181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* already-canonical ids are not changed */
2182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" },
2183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* PRE_EURO and EURO conversions don't affect other keywords */
2184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES@calendar=Japanese;currency=ESP" },
2185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah", "es_ES@currency=EUR;shout=zipeedeedoodah" },
2186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* currency keyword overrides PRE_EURO and EURO currency */
2187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES@currency=EUR" },
2188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES@currency=ESP" },
2189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* norwegian is just too weird, if we handle things in their full generality */
2190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "no-Hant-GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$" /* not: "nn_Hant_GB@currency=$$$" [alan ICU3.0] */ },
2191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* test cases reflecting internal resource bundle usage */
2193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "root@kw=foo", "root@kw=foo", "root@kw=foo" },
2194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "@calendar=gregorian", "@calendar=gregorian", "@calendar=gregorian" },
2195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        { "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese" }
2196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
2197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const char* label[] = { "createFromName", "createCanonical", "Locale" };
2199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i, j;
2201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i=0; i < (int)(sizeof(testCases)/sizeof(testCases[0])); i++) {
2203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (j=0; j<3; ++j) {
2204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            const char* expected = (j==1) ? testCases[i].canonicalID : testCases[i].getNameID;
2205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            Locale loc = _canonicalize(j, testCases[i].localeID);
2206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            const char* getName = loc.isBogus() ? "BOGUS" : loc.getName();
2207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if(uprv_strcmp(expected, getName) != 0) {
2208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: %s(%s).getName() => \"%s\", expected \"%s\"",
2209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                      label[j], testCases[i].localeID, getName, expected);
2210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
2211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                logln("Ok: %s(%s) => \"%s\"",
2212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                      label[j], testCases[i].localeID, getName);
2213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
2214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
2215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
2216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
2217c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2218c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruvoid LocaleTest::TestCurrencyByDate(void)
2219c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru{
2220c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
2221c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
2222c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UDate date = uprv_getUTCtime();
2223c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	UChar TMP[4];
2224c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	int32_t index = 0;
2225c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	int32_t resLen = 0;
2226c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UnicodeString tempStr, resultStr;
2227c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2228c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	// Cycle through historical currencies
2229c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    date = (UDate)-630720000000.0; // pre 1961 - no currency defined
22306d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    index = ucurr_countCurrencies("eo_AM", date, &status);
2231c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (index != 0)
2232c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	{
22336d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru		errcheckln(status, "FAIL: didn't return 0 for eo_AM - %s", u_errorName(status));
2234c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	}
2235c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
2236c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resLen != 0) {
22376d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru		errcheckln(status, "FAIL: eo_AM didn't return NULL - %s", u_errorName(status));
2238c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2239c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    status = U_ZERO_ERROR;
2240c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2241c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    date = (UDate)0.0; // 1970 - one currency defined
22426d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    index = ucurr_countCurrencies("eo_AM", date, &status);
2243c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (index != 1)
2244c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	{
22456d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru		errcheckln(status, "FAIL: didn't return 1 for eo_AM - %s", u_errorName(status));
2246c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	}
2247c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
2248c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2249c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("SUR");
2250c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
22516d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return SUR for eo_AM - %s", u_errorName(status));
2252c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2253c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2254c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    date = (UDate)693792000000.0; // 1992 - one currency defined
2255c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	index = ucurr_countCurrencies("eo_AM", date, &status);
2256c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (index != 1)
2257c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	{
22586d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru		errcheckln(status, "FAIL: didn't return 1 for eo_AM - %s", u_errorName(status));
2259c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	}
2260c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
2261c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2262c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("RUR");
2263c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
22646d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return RUR for eo_AM - %s", u_errorName(status));
2265c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2266c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2267c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	date = (UDate)977616000000.0; // post 1993 - one currency defined
2268c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	index = ucurr_countCurrencies("eo_AM", date, &status);
2269c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (index != 1)
2270c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	{
22716d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru		errcheckln(status, "FAIL: didn't return 1 for eo_AM - %s", u_errorName(status));
2272c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	}
2273c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
2274c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2275c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("AMD");
2276c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
22776d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return AMD for eo_AM - %s", u_errorName(status));
2278c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2279c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2280c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    // Locale AD has multiple currencies at once
2281c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	date = (UDate)977616000000.0; // year 2001
2282c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	index = ucurr_countCurrencies("eo_AD", date, &status);
2283c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (index != 4)
2284c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	{
22856d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru		errcheckln(status, "FAIL: didn't return 4 for eo_AD - %s", u_errorName(status));
2286c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	}
2287c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AD", date, 1, TMP, 4, &status);
2288c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2289c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("EUR");
2290c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
22916d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return EUR for eo_AD - %s", u_errorName(status));
2292c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2293c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AD", date, 2, TMP, 4, &status);
2294c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2295c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("ESP");
2296c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
22976d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return ESP for eo_AD - %s", u_errorName(status));
2298c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2299c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AD", date, 3, TMP, 4, &status);
2300c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2301c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("FRF");
2302c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
23036d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return FRF for eo_AD - %s", u_errorName(status));
2304c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2305c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AD", date, 4, TMP, 4, &status);
2306c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2307c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("ADP");
2308c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
23096d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return ADP for eo_AD - %s", u_errorName(status));
2310c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    }
2311c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
2312c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	date = (UDate)0.0; // year 1970
2313c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	index = ucurr_countCurrencies("eo_AD", date, &status);
2314c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (index != 3)
2315c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	{
23166d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru		errcheckln(status, "FAIL: didn't return 3 for eo_AD - %s", u_errorName(status));
2317c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	}
2318c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resLen = ucurr_forLocaleAndDate("eo_AD", date, 1, TMP, 4, &status);
2319c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru	tempStr.setTo(TMP);
2320c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    resultStr.setTo("ESP");
2321c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    if (resultStr != tempStr) {
23226d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errcheckln(status, "FAIL: didn't return ESP for eo_AD - %s", u_errorName(status));
2323