mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-7973 make isICUVersionAtLeast() easier to use, add isICUVersionBefore()
X-SVN-Rev: 31122
This commit is contained in:
parent
b3365b405a
commit
b4ce283bca
9 changed files with 53 additions and 32 deletions
|
@ -692,9 +692,15 @@ U_CFUNC UBool assertEquals(const char* message, const char* expected,
|
|||
*--------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
U_CFUNC UBool isICUVersionAtLeast(const UVersionInfo x) {
|
||||
UVersionInfo v;
|
||||
u_getVersion(v);
|
||||
return (uprv_memcmp(v, x, U_MAX_VERSION_LENGTH) >= 0);
|
||||
U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli) {
|
||||
UVersionInfo iv;
|
||||
UVersionInfo ov = { (uint8_t)major, (uint8_t)minor, (uint8_t)milli, 0 };
|
||||
u_getVersion(iv);
|
||||
return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0;
|
||||
}
|
||||
|
||||
U_CFUNC UBool isICUVersionAtLeast(int major, int minor, int milli) {
|
||||
return !isICUVersionBefore(major, minor, milli);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2005, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2011, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
|
@ -105,10 +105,13 @@ U_CFUNC UBool assertEquals(const char* msg, const char* expectedString,
|
|||
const char* actualString);
|
||||
|
||||
/**
|
||||
* Time bomb - allows temporary behavior that expires at a given
|
||||
* release
|
||||
*
|
||||
* Returns true if u_getVersion() < major.minor.milli.
|
||||
*/
|
||||
U_CFUNC UBool isICUVersionAtLeast(const UVersionInfo x);
|
||||
U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli);
|
||||
|
||||
/**
|
||||
* Returns true if u_getVersion() >= major.minor.milli.
|
||||
*/
|
||||
U_CFUNC UBool isICUVersionAtLeast(int major, int minor, int milli);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -489,7 +489,6 @@ TestLocaleStructure(void) {
|
|||
int32_t locIndex;
|
||||
UErrorCode errorCode = U_ZERO_ERROR;
|
||||
const char *currLoc, *resolvedLoc;
|
||||
static const UVersionInfo icu48 = { 4, 8, 0, 0 };
|
||||
|
||||
/* TODO: Compare against parent's data too. This code can't handle fallbacks that some tools do already. */
|
||||
/* char locName[ULOC_FULLNAME_CAPACITY];
|
||||
|
@ -549,9 +548,7 @@ TestLocaleStructure(void) {
|
|||
currLoc);
|
||||
}
|
||||
resolvedLoc = ures_getLocaleByType(currentLocale, ULOC_ACTUAL_LOCALE, &errorCode);
|
||||
if ( strcmp(resolvedLoc, currLoc) != 0 &&
|
||||
( strcmp(currLoc,"vai_LR") != 0 || isICUVersionAtLeast(icu48))) {
|
||||
/* Time bomb for weird case with vai_LR - needs investigation */
|
||||
if (strcmp(resolvedLoc, currLoc) != 0) {
|
||||
/* All locales have at least a Version resource.
|
||||
If it's absolutely empty, then the previous test will fail too.*/
|
||||
log_err("Locale resolves to different locale. Is %s an alias of %s?\n",
|
||||
|
@ -867,7 +864,6 @@ findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen,
|
|||
}
|
||||
|
||||
static void VerifyTranslation(void) {
|
||||
static const UVersionInfo icu49 = { 49, 1, 0, 0 };
|
||||
UResourceBundle *root, *currentLocale;
|
||||
int32_t locCount = uloc_countAvailable();
|
||||
int32_t locIndex;
|
||||
|
@ -938,7 +934,7 @@ static void VerifyTranslation(void) {
|
|||
if (U_FAILURE(errorCode)) {
|
||||
log_err("error uloc_getDisplayCountry returned %s\n", u_errorName(errorCode));
|
||||
}
|
||||
else if (uprv_strstr(currLoc, "ti_") != currLoc || isICUVersionAtLeast(icu49)) { /* TODO: restore DisplayCountry test for ti_* when cldrbug 3058 is fixed) */
|
||||
else if (uprv_strstr(currLoc, "ti_") != currLoc || isICUVersionAtLeast(49, 1, 0)) { /* TODO: restore DisplayCountry test for ti_* when cldrbug 3058 is fixed) */
|
||||
strIdx = findStringSetMismatch(currLoc, langBuffer, langSize, exemplarCharacters, exemplarLen, FALSE, &badChar);
|
||||
if (strIdx >= 0) {
|
||||
log_err("getDisplayCountry(%s) at index %d returned characters not in the exemplar characters: %04X.\n",
|
||||
|
|
|
@ -5122,7 +5122,6 @@ TestTailor6179(void)
|
|||
static const uint8_t lastPrimaryIgnCE[]={1, 0xE3, 1, 5, 0};
|
||||
static const uint8_t firstSecondaryIgnCE[]={1, 1, 0xbf, 0x04, 0};
|
||||
static const uint8_t lastSecondaryIgnCE[]={1, 1, 0xbf, 0x04, 0};
|
||||
static const UVersionInfo icu49={ 49, 1, 0, 0 };
|
||||
|
||||
/* Test [Last Primary ignorable] */
|
||||
|
||||
|
@ -5171,7 +5170,7 @@ TestTailor6179(void)
|
|||
}
|
||||
log_err("\n");
|
||||
}
|
||||
if(isICUVersionAtLeast(icu49)) { /* TODO: debug & fix, see ticket #8982 */
|
||||
if(isICUVersionAtLeast(49, 1, 0)) { /* TODO: debug & fix, see ticket #8982 */
|
||||
tLen = u_strlen(tData2[1]);
|
||||
rLen = ucol_getSortKey(coll, tData2[1], tLen, resColl, 100);
|
||||
if (rLen != LEN(firstSecondaryIgnCE) || uprv_memcmp(resColl, firstSecondaryIgnCE, rLen) != 0) {
|
||||
|
|
|
@ -250,7 +250,6 @@ static void checkStatus(int32_t line, UErrorCode expected, UErrorCode status) {
|
|||
}
|
||||
|
||||
static void TestErrorCodes(void) {
|
||||
static const UVersionInfo icu49 = { 49, 1, 0, 0 };
|
||||
UErrorCode status = U_USING_DEFAULT_WARNING;
|
||||
|
||||
UResourceBundle *r = NULL, *r2 = NULL;
|
||||
|
@ -282,7 +281,7 @@ static void TestErrorCodes(void) {
|
|||
|
||||
/* we look up the resource which is aliased and at our level */
|
||||
/* TODO: restore the following test when cldrbug 3058: is fixed */
|
||||
if(U_SUCCESS(status) && r != NULL && isICUVersionAtLeast(icu49)) {
|
||||
if(U_SUCCESS(status) && r != NULL && isICUVersionAtLeast(49, 1, 0)) {
|
||||
status = U_USING_DEFAULT_WARNING;
|
||||
r2 = ures_getByKey(r, "Countries", r2, &status);
|
||||
checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
|
||||
|
|
|
@ -1752,10 +1752,11 @@ UBool IntlTest::assertEquals(const UnicodeString& message,
|
|||
// release
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
UBool IntlTest::isICUVersionAtLeast(const UVersionInfo x) {
|
||||
UVersionInfo v;
|
||||
u_getVersion(v);
|
||||
return (uprv_memcmp(v, x, U_MAX_VERSION_LENGTH) >= 0);
|
||||
UBool IntlTest::isICUVersionBefore(int major, int minor, int milli) {
|
||||
UVersionInfo iv;
|
||||
UVersionInfo ov = { (uint8_t)major, (uint8_t)minor, (uint8_t)milli, 0 };
|
||||
u_getVersion(iv);
|
||||
return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0;
|
||||
}
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
|
|
@ -175,10 +175,30 @@ public:
|
|||
static float random();
|
||||
|
||||
/**
|
||||
* Ascertain the version of ICU. Useful for
|
||||
* time bomb testing
|
||||
* Returns true if u_getVersion() < major.minor.
|
||||
*/
|
||||
UBool isICUVersionAtLeast(const UVersionInfo x);
|
||||
static UBool isICUVersionBefore(int major, int minor) {
|
||||
return isICUVersionBefore(major, minor, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if u_getVersion() < major.minor.milli.
|
||||
*/
|
||||
static UBool isICUVersionBefore(int major, int minor, int milli);
|
||||
|
||||
/**
|
||||
* Returns true if u_getVersion() >= major.minor.
|
||||
*/
|
||||
static UBool isICUVersionAtLeast(int major, int minor) {
|
||||
return isICUVersionAtLeast(major, minor, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if u_getVersion() >= major.minor.milli.
|
||||
*/
|
||||
static UBool isICUVersionAtLeast(int major, int minor, int milli) {
|
||||
return !isICUVersionBefore(major, minor, milli);
|
||||
}
|
||||
|
||||
enum { kMaxProps = 16 };
|
||||
|
||||
|
|
|
@ -2149,8 +2149,7 @@ void RBBITest::TestUnicodeFiles() {
|
|||
void RBBITest::runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi) {
|
||||
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
|
||||
// TODO(andy): Match line break behavior to Unicode 6.0 and remove this time bomb.
|
||||
UVersionInfo icu49 = { 49, 1, 0, 0 };
|
||||
UBool isICUVersionPast48 = isICUVersionAtLeast(icu49);
|
||||
UBool isICUVersionPast48 = isICUVersionAtLeast(49, 1);
|
||||
UBool isLineBreak = 0 == strcmp(fileName, "LineBreakTest.txt");
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
|
|
@ -904,7 +904,6 @@ static char *printOrders(char *buffer, OrderList &list)
|
|||
|
||||
void SSearchTest::offsetTest()
|
||||
{
|
||||
static const UVersionInfo icu49 = { 49, 1, 0, 0 };
|
||||
const char *test[] = {
|
||||
// The sequence \u0FB3\u0F71\u0F71\u0F80 contains a discontiguous
|
||||
// contraction (\u0FB3\u0F71\u0F80) logically followed by \u0F71.
|
||||
|
@ -981,7 +980,7 @@ void SSearchTest::offsetTest()
|
|||
col->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status);
|
||||
|
||||
for(int32_t i = 0; i < testCount; i += 1) {
|
||||
if (!isICUVersionAtLeast(icu49) && i>=4 && i<=6) {
|
||||
if (!isICUVersionAtLeast(49, 1) && i>=4 && i<=6) {
|
||||
continue; // timebomb until ticket #8080 is resolved
|
||||
}
|
||||
UnicodeString ts = CharsToUnicodeString(test[i]);
|
||||
|
@ -2342,7 +2341,6 @@ void SSearchTest::monkeyTest(char *params)
|
|||
|
||||
void SSearchTest::bmMonkeyTest(char *params)
|
||||
{
|
||||
static const UVersionInfo icu49 = { 49, 1, 0, 0 }; // for timebomb
|
||||
static const UChar skipChars[] = { 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0xAAB5, 0xAAB6, 0xAAB9, 0xAABB, 0xAABC, 0 }; // for timebomb
|
||||
// ook!
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
@ -2448,7 +2446,7 @@ void SSearchTest::bmMonkeyTest(char *params)
|
|||
generateTestCase(coll, monkeys, monkeyCount, prefix, altPrefix);
|
||||
generateTestCase(coll, monkeys, monkeyCount, suffix, altSuffix);
|
||||
|
||||
if (!isICUVersionAtLeast(icu49) && skipSet->containsSome(pattern)) {
|
||||
if (!isICUVersionAtLeast(49, 1) && skipSet->containsSome(pattern)) {
|
||||
continue; // timebomb until ticket #8080 is resolved
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue