X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/46f4442e9a5a4f3b98b7c1083586332f6a8a99a4..e4f10fab0c078f399c9deef476d9c9b73b47dff8:/icuSources/test/intltest/tsdtfmsy.cpp diff --git a/icuSources/test/intltest/tsdtfmsy.cpp b/icuSources/test/intltest/tsdtfmsy.cpp index 663fb6a6..02bc123f 100644 --- a/icuSources/test/intltest/tsdtfmsy.cpp +++ b/icuSources/test/intltest/tsdtfmsy.cpp @@ -1,5 +1,5 @@ /******************************************************************** - * Copyright (c) 1997-2008, International Business Machines + * Copyright (c) 1997-2013, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************/ @@ -26,6 +26,7 @@ void IntlTestDateFormatSymbols::runIndexedTest( int32_t index, UBool exec, const TESTCASE(2,TestGetMonths2); TESTCASE(3,TestGetWeekdays2); TESTCASE(4,TestGetEraNames); + TESTCASE(5,TestGetSetSpecificItems); default: name = ""; break; } } @@ -126,6 +127,41 @@ void IntlTestDateFormatSymbols::TestGetEraNames() delete symbol; } +UBool IntlTestDateFormatSymbols::UnicodeStringsArePrefixes(int32_t count, int32_t prefixLen, const UnicodeString *prefixArray, const UnicodeString *baseArray) +{ + int32_t i; + for (i = 0; i < count; i++) { + if (baseArray[i].compare(0, prefixLen, prefixArray[i]) != 0) { + errln("ERROR: Mismatch example: expect prefix \"" + prefixArray[i] + "\" of base \"" + baseArray[i] + "\"."); + return FALSE; + } + } + return TRUE; +} + +void IntlTestDateFormatSymbols::TestGetSetSpecificItems() +{ + UErrorCode status = U_ZERO_ERROR; + DateFormatSymbols *symbol=new DateFormatSymbols(Locale::getEnglish(), status); + if(U_FAILURE(status)) { + dataerrln("ERROR: Couldn't create English DateFormatSymbols " + (UnicodeString)u_errorName(status)); + return; + } + int32_t cntFmtAbbrev, cntFmtShort, cntStdAloneShort; + const UnicodeString * wdFmtAbbrev = symbol->getWeekdays(cntFmtAbbrev,DateFormatSymbols::FORMAT,DateFormatSymbols::ABBREVIATED); + const UnicodeString * wdFmtShort = symbol->getWeekdays(cntFmtShort,DateFormatSymbols::FORMAT,DateFormatSymbols::SHORT); + const UnicodeString * wdStdAloneShort = symbol->getWeekdays(cntStdAloneShort,DateFormatSymbols::STANDALONE,DateFormatSymbols::SHORT); + // Expect that English short names are prefixes of abbreviated names + if (cntFmtShort != cntFmtAbbrev || !UnicodeStringsArePrefixes(cntFmtAbbrev, 2, wdFmtShort, wdFmtAbbrev)) { + errln("ERROR: English format short weekday names don't match prefixes of format abbreviated names"); + } + if (cntStdAloneShort != cntFmtAbbrev || !UnicodeStringsArePrefixes(cntFmtAbbrev, 2, wdStdAloneShort, wdFmtAbbrev)) { + errln("ERROR: English standalone short weekday names don't match prefixes of format abbreviated names"); + } + + delete symbol; +} + /** * Test the API of DateFormatSymbols; primarily a simple get/set set. */ @@ -135,19 +171,22 @@ void IntlTestDateFormatSymbols::TestSymbols(/* char *par */) DateFormatSymbols fr(Locale::getFrench(), status); if(U_FAILURE(status)) { - errln("ERROR: Couldn't create French DateFormatSymbols " + (UnicodeString)u_errorName(status)); + dataerrln("ERROR: Couldn't create French DateFormatSymbols " + (UnicodeString)u_errorName(status)); + return; } status = U_ZERO_ERROR; DateFormatSymbols fr2(Locale::getFrench(), status); if(U_FAILURE(status)) { - errln("ERROR: Couldn't create French DateFormatSymbols " + (UnicodeString)u_errorName(status)); + errcheckln(status, "ERROR: Couldn't create French DateFormatSymbols " + (UnicodeString)u_errorName(status)); + return; } status = U_ZERO_ERROR; DateFormatSymbols en(Locale::getEnglish(), status); if(U_FAILURE(status)) { - errln("ERROR: Couldn't create English DateFormatSymbols " + (UnicodeString)u_errorName(status)); + errcheckln(status, "ERROR: Couldn't create English DateFormatSymbols " + (UnicodeString)u_errorName(status)); + return; } if(en == fr || ! (en != fr) ) {