ICU-5808 fixes for uconfigtest.

X-SVN-Rev: 22349
This commit is contained in:
Eric Mader 2007-08-10 23:31:48 +00:00
parent 7849815922
commit a3b08a4e2b
8 changed files with 138 additions and 43 deletions

View File

@ -1,41 +1,41 @@
/*
******************************************************************************
* Copyright (C) 1996-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
******************************************************************************
* Copyright (C) 1996-2007, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
/**
* File coll.cpp
*
* Created by: Helena Shih
*
* Modification History:
*
* Date Name Description
* 2/5/97 aliu Modified createDefault to load collation data from
* binary files when possible. Added related methods
* createCollationFromFile, chopLocale, createPathName.
* 2/11/97 aliu Added methods addToCache, findInCache, which implement
* a Collation cache. Modified createDefault to look in
* cache first, and also to store newly created Collation
* objects in the cache. Modified to not use gLocPath.
* 2/12/97 aliu Modified to create objects from RuleBasedCollator cache.
* Moved cache out of Collation class.
* 2/13/97 aliu Moved several methods out of this class and into
* RuleBasedCollator, with modifications. Modified
* createDefault() to call new RuleBasedCollator(Locale&)
* constructor. General clean up and documentation.
* 2/20/97 helena Added clone, operator==, operator!=, operator=, and copy
* constructor.
* 05/06/97 helena Added memory allocation error detection.
* 05/08/97 helena Added createInstance().
* 6/20/97 helena Java class name change.
* 04/23/99 stephen Removed EDecompositionMode, merged with
* Normalizer::EMode
* 11/23/9 srl Inlining of some critical functions
* 01/29/01 synwee Modified into a C++ wrapper calling C APIs (ucol.h)
*/
* File coll.cpp
*
* Created by: Helena Shih
*
* Modification History:
*
* Date Name Description
* 2/5/97 aliu Modified createDefault to load collation data from
* binary files when possible. Added related methods
* createCollationFromFile, chopLocale, createPathName.
* 2/11/97 aliu Added methods addToCache, findInCache, which implement
* a Collation cache. Modified createDefault to look in
* cache first, and also to store newly created Collation
* objects in the cache. Modified to not use gLocPath.
* 2/12/97 aliu Modified to create objects from RuleBasedCollator cache.
* Moved cache out of Collation class.
* 2/13/97 aliu Moved several methods out of this class and into
* RuleBasedCollator, with modifications. Modified
* createDefault() to call new RuleBasedCollator(Locale&)
* constructor. General clean up and documentation.
* 2/20/97 helena Added clone, operator==, operator!=, operator=, and copy
* constructor.
* 05/06/97 helena Added memory allocation error detection.
* 05/08/97 helena Added createInstance().
* 6/20/97 helena Java class name change.
* 04/23/99 stephen Removed EDecompositionMode, merged with
* Normalizer::EMode
* 11/23/9 srl Inlining of some critical functions
* 01/29/01 synwee Modified into a C++ wrapper calling C APIs (ucol.h)
*/
#include "unicode/utypes.h"
@ -77,9 +77,10 @@ static UBool U_CALLCONV collator_cleanup(void) {
U_CDECL_END
#if !UCONFIG_NO_SERVICE
U_NAMESPACE_BEGIN
#if !UCONFIG_NO_SERVICE
// ------------------------------------------
//
// Registration

View File

@ -4,6 +4,8 @@
* others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include <stdio.h>
@ -14,7 +16,6 @@
#include "unicode/smpdtfmt.h"
#include "unicode/dtfmtsym.h"
#include "unicode/dtptngen.h"
#include "unicode/utypes.h"
#include "loctest.h"

View File

@ -6,6 +6,8 @@
*/
#include "fldset.h"
#if !UCONFIG_NO_FORMATTING
#include <stdio.h>
#include "unicode/regex.h"
@ -68,11 +70,37 @@ UnicodeString FieldsSet::diffFrom(const FieldsSet& other, UErrorCode& status) co
return str;
}
static UnicodeString *split(const UnicodeString &src, UChar ch, int32_t &splits)
{
int32_t offset = -1;
splits = 1;
while((offset = src.indexOf(ch, offset + 1)) >= 0) {
splits += 1;
}
UnicodeString *result = new UnicodeString[splits];
int32_t start = 0;
int32_t split = 0;
int32_t end;
while((end = src.indexOf(ch, start)) >= 0) {
src.extractBetween(start, end, result[split++]);
start = end + 1;
}
src.extractBetween(start, src.length(), result[split]);
return result;
}
int32_t FieldsSet::parseFrom(const UnicodeString& str, const
FieldsSet* inheritFrom, UErrorCode& status) {
int goodFields = 0;
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
UnicodeString pattern(",", "");
RegexMatcher matcher(pattern, 0, status);
UnicodeString pattern2("=", "");
@ -117,6 +145,55 @@ int32_t FieldsSet::parseFrom(const UnicodeString& str, const
goodFields++;
}
}
#else
if(U_FAILURE(status)) {
return -1;
}
int32_t destCount = 0;
UnicodeString *dest = split(str, ',', destCount);
for(int i = 0; i < destCount; i += 1) {
int32_t dc = 0;
UnicodeString *kv = split(dest[i], '=', dc);
if(dc != 2) {
fprintf(stderr, "dc == %d?\n");
}
int32_t field = handleParseName(inheritFrom, kv[0], kv[1], status);
if(U_FAILURE(status)) {
char ch[256];
const UChar *u = kv[0].getBuffer();
int32_t len = kv[0].length();
u_UCharsToChars(u, ch, len);
ch[len] = 0; /* include terminating \0 */
fprintf(stderr,"Parse Failed: Field %s, err %s\n", ch, u_errorName(status));
return -1;
}
if(field != -1) {
handleParseValue(inheritFrom, field, kv[1], status);
if(U_FAILURE(status)) {
char ch[256];
const UChar *u = kv[1].getBuffer();
int32_t len = kv[1].length();
u_UCharsToChars(u, ch, len);
ch[len] = 0; /* include terminating \0 */
fprintf(stderr,"Parse Failed: Value %s, err %s\n", ch, u_errorName(status));
return -1;
}
goodFields += 1;
}
delete[] kv;
}
delete[] dest;
#endif
return goodFields;
}
@ -313,3 +390,4 @@ int32_t DateTimeStyleSet::handleParseName(const FieldsSet* /* inheritFrom */, co
}
}
#endif /*!UCONFIG_NO_FORMAT*/

View File

@ -8,6 +8,8 @@
#define FLDSET_H_
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/calendar.h"
#include "unicode/ucal.h"
#include "unicode/udat.h"
@ -180,5 +182,5 @@ class DateTimeStyleSet : public FieldsSet {
};
#endif /*!UCONFIG_NO_FORMAT*/
#endif /*FLDSET_H_*/

View File

@ -469,6 +469,8 @@ LocaleTest::TestDisplayNames()
UnicodeString s;
UErrorCode status = U_ZERO_ERROR;
#if !UCONFIG_NO_FORMATTING
DecimalFormatSymbols symb(status);
/* Check to see if ICU supports this locale */
if (symb.getLocale(ULOC_VALID_LOCALE, status) != Locale("root")) {
@ -494,6 +496,8 @@ LocaleTest::TestDisplayNames()
logln("Default locale %s is unsupported by ICU\n", Locale().getName());
}
s.remove();
#endif
french.getDisplayCountry(s);
if(s.isEmpty()) {
errln("unable to get any default-locale display string for the country of fr_FR\n");

View File

@ -421,12 +421,14 @@ StringCaseTest::TestCasingImpl(const UnicodeString &input,
utf8Out, (int32_t)sizeof(utf8Out),
utf8In, utf8InLength, &errorCode);
break;
#if !UCONFIG_NO_BREAK_ITERATION
case TEST_TITLE:
name="ucasemap_utf8ToTitle";
utf8OutLength=ucasemap_utf8ToTitle(csm,
utf8Out, (int32_t)sizeof(utf8Out),
utf8In, utf8InLength, &errorCode);
break;
#endif
case TEST_FOLD:
name="ucasemap_utf8FoldCase";
utf8OutLength=ucasemap_utf8FoldCase(csm,

View File

@ -86,8 +86,7 @@ T_CTEST_API const UnicodeString& T_CTEST_EXPORT2 udbg_enumString(UDebugEnumType
//fflush(stderr);
if(field<0 || field > count) {
return strs[type][count];
} else {
return strs[type][field];
} else { return strs[type][field];
}
}

View File

@ -100,8 +100,6 @@ static const Field names_UDateFormatStyle[] =
#endif
#define LEN_UDBG 5 /* "UDBG_" */
static const int32_t count_UDebugEnumType = UDBG_ENUM_COUNT;
@ -121,6 +119,16 @@ static const Field names_UDebugEnumType[] =
#define FIELD_CASE(x) case UDBG_##x: return names_##x;
#define FIELD_FAIL_CASE(x) case UDBG_##x: return NULL;
#else
#define COUNT_CASE(x)
#define COUNT_FAIL_CASE(x)
#define FIELD_CASE(X)
#define FIELD_FAIL_CASE(x)
#endif
// low level
/**