diff options
Diffstat (limited to 'Build/source/libs/icu-xetex/test/intltest/loctest.cpp')
-rw-r--r-- | Build/source/libs/icu-xetex/test/intltest/loctest.cpp | 101 |
1 files changed, 41 insertions, 60 deletions
diff --git a/Build/source/libs/icu-xetex/test/intltest/loctest.cpp b/Build/source/libs/icu-xetex/test/intltest/loctest.cpp index c18ea0a3f25..06264a7fba9 100644 --- a/Build/source/libs/icu-xetex/test/intltest/loctest.cpp +++ b/Build/source/libs/icu-xetex/test/intltest/loctest.cpp @@ -1,11 +1,10 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2005, International Business Machines Corporation and + * Copyright (c) 1997-2006, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #include "loctest.h" -#include <stdio.h> #include "unicode/decimfmt.h" #include "unicode/ucurr.h" #include "unicode/smpdtfmt.h" @@ -13,7 +12,7 @@ #include "unicode/brkiter.h" #include "unicode/coll.h" #include "cstring.h" -#include "uassert.h" +#include <stdio.h> const char* rawData[33][8] = { @@ -50,14 +49,14 @@ const char* rawData[33][8] = { // display langage (French) { "anglais", "fran\\u00E7ais", "catalan", "grec", "norv\\u00E9gien", "italien", "xx", "chinois" }, // display script (French) - { "", "", "", "", "", "", "", "han simplifi\\u00E9" }, + { "", "", "", "", "", "", "", "id\\u00E9ogrammes han (variante simplifi\\u00E9e)" }, // display country (French) { "\\u00C9tats-Unis", "France", "Espagne", "Gr\\u00E8ce", "Norv\\u00E8ge", "", "YY", "Chine" }, // display variant (French) { "", "", "", "", "NY", "", "", "" }, // display name (French) //{ "anglais (Etats-Unis)", "francais (France)", "catalan (Espagne)", "grec (Grece)", "norvegien (Norvege,Nynorsk)", "italien", "xx (YY)" }, - { "anglais (\\u00C9tats-Unis)", "fran\\u00E7ais (France)", "catalan (Espagne)", "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)", "italien", "xx (YY)", "chinois (han simplifi\\u00E9, Chine)" }, // STILL not right + { "anglais (\\u00C9tats-Unis)", "fran\\u00E7ais (France)", "catalan (Espagne)", "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)", "italien", "xx (YY)", "chinois (id\\u00E9ogrammes han (variante simplifi\\u00E9e), Chine)" }, // STILL not right /* display language (Catalan) */ @@ -119,38 +118,25 @@ const char* rawData[33][8] = { { "English (United States)", "French (France)", "Catalan (Spain)", "Greek (Greece)", "Norwegian (Norway,NY)", "Italian", "xx (YY)", "" } }; -// * test macros + /* Usage: - test_compare( Function to be performed, - Test of the function, - expected result of the test, - printable result - ) + test_assert( Test (should be TRUE) ) Example: - test_compare(i=3,i,3, someNumberFormatter(i)); - test_compare(0,1+1,2,someNumberFormatter(1+1)); - - Note that in the second example the expression is 0, because the fcn produces it's own result. + test_assert(i==3); - Macro is ugly but makes the tests pretty. + the macro is ugly but makes the tests pretty. */ -#define test_compare(expression,test,expected,printableResult) \ +#define test_assert(test) \ { \ - expression; \ - \ - if((test) != (expected)) \ - errln("FAIL: " + UnicodeString(#expression) + "; -> " + printableResult + "\n" + \ - " (" + UnicodeString(#test) + " != " + UnicodeString(#expected) + ")" ); \ + if(!(test)) \ + errln("FAIL: " #test " was not true. In " __FILE__ " on line %d", __LINE__ ); \ else \ - logln(UnicodeString(#expression) + " -> " + printableResult + " (" + UnicodeString(#test) + ")"); \ + logln("PASS: asserted " #test); \ } - - - /* Usage: test_assert_print( Test (should be TRUE), printable ) @@ -164,13 +150,13 @@ const char* rawData[33][8] = { #define test_assert_print(test,print) \ { \ if(!(test)) \ - errln("FAIL: " + UnicodeString(#test) + " was not true." + "-> " + UnicodeString(print) ); \ + errln("FAIL: " #test " was not true. " + UnicodeString(print) ); \ else \ - logln("PASS: asserted " + UnicodeString(#test) + "-> " + UnicodeString(print)); \ + logln("PASS: asserted " #test "-> " + UnicodeString(print)); \ } -#define test_dumpLocale(l) { UnicodeString s(l.getName(),""); logln(#l + UnicodeString(" = ") + s); } +#define test_dumpLocale(l) { logln(#l " = " + UnicodeString(l.getName(), "")); } LocaleTest::LocaleTest() : dataTable(NULL) @@ -511,24 +497,6 @@ LocaleTest::TestDisplayNames() } } -/* - Usage: - test_assert( Test (should be TRUE) ) - - Example: - test_assert(i==3); - - the macro is ugly but makes the tests pretty. -*/ - -#define test_assert(test) \ - { \ - if(!(test)) \ - errln("FAIL: " + UnicodeString(#test) + " was not true. " + UnicodeString(__FILE__ " line ") + __LINE__ ); \ - else \ - logln("PASS: asserted " + UnicodeString(#test) ); \ - } - void LocaleTest::TestSimpleObjectStuff() { Locale test1("aa", "AA"); Locale test2("aa", "AA"); @@ -877,8 +845,8 @@ LocaleTest::TestGetLangsAndCountries() ; /* TODO: Change this test to be more like the cloctst version? */ - if (testCount != 473) - errln("Expected getISOLanguages() to return 473 languages; it returned %d", testCount); + if (testCount != 485) + errln("Expected getISOLanguages() to return 481 languages; it returned %d", testCount); else { for (i = 0; i < 15; i++) { int32_t j; @@ -908,9 +876,9 @@ LocaleTest::TestGetLangsAndCountries() for(testCount=0;test[testCount];testCount++) ; - if (testCount != 240) - errln("Expected getISOLanguages to return 240 languages; it returned" + testCount); - else { + if (testCount != 244){ + errln("Expected getISOCountries to return 240 countries; it returned %d", testCount); + }else { for (i = 0; i < spot2Len; i++) { int32_t j; for (j = 0; j < testCount; j++) @@ -925,7 +893,7 @@ LocaleTest::TestGetLangsAndCountries() errln("Couldn't find " + spotCheck2[i] + " in country list."); } } - for (i = 0; i < testCount; i++) { + for (i = 0; i < testCount; i++) { UnicodeString testee(test[i],""); UnicodeString uc(test[i],""); if (testee != uc.toUpper()) @@ -1037,7 +1005,7 @@ LocaleTest::TestAtypicalLocales() "espagnol (Allemagne)", "Croatie", CharsToUnicodeString("Su\\u00E8de"), - CharsToUnicodeString("R\\u00E9publique dominicaine"), + CharsToUnicodeString("Dominicaine, r\\u00E9publique"), "Belgique" }; UnicodeString spanishDisplayNames [] = { CharsToUnicodeString("alem\\u00E1n (Canad\\u00E1)"), @@ -1819,7 +1787,10 @@ void LocaleTest::TestGetLocale(void) { if (U_FAILURE(ec)) { errln("FAIL: NumberFormat::createInstance failed"); } else { - U_ASSERT(dec->getDynamicClassID() == DecimalFormat::getStaticClassID()); + if (dec->getDynamicClassID() != DecimalFormat::getStaticClassID()) { + errln("FAIL: NumberFormat::createInstance does not return a DecimalFormat"); + return; + } valid = dec->getLocale(ULOC_VALID_LOCALE, ec); actual = dec->getLocale(ULOC_ACTUAL_LOCALE, ec); if (U_FAILURE(ec)) { @@ -1829,7 +1800,10 @@ void LocaleTest::TestGetLocale(void) { } const DecimalFormatSymbols* sym = dec->getDecimalFormatSymbols(); - U_ASSERT(sym != 0); + if (sym == NULL) { + errln("FAIL: getDecimalFormatSymbols returned NULL"); + return; + } valid = sym->getLocale(ULOC_VALID_LOCALE, ec); actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec); if (U_FAILURE(ec)) { @@ -1850,7 +1824,10 @@ void LocaleTest::TestGetLocale(void) { if (dat == 0){ dataerrln("Error calling DateFormat::createDateInstance()"); } else { - U_ASSERT(dat->getDynamicClassID() == SimpleDateFormat::getStaticClassID()); + if (dat->getDynamicClassID() != SimpleDateFormat::getStaticClassID()) { + errln("FAIL: NumberFormat::createInstance does not return a DecimalFormat"); + return; + } valid = dat->getLocale(ULOC_VALID_LOCALE, ec); actual = dat->getLocale(ULOC_ACTUAL_LOCALE, ec); if (U_FAILURE(ec)) { @@ -1860,7 +1837,10 @@ void LocaleTest::TestGetLocale(void) { } const DateFormatSymbols* sym = dat->getDateFormatSymbols(); - U_ASSERT(sym != 0); + if (sym == NULL) { + errln("FAIL: getDateFormatSymbols returned NULL"); + return; + } valid = sym->getLocale(ULOC_VALID_LOCALE, ec); actual = sym->getLocale(ULOC_ACTUAL_LOCALE, ec); if (U_FAILURE(ec)) { @@ -2087,8 +2067,9 @@ void LocaleTest::TestCanonicalization(void) { "en-BOONT", "BOGUS", "en__BOONT" }, /* registered name */ { "de-1901", "de_1901", "de__1901" }, /* registered name */ { "de-1906", "de_1906", "de__1906" }, /* registered name */ - { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_SP" }, /* .NET name */ - { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_SP" }, /* .NET name */ + { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_CS" }, /* .NET name */ + { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_CS" }, /* .NET name */ + { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_CS" }, /* Linux name */ { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */ { "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */ { "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */ |