From 63131bbb5fc8cc62d327ed891d2ae52ed1973148 Mon Sep 17 00:00:00 2001 From: Vladimir Weinstein Date: Fri, 9 Jan 2004 08:08:26 +0000 Subject: [PATCH] ICU-2438 getBaseName test X-SVN-Rev: 14280 --- icu4c/source/test/intltest/loctest.cpp | 23 +++++++++++++++++++++++ icu4c/source/test/intltest/loctest.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/icu4c/source/test/intltest/loctest.cpp b/icu4c/source/test/intltest/loctest.cpp index 91e6c8a623..4e6c45c753 100644 --- a/icu4c/source/test/intltest/loctest.cpp +++ b/icu4c/source/test/intltest/loctest.cpp @@ -226,6 +226,7 @@ void LocaleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, c CASE(23, TestParallelAPIValues) CASE(24, TestKeywordVariants) CASE(25, TestKeywordVariantParsing) + CASE(26, TestGetBaseName) // keep the last index in sync with the condition in default: @@ -1657,3 +1658,25 @@ LocaleTest::TestKeywordVariantParsing(void) { } } +void +LocaleTest::TestGetBaseName(void) { + struct { + const char *localeID; + const char *baseName; + } testCases[] = { + { "de_DE@ C o ll A t i o n = Phonebook ", "de_DE" }, + { "de@currency = euro; CoLLaTion = PHONEBOOk", "de" }, + { "ja@calendar = buddhist", "ja" } + }; + + int32_t i = 0, baseNameLen = 0; + + for(i = 0; i < sizeof(testCases)/sizeof(testCases[0]); i++) { + Locale loc(testCases[i].localeID); + if(strcmp(testCases[i].baseName, loc.getBaseName())) { + errln("For locale \"%s\" expected baseName \"%s\", but got \"%s\"", + testCases[i].localeID, testCases[i].baseName, loc.getBaseName()); + return; + } + } +} diff --git a/icu4c/source/test/intltest/loctest.h b/icu4c/source/test/intltest/loctest.h index a9540b69df..f5bd8ddeae 100644 --- a/icu4c/source/test/intltest/loctest.h +++ b/icu4c/source/test/intltest/loctest.h @@ -75,6 +75,9 @@ public: /* Test getting keyword values */ void TestKeywordVariantParsing(void); + + /* Test getting the locale base name */ + void TestGetBaseName(void); #if !UCONFIG_NO_FORMATTING void Test4105828(void) ;