summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu-xetex/test/cintltst
diff options
context:
space:
mode:
authorJonathan Kew <jfkthame@googlemail.com>2007-11-21 12:29:46 +0000
committerJonathan Kew <jfkthame@googlemail.com>2007-11-21 12:29:46 +0000
commit952d69f85d43b087ce9fa79d3fc6f1c076000bc7 (patch)
treedd6937a6486e80e1638618308481075efab000ae /Build/source/libs/icu-xetex/test/cintltst
parent888236cb9df7b7d7b5a3e2d784037a9a59511c53 (diff)
updated icu-xetex library for XeTeX 0.997
git-svn-id: svn://tug.org/texlive/trunk@5536 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/icu-xetex/test/cintltst')
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/Makefile.in28
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/bocu1tst.c4
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/callcoll.c27
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/callcoll.h6
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/calltest.c6
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/capitst.c87
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cbiapts.c8
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cbiditst.c1754
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/ccaltst.c62
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/ccapitst.c326
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cdattst.c26
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cdtdptst.c23
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cdtrgtst.c90
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/chashtst.c8
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cintltst.vcproj11
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cldrtest.c179
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cloctst.c372
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cloctst.h17
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cmsccoll.c118
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cmsgtst.c26
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cnmdptst.c48
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cnumtst.c49
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/crestst.c82
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/creststn.c392
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/creststn.h17
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cstrcase.c41
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cucdapi.c61
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cucdtst.c236
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cucdtst.h28
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/currtest.c7
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/custrtrn.c421
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/custrtst.c49
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cutiltst.c4
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/eurocreg.c9
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/hpmufn.c53
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/nccbtst.c164
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/ncnvfbts.c32
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/ncnvtst.c262
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/nfsprep.c42
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/nucnvtst.c346
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/putiltst.c9
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/reapits.c69
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/spreptst.c58
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/stdnmtst.c21
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/tracetst.c9
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/ucmptst.c201
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/ucsdetst.c356
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/udatatst.c277
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/utexttst.c10
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/utf8tst.c133
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/utmstest.c146
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/utransts.c9
52 files changed, 5453 insertions, 1366 deletions
diff --git a/Build/source/libs/icu-xetex/test/cintltst/Makefile.in b/Build/source/libs/icu-xetex/test/cintltst/Makefile.in
index dbc74f5381c..490f9220503 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/Makefile.in
+++ b/Build/source/libs/icu-xetex/test/cintltst/Makefile.in
@@ -1,6 +1,10 @@
+#******************************************************************************
+#
+# Copyright (C) 1999-2006, International Business Machines
+# Corporation and others. All Rights Reserved.
+#
+#******************************************************************************
## Makefile.in for ICU - test/cintltst
-## Copyright (c) 1999-2005, International Business Machines Corporation and
-## others. All Rights Reserved.
## Source directory information
srcdir = @srcdir@
@@ -8,6 +12,7 @@ top_srcdir = @top_srcdir@
top_builddir = ../..
+## All the flags and other definitions are included here.
include $(top_builddir)/icudefs.mk
## Build directory information
@@ -20,8 +25,8 @@ CLEANFILES = *~ $(DEPS)
TARGET = cintltst$(EXEEXT)
# Oh, this hurts my sensibility. This is supposedly a C test and we need to
-# link using a C++ compiler?! This must be done so that C++ static
-# initialization works in the libraries, like mutex.cpp, ustdio and iostream.
+# link using a C++ compiler?! This must be done so that library vtables
+# work correctly on all platforms.
ifneq ($(ENABLE_STATIC),)
LINK = $(LINK.cc)
@@ -37,8 +42,11 @@ BUILDDIR := $(BUILDDIR:test\\cintltst/../../=)
# Simplify the path for Windows 98
BUILDDIR := $(BUILDDIR:TEST\\CINTLTST/../../=)
+ifneq ($(top_builddir),$(top_srcdir))
+CPPFLAGS += -I$(top_builddir)/common
+endif
# we define ICU_UNICODE_VERSION so we can test it
-CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil
+CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil
DEFS += -D'ICU_UNICODE_VERSION="$(UNICODE_VERSION)"' -D'ICU_VERSION="@VERSION@"' -D'ICUDATA_NAME="$(ICUDATA_PLATFORM_NAME)"' -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUUC) $(LIBICUTOOLUTIL) $(DEFAULT_LIBS) $(LIB_M)
@@ -50,13 +58,16 @@ cmsccoll.o cmsgtst.o cposxtst.o cldrtest.o \
cnmdptst.o cnormtst.o cnumtst.o crestst.o creststn.o cturtst.o \
cucdapi.o cucdtst.o custrtst.o cstrcase.o cutiltst.o nucnvtst.o nccbtst.o bocu1tst.o \
cbiditst.o cbididat.o eurocreg.o udatatst.o utf16tst.o utransts.o \
-ncnvfbts.o ncnvtst.o putiltst.o cstrtest.o utf8tst.o ucmptst.o \
+ncnvfbts.o ncnvtst.o putiltst.o cstrtest.o utf8tst.o \
stdnmtst.o ctstdep.o usrchtst.o custrtrn.o sorttest.o trietest.o usettest.o \
uenumtst.o utmstest.o currtest.o \
-idnatest.o nfsprep.o spreptst.o sprpdata.o hpmufn.o tracetst.o reapits.o utexttst.o
+idnatest.o nfsprep.o spreptst.o sprpdata.o \
+hpmufn.o tracetst.o reapits.o utexttst.o ucsdetst.o
DEPS = $(OBJECTS:.o=.d)
+-include Makefile.local
+
## List of phony targets
.PHONY : all all-local install install-local clean clean-local \
distclean distclean-local dist dist-local check check-local
@@ -85,8 +96,6 @@ clean-local:
distclean-local: clean-local
$(RMV) Makefile
--include Makefile.local
-
check-local: all-local
$(INVOKE) ./$(TARGET) $(CINTLTST_OPTS)
@@ -106,3 +115,4 @@ ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
endif
endif
endif
+
diff --git a/Build/source/libs/icu-xetex/test/cintltst/bocu1tst.c b/Build/source/libs/icu-xetex/test/cintltst/bocu1tst.c
index f15d6eb02f6..0679752d272 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/bocu1tst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/bocu1tst.c
@@ -1,7 +1,7 @@
/*
******************************************************************************
*
-* Copyright (C) 2002-2003, International Business Machines
+* Copyright (C) 2002-2005, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@@ -15,7 +15,7 @@
*
* This is the reference implementation of BOCU-1,
* the MIME-friendly form of the Binary Ordered Compression for Unicode,
-* taken directly from ### http://oss.software.ibm.com/cvs/icu/icuhtml/design/conversion/bocu1/
+* taken directly from ### http://dev.icu-project.org/cgi-bin/viewcvs.cgi/icuhtml/design/conversion/bocu1/
* The files bocu1.h and bocu1.c from the design folder are taken
* verbatim (minus copyright and #include) and copied together into this file.
* The reference code and some of the reference bocu1tst.c
diff --git a/Build/source/libs/icu-xetex/test/cintltst/callcoll.c b/Build/source/libs/icu-xetex/test/cintltst/callcoll.c
index 9d33828e28f..f57dc605a64 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/callcoll.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/callcoll.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -335,7 +335,8 @@ static void doTestVariant(UCollator* myCollation, const UChar source[], const UC
partialSKResult = compareUsingPartials(myCollation, source, sLen, target, tLen, partialSizes[i], &status);
if(partialSKResult != result) {
- log_err("Partial sortkey comparison returned wrong result: %s, %s (size %i)\n",
+ log_err("Partial sortkey comparison returned wrong result (%i exp. %i): %s, %s (size %i)\n",
+ partialSKResult, result,
aescstrdup(source,-1), aescstrdup(target,-1), partialSizes[i]);
}
@@ -608,9 +609,8 @@ void genericLocaleStarterWithResult(const char *locale, const char *s[], uint32_
ucol_close(coll);
}
-#if 0
/* currently not used with options */
-void genericRulesStarterWithOptions(const char *rules, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize) {
+void genericRulesStarterWithOptionsAndResult(const char *rules, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize, UCollationResult result) {
UErrorCode status = U_ZERO_ERROR;
UChar rlz[RULE_BUFFER_LEN] = { 0 };
uint32_t rlen = u_unescape(rules, rlz, RULE_BUFFER_LEN);
@@ -626,15 +626,14 @@ void genericRulesStarterWithOptions(const char *rules, const char *s[], uint32_t
ucol_setAttribute(coll, attrs[i], values[i], &status);
}
- genericOrderingTest(coll, s, size);
+ genericOrderingTestWithResult(coll, s, size, result);
} else {
log_err("Unable to open collator with rules %s\n", rules);
}
ucol_close(coll);
}
-#endif
-void genericLocaleStarterWithOptions(const char *locale, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize) {
+void genericLocaleStarterWithOptionsAndResult(const char *locale, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize, UCollationResult result) {
UErrorCode status = U_ZERO_ERROR;
uint32_t i;
@@ -649,14 +648,18 @@ void genericLocaleStarterWithOptions(const char *locale, const char *s[], uint32
ucol_setAttribute(coll, attrs[i], values[i], &status);
}
- genericOrderingTest(coll, s, size);
+ genericOrderingTestWithResult(coll, s, size, result);
} else {
log_err("Unable to open collator for locale %s\n", locale);
}
ucol_close(coll);
}
-void genericRulesTestWithResult(const char *rules, const char *s[], uint32_t size, UCollationResult result) {
+void genericLocaleStarterWithOptions(const char *locale, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize) {
+ genericLocaleStarterWithOptionsAndResult(locale, s, size, attrs, values, attsize, UCOL_LESS);
+}
+
+void genericRulesStarterWithResult(const char *rules, const char *s[], uint32_t size, UCollationResult result) {
UErrorCode status = U_ZERO_ERROR;
UChar rlz[RULE_BUFFER_LEN] = { 0 };
uint32_t rlen = u_unescape(rules, rlz, RULE_BUFFER_LEN);
@@ -676,7 +679,7 @@ void genericRulesTestWithResult(const char *rules, const char *s[], uint32_t siz
}
void genericRulesStarter(const char *rules, const char *s[], uint32_t size) {
- genericRulesTestWithResult(rules, s, size, UCOL_LESS);
+ genericRulesStarterWithResult(rules, s, size, UCOL_LESS);
}
static void TestTertiary()
@@ -856,10 +859,8 @@ static void TestJB581(void)
/* Now, do the same comparison with keys */
sourceKeyOut = ucol_getSortKey(myCollator, source, -1, sourceKeyArray, 100);
targetKeyOut = ucol_getSortKey(myCollator, target, -1, targetKeyArray, 100);
- result = 0;
bufferLen = ((targetKeyOut > 100) ? 100 : targetKeyOut);
- result = memcmp(sourceKeyArray, targetKeyArray, bufferLen);
- if (result != 0)
+ if (memcmp(sourceKeyArray, targetKeyArray, bufferLen) != 0)
{
log_err("Comparing two strings with sort keys in C failed.\n");
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/callcoll.h b/Build/source/libs/icu-xetex/test/cintltst/callcoll.h
index 70cf316ab7c..af2cd940dba 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/callcoll.h
+++ b/Build/source/libs/icu-xetex/test/cintltst/callcoll.h
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -42,8 +42,10 @@ void genericOrderingTest(UCollator *coll, const char *s[], uint32_t size);
void genericLocaleStarter(const char *locale, const char *s[], uint32_t size);
void genericLocaleStarterWithResult(const char *locale, const char *s[], uint32_t size, UCollationResult result);
void genericLocaleStarterWithOptions(const char *locale, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize);
-void genericRulesTestWithResult(const char *rules, const char *s[], uint32_t size, UCollationResult result);
+void genericLocaleStarterWithOptionsAndResult(const char *locale, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize, UCollationResult result);
+void genericRulesStarterWithResult(const char *rules, const char *s[], uint32_t size, UCollationResult result);
void genericRulesStarter(const char *rules, const char *s[], uint32_t size);
+void genericRulesStarterWithOptionsAndResult(const char *rules, const char *s[], uint32_t size, const UColAttribute *attrs, const UColAttributeValue *values, uint32_t attsize, UCollationResult result);
UBool hasCollationElements(const char *locName);
diff --git a/Build/source/libs/icu-xetex/test/cintltst/calltest.c b/Build/source/libs/icu-xetex/test/cintltst/calltest.c
index 3740b40e5c0..b9dc71875af 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/calltest.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/calltest.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1996-2005, International Business Machines Corporation and
+ * Copyright (c) 1996-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -28,7 +28,6 @@ void addUTF16Test(TestNode** root);
void addUTF8Test(TestNode** root);
void addUTransTest(TestNode** root);
void addPUtilTest(TestNode** root);
-void addCompactArrayTest(TestNode** root);
void addTestDeprecatedAPI(TestNode** root);
void addUCharTransformTest(TestNode** root);
void addUSetTest(TestNode** root);
@@ -38,6 +37,7 @@ void addHeapMutexTest(TestNode **root);
void addUTraceTest(TestNode** root);
void addURegexTest(TestNode** root);
void addUTextTest(TestNode** root);
+void addUCsdetTest(TestNode** root);
void addAllTests(TestNode** root)
@@ -50,7 +50,6 @@ void addAllTests(TestNode** root)
addConvert(root);
addUCharTransformTest(root);
addStandardNamesTest(root);
- addCompactArrayTest(root);
#if !UCONFIG_NO_FORMATTING
addFormatTest(root);
#endif
@@ -76,5 +75,6 @@ void addAllTests(TestNode** root)
addURegexTest(root);
#endif
addUTextTest(root);
+ addUCsdetTest(root);
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/capitst.c b/Build/source/libs/icu-xetex/test/cintltst/capitst.c
index b43f4cefef6..b989eef8d62 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/capitst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/capitst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -281,9 +281,12 @@ void TestProperty()
ICU 2.4 currVersionArray = {0x21, 0x40, 0x04, 0x04};
ICU 2.6 currVersionArray = {0x21, 0x40, 0x03, 0x03};
ICU 2.8 currVersionArray = {0x29, 0x80, 0x00, 0x04};
+ ICU 3.4 currVersionArray = {0x31, 0xC0, 0x00, 0x04};
*/
- UVersionInfo currVersionArray = {0x31, 0xC0, 0x00, 0x04};
- UVersionInfo currUCAVersionArray = {4, 1, 0, 0};
+ UVersionInfo currVersionArray = {0x31, 0xC0, 0x00, 0x05};
+ /* ICU 3.4 had UCA 4.1 */
+ /*UVersionInfo currUCAVersionArray = {4, 1, 0, 0};*/
+ UVersionInfo currUCAVersionArray = {5, 0, 0, 0};
UVersionInfo versionArray = {0, 0, 0, 0};
UVersionInfo versionUCAArray = {0, 0, 0, 0};
@@ -637,11 +640,13 @@ void TestDecomposition() {
ucol_close(vi_VN);
}
-#define CLONETEST_COLLATOR_COUNT 3
+#define CLONETEST_COLLATOR_COUNT 4
void TestSafeClone() {
UChar* test1;
UChar* test2;
+ static const UChar umlautUStr[] = {0x00DC, 0};
+ static const UChar oeStr[] = {0x0055, 0x0045, 0};
UCollator * someCollators [CLONETEST_COLLATOR_COUNT];
UCollator * someClonedCollators [CLONETEST_COLLATOR_COUNT];
UCollator * col;
@@ -649,6 +654,8 @@ void TestSafeClone() {
int8_t testSize = 6; /* Leave this here to test buffer alingment in memory*/
uint8_t buffer [CLONETEST_COLLATOR_COUNT] [U_COL_SAFECLONE_BUFFERSIZE];
int32_t bufferSize = U_COL_SAFECLONE_BUFFERSIZE;
+ const char sampleRuleChars[] = "&Z < CH";
+ UChar sampleRule[sizeof(sampleRuleChars)];
int index;
if (TestBufferSize()) {
@@ -660,14 +667,16 @@ void TestSafeClone() {
test2=(UChar*)malloc(sizeof(UChar) * testSize);
u_uastrcpy(test1, "abCda");
u_uastrcpy(test2, "abcda");
+ u_uastrcpy(sampleRule, sampleRuleChars);
/* one default collator & two complex ones */
someCollators[0] = ucol_open("en_US", &err);
someCollators[1] = ucol_open("ko", &err);
someCollators[2] = ucol_open("ja_JP", &err);
+ someCollators[3] = ucol_openRules(sampleRule, -1, UCOL_ON, UCOL_TERTIARY, NULL, &err);
if(U_FAILURE(err)) {
- log_data_err("Couldn't open one or more collators\n");
- return;
+ log_data_err("Couldn't open one or more collators\n");
+ return;
}
/* Check the various error & informational states: */
@@ -736,23 +745,60 @@ void TestSafeClone() {
err = U_ZERO_ERROR;
+ /* Test that a cloned collator doesn't accidentally use UCA. */
+ col=ucol_open("de@collation=phonebook", &err);
+ bufferSize = U_COL_SAFECLONE_BUFFERSIZE;
+ someClonedCollators[0] = ucol_safeClone(col, buffer[0], &bufferSize, &err);
+ doAssert( (ucol_greater(col, umlautUStr, u_strlen(umlautUStr), oeStr, u_strlen(oeStr))), "Original German phonebook collation sorts differently than expected");
+ doAssert( (ucol_greater(someClonedCollators[0], umlautUStr, u_strlen(umlautUStr), oeStr, u_strlen(oeStr))), "Cloned German phonebook collation sorts differently than expected");
+ if (!ucol_equals(someClonedCollators[0], col)) {
+ log_err("FAIL: Cloned German phonebook collator is not equal to original.\n");
+ }
+ ucol_close(col);
+ ucol_close(someClonedCollators[0]);
+
+ err = U_ZERO_ERROR;
+
/* change orig & clone & make sure they are independent */
for (index = 0; index < CLONETEST_COLLATOR_COUNT; index++)
{
+ ucol_setStrength(someCollators[index], UCOL_IDENTICAL);
+ bufferSize = 1;
+ err = U_ZERO_ERROR;
+ ucol_close(ucol_safeClone(someCollators[index], buffer[index], &bufferSize, &err));
+ if (err != U_SAFECLONE_ALLOCATED_WARNING) {
+ log_err("FAIL: collator number %d was not allocated.\n", index);
+ }
+
bufferSize = U_COL_SAFECLONE_BUFFERSIZE;
+ err = U_ZERO_ERROR;
someClonedCollators[index] = ucol_safeClone(someCollators[index], buffer[index], &bufferSize, &err);
+ if (someClonedCollators[index] == NULL
+ || someClonedCollators[index] < (UCollator *)buffer[index]
+ || someClonedCollators[index] > (UCollator *)(buffer[index]+(U_COL_SAFECLONE_BUFFERSIZE-1)))
+ {
+ log_err("FAIL: Cloned collator didn't use provided buffer.\n");
+ return;
+ }
+ if (!ucol_equals(someClonedCollators[index], someCollators[index])) {
+ log_err("FAIL: Cloned collator is not equal to original at index = %d.\n", index);
+ }
- ucol_setStrength(someClonedCollators[index], UCOL_TERTIARY);
+ /* Check the usability */
ucol_setStrength(someCollators[index], UCOL_PRIMARY);
- ucol_setAttribute(someClonedCollators[index], UCOL_CASE_LEVEL, UCOL_OFF, &err);
ucol_setAttribute(someCollators[index], UCOL_CASE_LEVEL, UCOL_OFF, &err);
- doAssert( (ucol_greater(someClonedCollators[index], test1, u_strlen(test1), test2, u_strlen(test2))), "Result should be \"abCda\" >>> \"abcda\" ");
doAssert( (ucol_equal(someCollators[index], test1, u_strlen(test1), test2, u_strlen(test2))), "Result should be \"abcda\" == \"abCda\"");
- ucol_close(someClonedCollators[index]);
+ /* Close the original to make sure that the clone is usable. */
ucol_close(someCollators[index]);
+
+ ucol_setStrength(someClonedCollators[index], UCOL_TERTIARY);
+ ucol_setAttribute(someClonedCollators[index], UCOL_CASE_LEVEL, UCOL_OFF, &err);
+ doAssert( (ucol_greater(someClonedCollators[index], test1, u_strlen(test1), test2, u_strlen(test2))), "Result should be \"abCda\" >>> \"abcda\" ");
+
+ ucol_close(someClonedCollators[index]);
}
free(test1);
free(test2);
@@ -818,10 +864,12 @@ void TestSortKey()
{
uint8_t *sortk1 = NULL, *sortk2 = NULL, *sortk3 = NULL, *sortkEmpty = NULL;
uint8_t sortk2_compat[] = {
- /* 3.4 key, UCA 4.1 */
- 0x28, 0x2a, 0x2c, 0x2e, 0x28, 0x01,
- 0x09, 0x01, 0x09, 0x01, 0x27, 0x01,
- 0x92, 0x93, 0x94, 0x95, 0x92, 0x00
+ /* 3.6 key, from UCA 5.0 */
+ 0x29, 0x2b, 0x2d, 0x2f, 0x29, 0x01,
+ 0x09, 0x01, 0x09, 0x01, 0x28, 0x01,
+ 0x92, 0x93, 0x94, 0x95, 0x92, 0x00
+ /* 3.4 key, from UCA 4.1 */
+ /* 0x28, 0x2a, 0x2c, 0x2e, 0x28, 0x01, 0x09, 0x01, 0x09, 0x01, 0x27, 0x01, 0x92, 0x93, 0x94, 0x95, 0x92, 0x00 */
/* 2.6.1 key */
/* 0x26, 0x28, 0x2A, 0x2C, 0x26, 0x01, 0x09, 0x01, 0x09, 0x01, 0x25, 0x01, 0x92, 0x93, 0x94, 0x95, 0x92, 0x00 */
/* 2.2 key */
@@ -1788,7 +1836,7 @@ static void TestShortString(void)
int32_t expectedOffset;
uint32_t expectedIdentifier;
} testCases[] = {
- {"LDE_RDE_KPHONEBOOK_T0041_ZLATN","B2800_KPHONEBOOK_LDE", "de@collation=phonebook", U_USING_FALLBACK_WARNING, 0, 0 },
+ {"LDE_RDE_KPHONEBOOK_T0041_ZLATN","B2900_KPHONEBOOK_LDE", "de@collation=phonebook", U_USING_FALLBACK_WARNING, 0, 0 },
{"LEN_RUS_NO_AS_S4","AS_LEN_NO_S4", NULL, U_USING_FALLBACK_WARNING, 0, 0 },
{"LDE_VPHONEBOOK_EO_SI","EO_KPHONEBOOK_LDE_SI", "de@collation=phonebook", U_ZERO_ERROR, 0, 0 },
{"LDE_Kphonebook","KPHONEBOOK_LDE", "de@collation=phonebook", U_ZERO_ERROR, 0, 0 },
@@ -2043,7 +2091,14 @@ TestOpenBinary(void)
uint8_t *image = imageBuffer;
int32_t imageBufferCapacity = 32768;
- int32_t imageSize = ucol_cloneBinary(coll, image, imageBufferCapacity, &status);
+ int32_t imageSize;
+
+ if((coll==NULL)||(UCA==NULL)||(U_FAILURE(status))) {
+ log_data_err("could not load collators or error occured: %s\n",
+ u_errorName(status));
+ return;
+ }
+ imageSize = ucol_cloneBinary(coll, image, imageBufferCapacity, &status);
if(U_FAILURE(status)) {
image = (uint8_t *)malloc(imageSize*sizeof(uint8_t));
status = U_ZERO_ERROR;
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cbiapts.c b/Build/source/libs/icu-xetex/test/cintltst/cbiapts.c
index 45e2389607b..fe597ae1857 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cbiapts.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cbiapts.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -190,11 +190,11 @@ static void TestBreakIteratorCAPI()
/*trying to open an illegal iterator*/
bogus = ubrk_open((UBreakIteratorType)5, "en_US", text, u_strlen(text), &status);
if(U_SUCCESS(status)){
- log_err("FAIL: Error in ubrk_open() for BOGUS breakiterator. Expected U_MEMORY_ALLOCATION_ERROR\n");
+ log_err("FAIL: Error in ubrk_open() for BOGUS breakiterator. Expected U_ILLEGAL_ARGUMENT_ERROR\n");
}
if(U_FAILURE(status)){
- if(status != U_MEMORY_ALLOCATION_ERROR){
- log_err("FAIL: Error in ubrk_open() for BOGUS breakiterator. Expected U_MEMORY_ALLOCATION_ERROR\n Got %s\n", myErrorName(status));
+ if(status != U_ILLEGAL_ARGUMENT_ERROR){
+ log_err("FAIL: Error in ubrk_open() for BOGUS breakiterator. Expected U_ILLEGAL_ARGUMENT_ERROR\n Got %s\n", myErrorName(status));
}
}
status=U_ZERO_ERROR;
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cbiditst.c b/Build/source/libs/icu-xetex/test/cintltst/cbiditst.c
index 7767bd820fe..bf7dab2d74e 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cbiditst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cbiditst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* file name: cbiditst.cpp
@@ -18,10 +18,12 @@
#include "unicode/ustring.h"
#include "unicode/ubidi.h"
#include "unicode/ushape.h"
-#include "cmemory.h"
#include "cbiditst.h"
#include "cstring.h"
+/* the following include is needed for sprintf */
+#include <stdio.h>
+#define MAXLEN MAX_STRING_LENGTH
#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
/* prototypes ---------------------------------------------------------------*/
@@ -71,6 +73,25 @@ static void TestFailureRecovery(void);
static void TestMultipleParagraphs(void);
+/* new BIDI API */
+static void doReorderingModeBidiTest(void);
+static void doReorderRunsTest(void);
+static void doBidiStreamingTest(void);
+static void doBidiClassOverrideTest(void);
+static const char* inverseBasic(UBiDi *pBiDi, const UChar *src, int32_t srcLen,
+ uint32_t option, UBiDiLevel level, char *result);
+static UBool assertRoundTrip(UBiDi *pBiDi, int32_t tc, int32_t outIndex,
+ const char *srcChars, const char *destChars,
+ const UChar *dest, int32_t destLen, int mode,
+ int option, UBiDiLevel level);
+static UBool checkResultLength(UBiDi *pBiDi, const char *srcChars,
+ const char *destChars, const UChar *dest,
+ int32_t destLen, const char *mode,
+ const char *option, UBiDiLevel level);
+static UBool testMaps(UBiDi *pBiDi, int32_t stringIndex, const char *src,
+ const char *dest, const char *mode, const char* option,
+ UBiDiLevel level, UBool forward);
+
/* helpers ------------------------------------------------------------------ */
static const char *levelString="...............................................................";
@@ -79,7 +100,7 @@ static void
initCharFromDirProps(void);
static UChar *
-getStringFromDirProps(const uint8_t *dirProps, int32_t length);
+getStringFromDirProps(const uint8_t *dirProps, int32_t length, UChar *buffer);
static void
printUnicode(const UChar *s, int32_t length, const UBiDiLevel *levels);
@@ -96,6 +117,11 @@ addComplexTest(TestNode** root) {
addTest(root, TestReorder,"complex/bidi/TestReorder");
addTest(root, TestFailureRecovery,"complex/bidi/TestFailureRecovery");
addTest(root, TestMultipleParagraphs,"complex/bidi/multipleParagraphs");
+ addTest(root, doReorderingModeBidiTest, "complex/bidi/TestReorderingMode");
+ addTest(root, doReorderRunsTest, "complex/bidi/TestReorderRunsOnly");
+ addTest(root, doBidiStreamingTest, "complex/bidi/TestStreamingMode");
+ addTest(root, doBidiClassOverrideTest, "complex/bidi/TestClassOverride");
+
addTest(root, doArabicShapingTest, "complex/arabic-shaping/ArabicShapingTest");
addTest(root, doLamAlefSpecialVLTRArabicShapingTest, "complex/arabic-shaping/lamalef");
addTest(root, doTashkeelSpecialVLTRArabicShapingTest, "complex/arabic-shaping/tashkeel");
@@ -111,7 +137,7 @@ charFromDirPropTest(void) {
for(i=0; i<U_CHAR_DIRECTION_COUNT; ++i) {
if(u_charDirection(charFromDirProp[i])!=(UCharDirection)i) {
- log_err("u_charDirection(charFromDirProp[%d]=U+%04x)==%d!=%d\n",
+ log_err("\nu_charDirection(charFromDirProp[%d]=U+%04x)==%d!=%d\n",
i, charFromDirProp[i], u_charDirection(charFromDirProp[i]), i);
}
}
@@ -122,9 +148,9 @@ doBiDiTest() {
UBiDi *pBiDi, *pLine=NULL;
UErrorCode errorCode=U_ZERO_ERROR;
- log_verbose("*** bidi regression test ***\n");
+ log_verbose("\n*** bidi regression test ***\n");
- pBiDi=ubidi_openSized(MAX_STRING_LENGTH, 0, &errorCode);
+ pBiDi=ubidi_openSized(MAXLEN, 0, &errorCode);
if(pBiDi!=NULL) {
pLine=ubidi_open();
if(pLine!=NULL) {
@@ -144,22 +170,22 @@ doBiDiTest() {
ubidi_close(pBiDi);
}
- log_verbose("*** bidi regression test finished ***\n");
+ log_verbose("\n*** bidi regression test finished ***\n");
}
static void
doTests(UBiDi *pBiDi, UBiDi *pLine, UBool countRunsFirst) {
int i;
- UChar *s;
+ UChar string[MAXLEN];
UErrorCode errorCode;
int32_t lineStart;
UBiDiLevel paraLevel;
for(i=0; i<bidiTestCount; ++i) {
errorCode=U_ZERO_ERROR;
- s=getStringFromDirProps(tests[i].text, tests[i].length);
+ getStringFromDirProps(tests[i].text, tests[i].length, string);
paraLevel=tests[i].paraLevel;
- ubidi_setPara(pBiDi, s, -1, paraLevel, NULL, &errorCode);
+ ubidi_setPara(pBiDi, string, -1, paraLevel, NULL, &errorCode);
if(U_SUCCESS(errorCode)) {
log_verbose("ubidi_setPara(tests[%d], paraLevel %d) ok, direction %d paraLevel=%d\n",
i, paraLevel, ubidi_getDirection(pBiDi), ubidi_getParaLevel(pBiDi));
@@ -183,102 +209,268 @@ doTests(UBiDi *pBiDi, UBiDi *pLine, UBool countRunsFirst) {
}
}
}
+
+static const char columns[62] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+#define TABLE_SIZE 256
+static UBool tablesInitialized = FALSE;
+static UChar pseudoToUChar[TABLE_SIZE];
+static uint8_t UCharToPseudo[TABLE_SIZE]; /* used for Unicode chars < 0x0100 */
+static uint8_t UCharToPseud2[TABLE_SIZE]; /* used for Unicode chars >=0x0100 */
+
+static void buildPseudoTables(void)
+/*
+ The rules for pseudo-Bidi are as follows:
+ - [ == LRE
+ - ] == RLE
+ - { == LRO
+ - } == RLO
+ - ^ == PDF
+ - @ == LRM
+ - & == RLM
+ - A-F == Arabic Letters 0631-0636
+ - G-Z == Hebrew letters 05d7-05ea
+ - 0-5 == western digits 0030-0035
+ - 6-9 == Arabic-Indic digits 0666-0669
+ - ` == Combining Grave Accent 0300 (NSM)
+ - ~ == Delete 007f (BN)
+ - | == Paragraph Separator 2029 (B)
+ - _ == Info Separator 1 001f (S)
+ All other characters represent themselves as Latin-1, with the corresponding
+ Bidi properties.
+*/
+{
+ int i;
+ UChar uchar;
+ uint8_t c;
+ /* initialize all tables to unknown */
+ for (i=0; i < TABLE_SIZE; i++) {
+ pseudoToUChar[i] = 0xFFFD;
+ UCharToPseudo[i] = '?';
+ UCharToPseud2[i] = '?';
+ }
+ /* initialize non letters or digits */
+ pseudoToUChar[(uint8_t) 0 ] = 0x0000; UCharToPseudo[0x00] = (uint8_t) 0 ;
+ pseudoToUChar[(uint8_t)' '] = 0x0020; UCharToPseudo[0x20] = (uint8_t)' ';
+ pseudoToUChar[(uint8_t)'!'] = 0x0021; UCharToPseudo[0x21] = (uint8_t)'!';
+ pseudoToUChar[(uint8_t)'"'] = 0x0022; UCharToPseudo[0x22] = (uint8_t)'"';
+ pseudoToUChar[(uint8_t)'#'] = 0x0023; UCharToPseudo[0x23] = (uint8_t)'#';
+ pseudoToUChar[(uint8_t)'$'] = 0x0024; UCharToPseudo[0x24] = (uint8_t)'$';
+ pseudoToUChar[(uint8_t)'%'] = 0x0025; UCharToPseudo[0x25] = (uint8_t)'%';
+ pseudoToUChar[(uint8_t)'\'']= 0x0027; UCharToPseudo[0x27] = (uint8_t)'\'';
+ pseudoToUChar[(uint8_t)'('] = 0x0028; UCharToPseudo[0x28] = (uint8_t)'(';
+ pseudoToUChar[(uint8_t)')'] = 0x0029; UCharToPseudo[0x29] = (uint8_t)')';
+ pseudoToUChar[(uint8_t)'*'] = 0x002A; UCharToPseudo[0x2A] = (uint8_t)'*';
+ pseudoToUChar[(uint8_t)'+'] = 0x002B; UCharToPseudo[0x2B] = (uint8_t)'+';
+ pseudoToUChar[(uint8_t)','] = 0x002C; UCharToPseudo[0x2C] = (uint8_t)',';
+ pseudoToUChar[(uint8_t)'-'] = 0x002D; UCharToPseudo[0x2D] = (uint8_t)'-';
+ pseudoToUChar[(uint8_t)'.'] = 0x002E; UCharToPseudo[0x2E] = (uint8_t)'.';
+ pseudoToUChar[(uint8_t)'/'] = 0x002F; UCharToPseudo[0x2F] = (uint8_t)'/';
+ pseudoToUChar[(uint8_t)':'] = 0x003A; UCharToPseudo[0x3A] = (uint8_t)':';
+ pseudoToUChar[(uint8_t)';'] = 0x003B; UCharToPseudo[0x3B] = (uint8_t)';';
+ pseudoToUChar[(uint8_t)'<'] = 0x003C; UCharToPseudo[0x3C] = (uint8_t)'<';
+ pseudoToUChar[(uint8_t)'='] = 0x003D; UCharToPseudo[0x3D] = (uint8_t)'=';
+ pseudoToUChar[(uint8_t)'>'] = 0x003E; UCharToPseudo[0x3E] = (uint8_t)'>';
+ pseudoToUChar[(uint8_t)'?'] = 0x003F; UCharToPseudo[0x3F] = (uint8_t)'?';
+ pseudoToUChar[(uint8_t)'\\']= 0x005C; UCharToPseudo[0x5C] = (uint8_t)'\\';
+ /* initialize specially used characters */
+ pseudoToUChar[(uint8_t)'`'] = 0x0300; UCharToPseud2[0x00] = (uint8_t)'`'; /* NSM */
+ pseudoToUChar[(uint8_t)'@'] = 0x200E; UCharToPseud2[0x0E] = (uint8_t)'@'; /* LRM */
+ pseudoToUChar[(uint8_t)'&'] = 0x200F; UCharToPseud2[0x0F] = (uint8_t)'&'; /* RLM */
+ pseudoToUChar[(uint8_t)'_'] = 0x001F; UCharToPseudo[0x1F] = (uint8_t)'_'; /* S */
+ pseudoToUChar[(uint8_t)'|'] = 0x2029; UCharToPseud2[0x29] = (uint8_t)'|'; /* B */
+ pseudoToUChar[(uint8_t)'['] = 0x202A; UCharToPseud2[0x2A] = (uint8_t)'['; /* LRE */
+ pseudoToUChar[(uint8_t)']'] = 0x202B; UCharToPseud2[0x2B] = (uint8_t)']'; /* RLE */
+ pseudoToUChar[(uint8_t)'^'] = 0x202C; UCharToPseud2[0x2C] = (uint8_t)'^'; /* PDF */
+ pseudoToUChar[(uint8_t)'{'] = 0x202D; UCharToPseud2[0x2D] = (uint8_t)'{'; /* LRO */
+ pseudoToUChar[(uint8_t)'}'] = 0x202E; UCharToPseud2[0x2E] = (uint8_t)'}'; /* RLO */
+ pseudoToUChar[(uint8_t)'~'] = 0x007F; UCharToPseudo[0x7F] = (uint8_t)'~'; /* BN */
+ /* initialize western digits */
+ for (i = 0, uchar = 0x0030; i < 6; i++, uchar++) {
+ c = (uint8_t)columns[i];
+ pseudoToUChar[c] = uchar;
+ UCharToPseudo[uchar & 0x00ff] = c;
+ }
+ /* initialize Hindi digits */
+ for (i = 6, uchar = 0x0666; i < 10; i++, uchar++) {
+ c = (uint8_t)columns[i];
+ pseudoToUChar[c] = uchar;
+ UCharToPseud2[uchar & 0x00ff] = c;
+ }
+ /* initialize Arabic letters */
+ for (i = 10, uchar = 0x0631; i < 16; i++, uchar++) {
+ c = (uint8_t)columns[i];
+ pseudoToUChar[c] = uchar;
+ UCharToPseud2[uchar & 0x00ff] = c;
+ }
+ /* initialize Hebrew letters */
+ for (i = 16, uchar = 0x05D7; i < 36; i++, uchar++) {
+ c = (uint8_t)columns[i];
+ pseudoToUChar[c] = uchar;
+ UCharToPseud2[uchar & 0x00ff] = c;
+ }
+ /* initialize Latin lower case letters */
+ for (i = 36, uchar = 0x0061; i < 62; i++, uchar++) {
+ c = (uint8_t)columns[i];
+ pseudoToUChar[c] = uchar;
+ UCharToPseudo[uchar & 0x00ff] = c;
+ }
+ tablesInitialized = TRUE;
+}
+
+/*----------------------------------------------------------------------*/
+
+static int pseudoToU16( const int length, const char * input, UChar * output )
+/* This function converts a pseudo-Bidi string into a UChar string.
+ It returns the length of the UChar string.
+*/
+{
+ int i;
+ if (!tablesInitialized) {
+ buildPseudoTables();
+ }
+ for (i = 0; i < length; i++)
+ output[i] = pseudoToUChar[(uint8_t)input[i]];
+ return length;
+}
+
+/*----------------------------------------------------------------------*/
+
+static int u16ToPseudo( const int length, const UChar * input, char * output )
+/* This function converts a UChar string into a pseudo-Bidi string.
+ It returns the length of the pseudo-Bidi string.
+*/
+{
+ int i;
+ UChar uchar;
+ if (!tablesInitialized) {
+ buildPseudoTables();
+ }
+ for (i = 0; i < length; i++)
+ {
+ uchar = input[i];
+ output[i] = uchar < 0x0100 ? UCharToPseudo[uchar] :
+ UCharToPseud2[uchar & 0x00ff];
+ }
+ output[length] = '\0';
+ return length;
+}
+
+static char * formatLevels(UBiDi *bidi, char *buffer) {
+ UErrorCode ec = U_ZERO_ERROR;
+ const UBiDiLevel* gotLevels = ubidi_getLevels(bidi, &ec);
+ int len = ubidi_getLength(bidi);
+ char c;
+ int i, k;
+
+ if(U_FAILURE(ec)) {
+ strcpy(buffer, "BAD LEVELS");
+ return buffer;
+ }
+ for (i=0; i<len; i++) {
+ k = gotLevels[i];
+ if (k >= sizeof columns)
+ c = '+';
+ else
+ c = columns[k];
+ buffer[i] = c;
+ }
+ buffer[len] = '\0';
+ return buffer;
+}
+
static void TestReorder(){
static const char* const logicalOrder[] ={
- "DEL(\\u062F\\u0625)ADD(\\u062F.\\u0625.\\u200F)",
- "DEL(\\u0645\\u0627\\u064A\\u0648) ADD(\\u0623\\u064A\\u0627\\u0631)",
- "DEL(\\u0644\\u0644)ADD(\\u0644.\\u0644.\\u0029\\u0644)\\u0644.\\u200F",
- "DEL(\\u0631\\u064A)ADD(\\u0631.\\u064A.) \\u0631.\\u064A.\\u200F",
- "DAY 2 \\u0646 \\u0627\\u0644\\u0627\\u062B\\u0646\\u064A\\u0646 DAYABBR",
- "DAY 3 \\u062B \\u0627\\u0644\\u062B\\u0644\\u0627\\u062B\\u0627\\u0621 DAYABBR",
- "DAY 4 \\u0631 \\u0627\\u0644\\u0623\\u0631\\u0628\\u0639\\u0627\\u0621 DAYABBR",
- "DAY 5 \\u062E \\u0627\\u0644\\u062E\\u0645\\u064A\\u0633 DAYABBR",
- "DAY 6 \\u062C \\u0627\\u0644\\u062C\\u0645\\u0639\\u0629 DAYABBR",
- "DAY 7 \\u0633 \\u0627\\u0644\\u0633\\u0628\\u062A DAYABBR",
- "HELLO\\u0627\\u0644\\u0633\\u0628\\u062A",
+ "del(KC)add(K.C.&)",
+ "del(QDVT) add(BVDL)",
+ "del(PQ)add(R.S.)T)U.&",
+ "del(LV)add(L.V.) L.V.&",
+ "day 0 R DPDHRVR dayabbr",
+ "day 1 H DPHPDHDA dayabbr",
+ "day 2 L DPBLENDA dayabbr",
+ "day 3 J DPJQVM dayabbr",
+ "day 4 I DPIQNF dayabbr",
+ "day 5 M DPMEG dayabbr",
+ "helloDPMEG",
};
static const char* const visualOrder[]={
- "DEL(\\u0625\\u062F)ADD(\\u200F.\\u0625.\\u062F)",
- "DEL(\\u0648\\u064A\\u0627\\u0645) ADD(\\u0631\\u0627\\u064A\\u0623)",
- "DEL(\\u0644\\u0644)ADD(\\u0644\\u0029.\\u0644.\\u0644)\\u200F.\\u0644",
- /* I am doutful about this...
- * what I would expect is :
- * DEL(\\u064A\\u0631)ADD(.\\u064A.\\u0631) \\u200F.\\u064A.\\u0631
- */
- "DEL(\\u064A\\u0631)ADD(\\u200F.\\u064A.\\u0631 (.\\u064A.\\u0631",
- "DAY 2 \\u0646\\u064A\\u0646\\u062B\\u0627\\u0644\\u0627 \\u0646 DAYABBR",
- "DAY 3 \\u0621\\u0627\\u062B\\u0627\\u0644\\u062B\\u0644\\u0627 \\u062B DAYABBR",
- "DAY 4 \\u0621\\u0627\\u0639\\u0628\\u0631\\u0623\\u0644\\u0627 \\u0631 DAYABBR",
- "DAY 5 \\u0633\\u064A\\u0645\\u062E\\u0644\\u0627 \\u062E DAYABBR",
- "DAY 6 \\u0629\\u0639\\u0645\\u062C\\u0644\\u0627 \\u062C DAYABBR",
- "DAY 7 \\u062A\\u0628\\u0633\\u0644\\u0627 \\u0633 DAYABBR",
- "HELLO\\u062A\\u0628\\u0633\\u0644\\u0627",
+ "del(CK)add(&.C.K)",
+ "del(TVDQ) add(LDVB)",
+ "del(QP)add(&.U(T(.S.R",
+ "del(VL)add(&.V.L (.V.L",
+ "day 0 RVRHDPD R dayabbr",
+ "day 1 ADHDPHPD H dayabbr",
+ "day 2 ADNELBPD L dayabbr",
+ "day 3 MVQJPD J dayabbr",
+ "day 4 FNQIPD I dayabbr",
+ "day 5 GEMPD M dayabbr",
+ "helloGEMPD",
};
static const char* const visualOrder1[]={
- ")\\u062F.\\u0625.\\u200F(DDA)\\u062F\\u0625(LED",
- ")\\u0623\\u064A\\u0627\\u0631(DDA )\\u0645\\u0627\\u064A\\u0648(LED",
- "\\u0644.\\u0644.(\\u0644(\\u0644.\\u200F(DDA)\\u0644\\u0644(LED",
- "\\u0631.\\u064A.( \\u0631.\\u064A.\\u200F(DDA)\\u0631\\u064A(LED",
- "RBBAYAD \\u0646 \\u0627\\u0644\\u0627\\u062B\\u0646\\u064A\\u0646 2 YAD",
- "RBBAYAD \\u062B \\u0627\\u0644\\u062B\\u0644\\u0627\\u062B\\u0627\\u0621 3 YAD",
- "RBBAYAD \\u0631 \\u0627\\u0644\\u0623\\u0631\\u0628\\u0639\\u0627\\u0621 4 YAD",
- "RBBAYAD \\u062E \\u0627\\u0644\\u062E\\u0645\\u064A\\u0633 5 YAD",
- "RBBAYAD \\u062C \\u0627\\u0644\\u062C\\u0645\\u0639\\u0629 6 YAD",
- "RBBAYAD \\u0633 \\u0627\\u0644\\u0633\\u0628\\u062A 7 YAD",
- "\\u0627\\u0644\\u0633\\u0628\\u062AOLLEH",
+ ")K.C.&(dda)KC(led",
+ ")BVDL(dda )QDVT(led",
+ "R.S.(T(U.&(dda)PQ(led",
+ "L.V.( L.V.&(dda)LV(led",
+ "rbbayad R DPDHRVR 0 yad",
+ "rbbayad H DPHPDHDA 1 yad",
+ "rbbayad L DPBLENDA 2 yad",
+ "rbbayad J DPJQVM 3 yad",
+ "rbbayad I DPIQNF 4 yad",
+ "rbbayad M DPMEG 5 yad",
+ "DPMEGolleh",
};
static const char* const visualOrder2[]={
- "\\u200E)\\u200E\\u062F.\\u0625.\\u200F\\u200E(DDA)\\u200E\\u062F\\u0625\\u200E(LED",
- "\\u200E)\\u200E\\u0623\\u064A\\u0627\\u0631\\u200E(DDA )\\u200E\\u0645\\u0627\\u064A\\u0648\\u200E(LED",
- "\\u0644.\\u0644.)\\u0644)\\u0644.\\u200F\\u200E(DDA)\\u200E\\u0644\\u0644\\u200E(LED",
- "\\u0631.\\u064A.) \\u0631.\\u064A.\\u200F\\u200E(DDA)\\u200E\\u0631\\u064A\\u200E(LED",
- "RBBAYAD \\u200E\\u0646 \\u0627\\u0644\\u0627\\u062B\\u0646\\u064A\\u0646\\u200E 2 YAD",
- "RBBAYAD \\u200E\\u062B \\u0627\\u0644\\u062B\\u0644\\u0627\\u062B\\u0627\\u0621\\u200E 3 YAD",
- "RBBAYAD \\u200E\\u0631 \\u0627\\u0644\\u0623\\u0631\\u0628\\u0639\\u0627\\u0621\\u200E 4 YAD",
- "RBBAYAD \\u200E\\u062E \\u0627\\u0644\\u062E\\u0645\\u064A\\u0633\\u200E 5 YAD",
- "RBBAYAD \\u200E\\u062C \\u0627\\u0644\\u062C\\u0645\\u0639\\u0629\\u200E 6 YAD",
- "RBBAYAD \\u200E\\u0633 \\u0627\\u0644\\u0633\\u0628\\u062A\\u200E 7 YAD",
- "\\u0627\\u0644\\u0633\\u0628\\u062AOLLEH",
+ "@)@K.C.&@(dda)@KC@(led",
+ "@)@BVDL@(dda )@QDVT@(led",
+ "R.S.)T)U.&@(dda)@PQ@(led",
+ "L.V.) L.V.&@(dda)@LV@(led",
+ "rbbayad @R DPDHRVR@ 0 yad",
+ "rbbayad @H DPHPDHDA@ 1 yad",
+ "rbbayad @L DPBLENDA@ 2 yad",
+ "rbbayad @J DPJQVM@ 3 yad",
+ "rbbayad @I DPIQNF@ 4 yad",
+ "rbbayad @M DPMEG@ 5 yad",
+ "DPMEGolleh",
};
static const char* const visualOrder3[]={
- ")\\u062F.\\u0625.\\u200F(DDA)\\u062F\\u0625(LED",
- ")\\u0623\\u064A\\u0627\\u0631(DDA )\\u0645\\u0627\\u064A\\u0648(LED",
- "\\u0644.\\u0644.)\\u0644)\\u0644.\\u200F(\\u0644\\u0644)DDA(LED",
- "\\u0631.\\u064A.) \\u0631.\\u064A.\\u200F(\\u0631\\u064A)DDA(LED",
- "RBBAYAD \\u0627\\u0644\\u0627\\u062B\\u0646\\u064A\\u0646 \\u0646 2 YAD",
- "RBBAYAD \\u0627\\u0644\\u062B\\u0644\\u0627\\u062B\\u0627\\u0621 \\u062B 3 YAD",
- "RBBAYAD \\u0627\\u0644\\u0623\\u0631\\u0628\\u0639\\u0627\\u0621 \\u0631 4 YAD",
- "RBBAYAD \\u0627\\u0644\\u062E\\u0645\\u064A\\u0633 \\u062E 5 YAD",
- "RBBAYAD \\u0627\\u0644\\u062C\\u0645\\u0639\\u0629 \\u062C",
- "RBBAYAD \\u0627\\u0644\\u0633\\u0628\\u062A \\u0633 7 YAD",
- "\\u0627\\u0644\\u0633\\u0628\\u062AOLLEH"
+ ")K.C.&(KC)dda(led",
+ ")BVDL(ddaQDVT) (led",
+ "R.S.)T)U.&(PQ)dda(led",
+ "L.V.) L.V.&(LV)dda(led",
+ "rbbayad DPDHRVR R 0 yad",
+ "rbbayad DPHPDHDA H 1 yad",
+ "rbbayad DPBLENDA L 2 yad",
+ "rbbayad DPJQVM J 3 yad",
+ "rbbayad DPIQNF I 4 yad",
+ "rbbayad DPMEG M 5 yad",
+ "DPMEGolleh"
};
static const char* const visualOrder4[]={
- "DEL(ADD(\\u0625\\u062F(.\\u0625.\\u062F)",
- "DEL( (\\u0648\\u064A\\u0627\\u0645ADD(\\u0631\\u0627\\u064A\\u0623)",
- "DEL(ADD(\\u0644\\u0644(.\\u0644(\\u0644(.\\u0644.\\u0644",
- "DEL(ADD(\\u064A\\u0631(.\\u064A.\\u0631 (.\\u064A.\\u0631",
- "DAY 2 \\u0646 \\u0646\\u064A\\u0646\\u062B\\u0627\\u0644\\u0627 DAYABBR",
- "DAY 3 \\u062B \\u0621\\u0627\\u062B\\u0627\\u0644\\u062B\\u0644\\u0627 DAYABBR",
- "DAY 4 \\u0631 \\u0621\\u0627\\u0639\\u0628\\u0631\\u0623\\u0644\\u0627 DAYABBR",
- "DAY 5 \\u062E \\u0633\\u064A\\u0645\\u062E\\u0644\\u0627 DAYABBR",
- "DAY 6 \\u062C \\u0629\\u0639\\u0645\\u062C\\u0644\\u0627 DAYABBR",
- "DAY 7 \\u0633 \\u062A\\u0628\\u0633\\u0644\\u0627 DAYABBR ",
- "HELLO\\u062A\\u0628\\u0633\\u0644\\u0627"
+ "del(add(CK(.C.K)",
+ "del( (TVDQadd(LDVB)",
+ "del(add(QP(.U(T(.S.R",
+ "del(add(VL(.V.L (.V.L",
+ "day 0 R RVRHDPD dayabbr",
+ "day 1 H ADHDPHPD dayabbr",
+ "day 2 L ADNELBPD dayabbr",
+ "day 3 J MVQJPD dayabbr",
+ "day 4 I FNQIPD dayabbr",
+ "day 5 M GEMPD dayabbr",
+ "helloGEMPD"
};
+ char formatChars[MAXLEN];
UErrorCode ec = U_ZERO_ERROR;
UBiDi* bidi = ubidi_open();
- int i=0;
- for(;i<(sizeof(logicalOrder)/sizeof(logicalOrder[0]));i++){
- int32_t srcSize = (int32_t)uprv_strlen(logicalOrder[i]);
+ int i;
+ for(i=0;i<LENGTHOF(logicalOrder);i++){
+ int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
int32_t destSize = srcSize*2;
- UChar* src = (UChar*) malloc(sizeof(UChar)*srcSize );
- UChar* dest = (UChar*) malloc(sizeof(UChar)*destSize);
- char* chars=NULL;
+ UChar src[MAXLEN];
+ UChar dest[MAXLEN];
+ char chars[MAXLEN];
+ pseudoToU16(srcSize,logicalOrder[i],src);
ec = U_ZERO_ERROR;
- u_unescape(logicalOrder[i],src,srcSize);
- srcSize= u_strlen(src);
ubidi_setPara(bidi,src,srcSize,UBIDI_DEFAULT_LTR ,NULL,&ec);
if(U_FAILURE(ec)){
log_err("ubidi_setPara(tests[%d], paraLevel %d) failed with errorCode %s\n",
@@ -294,25 +486,24 @@ static void TestReorder(){
ec= U_ZERO_ERROR;
}
destSize=ubidi_writeReordered(bidi,dest,destSize+1,UBIDI_DO_MIRRORING,&ec);
- chars = aescstrdup(dest,-1);
+ u16ToPseudo(destSize,dest,chars);
if(destSize!=srcSize){
log_err("ubidi_writeReordered() destSize and srcSize do not match\n");
- }else if(uprv_strncmp(visualOrder[i],chars,destSize)!=0){
- log_err("ubidi_writeReordered() did not give expected results. Expected: %s Got: %s At Index: %d\n",visualOrder[i],chars,i);
+ }else if(strcmp(visualOrder[i],chars)!=0){
+ log_err("ubidi_writeReordered() did not give expected results for UBIDI_DO_MIRRORING.\n"
+ "Input : %s\nExpected: %s\nGot : %s\nLevels : %s\nAt Index: %d\n",
+ logicalOrder[i],visualOrder[i],chars,formatLevels(bidi, formatChars),i);
}
- free(src);
- free(dest);
}
- for(i=0;i<(sizeof(logicalOrder)/sizeof(logicalOrder[0]));i++){
- int32_t srcSize = (int32_t)uprv_strlen(logicalOrder[i]);
+ for(i=0;i<LENGTHOF(logicalOrder);i++){
+ int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
int32_t destSize = srcSize*2;
- UChar* src = (UChar*) malloc(sizeof(UChar)*srcSize );
- UChar* dest = (UChar*) malloc(sizeof(UChar)*destSize);
- char* chars=NULL;
+ UChar src[MAXLEN];
+ UChar dest[MAXLEN];
+ char chars[MAXLEN];
+ pseudoToU16(srcSize,logicalOrder[i],src);
ec = U_ZERO_ERROR;
- u_unescape(logicalOrder[i],src,srcSize);
- srcSize=u_strlen(src);
ubidi_setPara(bidi,src,srcSize,UBIDI_DEFAULT_LTR ,NULL,&ec);
if(U_FAILURE(ec)){
log_err("ubidi_setPara(tests[%d], paraLevel %d) failed with errorCode %s\n",
@@ -328,28 +519,26 @@ static void TestReorder(){
ec= U_ZERO_ERROR;
}
destSize=ubidi_writeReordered(bidi,dest,destSize+1,UBIDI_DO_MIRRORING+UBIDI_OUTPUT_REVERSE,&ec);
- chars = aescstrdup(dest,destSize);
+ u16ToPseudo(destSize,dest,chars);
if(destSize!=srcSize){
log_err("ubidi_writeReordered() destSize and srcSize do not match\n");
- }else if(uprv_strncmp(visualOrder1[i],chars,destSize)!=0){
- log_err("ubidi_writeReordered() did not give expected results for UBIDI_DO_MIRRORING+UBIDI_OUTPUT_REVERSE. Expected: %s Got: %s At Index: %d\n",visualOrder1[i],chars,i);
+ }else if(strcmp(visualOrder1[i],chars)!=0){
+ log_err("ubidi_writeReordered() did not give expected results for UBIDI_DO_MIRRORING+UBIDI_OUTPUT_REVERSE.\n"
+ "Input : %s\nExpected: %s\nGot : %s\nLevels : %s\nAt Index: %d\n",
+ logicalOrder[i],visualOrder1[i],chars,formatLevels(bidi, formatChars),i);
}
- free(src);
- free(dest);
}
- for(i=0;i<(sizeof(logicalOrder)/sizeof(logicalOrder[0]));i++){
- int32_t srcSize = (int32_t)uprv_strlen(logicalOrder[i]);
+ for(i=0;i<LENGTHOF(logicalOrder);i++){
+ int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
int32_t destSize = srcSize*2;
- UChar* src = (UChar*) malloc(sizeof(UChar)*srcSize );
- UChar* dest = (UChar*) malloc(sizeof(UChar)*destSize);
- char* chars=NULL;
+ UChar src[MAXLEN];
+ UChar dest[MAXLEN];
+ char chars[MAXLEN];
+ pseudoToU16(srcSize,logicalOrder[i],src);
ec = U_ZERO_ERROR;
- u_unescape(logicalOrder[i],src,srcSize);
- srcSize=u_strlen(src);
ubidi_setInverse(bidi,TRUE);
ubidi_setPara(bidi,src,srcSize,UBIDI_DEFAULT_LTR ,NULL,&ec);
-
if(U_FAILURE(ec)){
log_err("ubidi_setPara(tests[%d], paraLevel %d) failed with errorCode %s\n",
i, UBIDI_DEFAULT_LTR, u_errorName(ec));
@@ -362,28 +551,23 @@ static void TestReorder(){
ec= U_ZERO_ERROR;
}
destSize=ubidi_writeReordered(bidi,dest,destSize+1,UBIDI_INSERT_LRM_FOR_NUMERIC+UBIDI_OUTPUT_REVERSE,&ec);
- chars = aescstrdup(dest,destSize);
-
- /*if(destSize!=srcSize){
- log_err("ubidi_writeReordered() destSize and srcSize do not match. Dest Size = %d Source Size = %d\n",destSize,srcSize );
- }else*/
- if(uprv_strncmp(visualOrder2[i],chars,destSize)!=0){
- log_err("ubidi_writeReordered() did not give expected results for UBIDI_INSERT_LRM_FOR_NUMERIC+UBIDI_OUTPUT_REVERSE. Expected: %s Got: %s At Index: %d\n",visualOrder2[i],chars,i);
+ u16ToPseudo(destSize,dest,chars);
+ if(strcmp(visualOrder2[i],chars)!=0){
+ log_err("ubidi_writeReordered() did not give expected results for UBIDI_INSERT_LRM_FOR_NUMERIC+UBIDI_OUTPUT_REVERSE.\n"
+ "Input : %s\nExpected: %s\nGot : %s\nLevels : %s\nAt Index: %d\n",
+ logicalOrder[i],visualOrder2[i],chars,formatLevels(bidi, formatChars),i);
}
- free(src);
- free(dest);
}
/* Max Explicit level */
- for(i=0;i<(sizeof(logicalOrder)/sizeof(logicalOrder[0]));i++){
- int32_t srcSize = (int32_t)uprv_strlen(logicalOrder[i]);
+ for(i=0;i<LENGTHOF(logicalOrder);i++){
+ int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
int32_t destSize = srcSize*2;
- UChar* src = (UChar*) malloc(sizeof(UChar)*srcSize );
- UChar* dest = (UChar*) malloc(sizeof(UChar)*destSize);
- char* chars=NULL;
+ UChar src[MAXLEN];
+ UChar dest[MAXLEN];
+ char chars[MAXLEN];
UBiDiLevel levels[UBIDI_MAX_EXPLICIT_LEVEL]={1,2,3,4,5,6,7,8,9,10};
+ pseudoToU16(srcSize,logicalOrder[i],src);
ec = U_ZERO_ERROR;
- u_unescape(logicalOrder[i],src,srcSize);
- srcSize=u_strlen(src);
ubidi_setPara(bidi,src,srcSize,UBIDI_DEFAULT_LTR,levels,&ec);
if(U_FAILURE(ec)){
log_err("ubidi_setPara(tests[%d], paraLevel %d) failed with errorCode %s\n",
@@ -396,54 +580,46 @@ static void TestReorder(){
}else if(destSize!=srcSize){
log_err("Pre-flighting did not give expected size: Expected: %d. Got: %d \n",srcSize,destSize);
}else{
- ec= U_ZERO_ERROR;
+ ec = U_ZERO_ERROR;
}
destSize=ubidi_writeReordered(bidi,dest,destSize+1,UBIDI_OUTPUT_REVERSE,&ec);
- chars = aescstrdup(dest,destSize);
-
+ u16ToPseudo(destSize,dest,chars);
if(destSize!=srcSize){
log_err("ubidi_writeReordered() destSize and srcSize do not match. Dest Size = %d Source Size = %d\n",destSize,srcSize );
- }else if(uprv_strncmp(visualOrder3[i],chars,destSize)!=0){
- log_err("ubidi_writeReordered() did not give expected results for UBIDI_OUTPUT_REVERSE. Expected: %s Got: %s At Index: %d\n",visualOrder3[i],chars,i);
+ }else if(strcmp(visualOrder3[i],chars)!=0){
+ log_err("ubidi_writeReordered() did not give expected results for UBIDI_OUTPUT_REVERSE.\n"
+ "Input : %s\nExpected: %s\nGot : %s\nLevels : %s\nAt Index: %d\n",
+ logicalOrder[i],visualOrder3[i],chars,formatLevels(bidi, formatChars),i);
}
- free(src);
- free(dest);
}
- for(i=0;i<(sizeof(logicalOrder)/sizeof(logicalOrder[0]));i++){
- int32_t srcSize = (int32_t)uprv_strlen(logicalOrder[i]);
+ for(i=0;i<LENGTHOF(logicalOrder);i++){
+ int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
int32_t destSize = srcSize*2;
- UChar* src = (UChar*) malloc(sizeof(UChar)*srcSize );
- UChar* dest = (UChar*) malloc(sizeof(UChar)*destSize);
- char* chars=NULL;
+ UChar src[MAXLEN];
+ UChar dest[MAXLEN];
+ char chars[MAXLEN];
UBiDiLevel levels[UBIDI_MAX_EXPLICIT_LEVEL]={1,2,3,4,5,6,7,8,9,10};
+ pseudoToU16(srcSize,logicalOrder[i],src);
ec = U_ZERO_ERROR;
- u_unescape(logicalOrder[i],src,srcSize);
- srcSize=u_strlen(src);
ubidi_setPara(bidi,src,srcSize,UBIDI_DEFAULT_LTR,levels,&ec);
if(U_FAILURE(ec)){
log_err("ubidi_setPara(tests[%d], paraLevel %d) failed with errorCode %s\n",
i, UBIDI_MAX_EXPLICIT_LEVEL, u_errorName(ec));
}
-
/* try pre-flighting */
destSize = ubidi_writeReordered(bidi,dest,0,UBIDI_DO_MIRRORING+UBIDI_REMOVE_BIDI_CONTROLS,&ec);
if(ec!=U_BUFFER_OVERFLOW_ERROR){
log_err("Pre-flighting did not give expected error: Expected: U_BUFFER_OVERFLOW_ERROR. Got: %s \n",u_errorName(ec));
- /*}else if(destSize!=srcSize){
- log_err("Pre-flighting did not give expected size: Expected: %d. Got: %d \n",srcSize,destSize);*/
}else{
ec= U_ZERO_ERROR;
}
destSize=ubidi_writeReordered(bidi,dest,destSize+1,UBIDI_DO_MIRRORING+UBIDI_REMOVE_BIDI_CONTROLS,&ec);
- chars = aescstrdup(dest,destSize);
-
- /*if(destSize!=srcSize){
- log_err("ubidi_writeReordered() destSize and srcSize do not match. Dest Size = %d Source Size = %d\n",destSize,srcSize );
- }else*/ if(uprv_strncmp(visualOrder4[i],chars,destSize)!=0){
- log_err("ubidi_writeReordered() did not give expected results for UBIDI_DO_MIRRORING+UBIDI_REMOVE_BIDI_CONTROLS. Expected: %s Got: %s At Index: %d\n",visualOrder4[i],chars,i);
+ u16ToPseudo(destSize,dest,chars);
+ if(strcmp(visualOrder4[i],chars)!=0){
+ log_err("ubidi_writeReordered() did not give expected results for UBIDI_DO_MIRRORING+UBIDI_REMOVE_BIDI_CONTROLS.\n"
+ "Input : %s\nExpected: %s\nGot : %s\nLevels : %s\nAt Index: %d\n",
+ logicalOrder[i],visualOrder4[i],chars,formatLevels(bidi, formatChars),i);
}
- free(src);
- free(dest);
}
ubidi_close(bidi);
}
@@ -506,7 +682,7 @@ doTest(UBiDi *pBiDi, int testNumber, BiDiTestData *test, int32_t lineStart, UBoo
for(i=0; i<len; ++i) {
if(levels[i]!=ubidi_getLevelAt(pBiDi, i)) {
- log_err("ubidi_getLevelAt(tests[%d], %d): wrong level %d\n", testNumber, i, ubidi_getLevelAt(pBiDi, i));
+ log_err("ubidi_getLevelAt(tests[%d], %d): wrong level %d, expected %d\n", testNumber, i, ubidi_getLevelAt(pBiDi, i), levels[i]);
return;
}
}
@@ -553,11 +729,12 @@ doTest(UBiDi *pBiDi, int testNumber, BiDiTestData *test, int32_t lineStart, UBoo
static void
testReordering(UBiDi *pBiDi, int testNumber) {
int32_t
- logicalMap1[200], logicalMap2[200], logicalMap3[200],
- visualMap1[200], visualMap2[200], visualMap3[200], visualMap4[200];
+ logicalMap1[MAXLEN], logicalMap2[MAXLEN], logicalMap3[MAXLEN],
+ visualMap1[MAXLEN], visualMap2[MAXLEN], visualMap3[MAXLEN], visualMap4[MAXLEN];
UErrorCode errorCode=U_ZERO_ERROR;
- UBiDiLevel levels[200];
- int32_t i, length=ubidi_getLength(pBiDi);
+ const UBiDiLevel *levels;
+ int32_t i, length=ubidi_getLength(pBiDi),
+ destLength=ubidi_getResultLength(pBiDi);
int32_t runCount, visualIndex, logicalStart, runLength;
UBool odd;
@@ -573,7 +750,6 @@ testReordering(UBiDi *pBiDi, int testNumber) {
}
ubidi_getVisualMap(pBiDi, visualMap1, &errorCode);
-
if(U_FAILURE(errorCode)) {
log_err("ubidi_getVisualMap(tests[%d]): error %s\n", testNumber, myErrorName(errorCode));
return;
@@ -581,10 +757,10 @@ testReordering(UBiDi *pBiDi, int testNumber) {
/* invert them both */
ubidi_invertMap(logicalMap1, visualMap2, length);
- ubidi_invertMap(visualMap1, logicalMap2, length);
+ ubidi_invertMap(visualMap1, logicalMap2, destLength);
/* get them from the levels array, too */
- uprv_memcpy(levels, ubidi_getLevels(pBiDi, &errorCode), length);
+ levels=ubidi_getLevels(pBiDi, &errorCode);
if(U_FAILURE(errorCode)) {
log_err("ubidi_getLevels(tests[%d]): error %s\n", testNumber, myErrorName(errorCode));
@@ -600,17 +776,12 @@ testReordering(UBiDi *pBiDi, int testNumber) {
log_err("ubidi_countRuns(tests[%d]): error %s\n", testNumber, myErrorName(errorCode));
return;
}
-
log_verbose("\n----%2d runs:", runCount);
- for(i=0; i<runCount; ++i) {
- odd=(UBool)(ubidi_getVisualRun(pBiDi, i, &logicalStart, &runLength));
- log_verbose(" (%c @%d[%d])", odd ? 'R' : 'L', logicalStart, runLength);
- }
- log_verbose("\n");
-
visualIndex=0;
for(i=0; i<runCount; ++i) {
- if(UBIDI_LTR==ubidi_getVisualRun(pBiDi, i, &logicalStart, &runLength)) {
+ odd=(UBool)ubidi_getVisualRun(pBiDi, i, &logicalStart, &runLength);
+ log_verbose(" (%c @%d[%d])", odd ? 'R' : 'L', logicalStart, runLength);
+ if(UBIDI_LTR==odd) {
do { /* LTR */
visualMap4[visualIndex++]=logicalStart++;
} while(--runLength>0);
@@ -621,6 +792,7 @@ testReordering(UBiDi *pBiDi, int testNumber) {
} while(--runLength>0);
}
}
+ log_verbose("\n");
/* print all the maps */
log_verbose("logical maps:\n");
@@ -637,11 +809,11 @@ testReordering(UBiDi *pBiDi, int testNumber) {
}
log_verbose("\nvisual maps:\n");
- for(i=0; i<length; ++i) {
+ for(i=0; i<destLength; ++i) {
log_verbose("%4d", visualMap1[i]);
}
log_verbose("\n");
- for(i=0; i<length; ++i) {
+ for(i=0; i<destLength; ++i) {
log_verbose("%4d", visualMap2[i]);
}
log_verbose("\n");
@@ -718,7 +890,6 @@ static void TestFailureRecovery(void) {
}
static void TestMultipleParagraphs(void) {
- #define MAXLEN 100
static const char* const text = "__ABC\\u001c" /* Para #0 offset 0 */
"__\\u05d0DE\\u001c" /* 1 6 */
"__123\\u001c" /* 2 12 */
@@ -993,29 +1164,30 @@ static void TestMultipleParagraphs(void) {
/* inverse BiDi ------------------------------------------------------------- */
-static const UChar
- string0[]={ 0x6c, 0x61, 0x28, 0x74, 0x69, 0x6e, 0x20, 0x5d0, 0x5d1, 0x29, 0x5d2, 0x5d3 },
- string1[]={ 0x6c, 0x61, 0x74, 0x20, 0x5d0, 0x5d1, 0x5d2, 0x20, 0x31, 0x32, 0x33 },
- string2[]={ 0x6c, 0x61, 0x74, 0x20, 0x5d0, 0x28, 0x5d1, 0x5d2, 0x20, 0x31, 0x29, 0x32, 0x33 },
- string3[]={ 0x31, 0x32, 0x33, 0x20, 0x5d0, 0x5d1, 0x5d2, 0x20, 0x34, 0x35, 0x36 },
- string4[]={ 0x61, 0x62, 0x20, 0x61, 0x62, 0x20, 0x661, 0x662 };
+static int countRoundtrips=0, countNonRoundtrips=0;
#define STRING_TEST_CASE(s) { (s), LENGTHOF(s) }
-static const struct {
- const UChar *s;
- int32_t length;
-} testCases[]={
- STRING_TEST_CASE(string0),
- STRING_TEST_CASE(string1),
- STRING_TEST_CASE(string2),
- STRING_TEST_CASE(string3)
-};
-
-static int countRoundtrips=0, countNonRoundtrips=0;
-
static void
doInverseBiDiTest() {
+ static const UChar
+ string0[]={ 0x6c, 0x61, 0x28, 0x74, 0x69, 0x6e, 0x20, 0x5d0, 0x5d1, 0x29, 0x5d2, 0x5d3 },
+ string1[]={ 0x6c, 0x61, 0x74, 0x20, 0x5d0, 0x5d1, 0x5d2, 0x20, 0x31, 0x32, 0x33 },
+ string2[]={ 0x6c, 0x61, 0x74, 0x20, 0x5d0, 0x28, 0x5d1, 0x5d2, 0x20, 0x31, 0x29, 0x32, 0x33 },
+ string3[]={ 0x31, 0x32, 0x33, 0x20, 0x5d0, 0x5d1, 0x5d2, 0x20, 0x34, 0x35, 0x36 },
+ string4[]={ 0x61, 0x62, 0x20, 0x61, 0x62, 0x20, 0x661, 0x662 };
+
+ static const struct {
+ const UChar *s;
+ int32_t length;
+ } testCases[]={
+ STRING_TEST_CASE(string0),
+ STRING_TEST_CASE(string1),
+ STRING_TEST_CASE(string2),
+ STRING_TEST_CASE(string3),
+ STRING_TEST_CASE(string4)
+ };
+
UBiDi *pBiDi;
UErrorCode errorCode;
int i;
@@ -1027,7 +1199,7 @@ doInverseBiDiTest() {
}
log_verbose("inverse BiDi: testInverseBiDi(L) with %u test cases ---\n", LENGTHOF(testCases));
- for(i=0; i<LENGTHOF(testCases); ++i) {
+ for(i=0; i<LENGTHOF(testCases); ++i) {
errorCode=U_ZERO_ERROR;
testInverseBiDi(pBiDi, testCases[i].s, testCases[i].length, 0, &errorCode);
}
@@ -1061,7 +1233,7 @@ static const UChar repeatSegments[COUNT_REPEAT_SEGMENTS][2]={
static void
testManyInverseBiDi(UBiDi *pBiDi, UBiDiLevel direction) {
- static UChar text[8]={ 0, 0, 0x20, 0, 0, 0x20, 0, 0 };
+ UChar text[8]={ 0, 0, 0x20, 0, 0, 0x20, 0, 0 };
int i, j, k;
UErrorCode errorCode;
@@ -1085,8 +1257,9 @@ testManyInverseBiDi(UBiDi *pBiDi, UBiDiLevel direction) {
}
static void
-testInverseBiDi(UBiDi *pBiDi, const UChar *src, int32_t srcLength, UBiDiLevel direction, UErrorCode *pErrorCode) {
- static UChar visualLTR[200], logicalDest[200], visualDest[200];
+testInverseBiDi(UBiDi *pBiDi, const UChar *src, int32_t srcLength,
+ UBiDiLevel direction, UErrorCode *pErrorCode) {
+ UChar visualLTR[MAXLEN], logicalDest[MAXLEN], visualDest[MAXLEN];
int32_t ltrLength, logicalLength, visualLength;
if(direction==0) {
@@ -1094,7 +1267,13 @@ testInverseBiDi(UBiDi *pBiDi, const UChar *src, int32_t srcLength, UBiDiLevel di
/* convert visual to logical */
ubidi_setInverse(pBiDi, TRUE);
+ if (!ubidi_isInverse(pBiDi)) {
+ log_err("Error while doing ubidi_setInverse(TRUE)\n");
+ }
ubidi_setPara(pBiDi, src, srcLength, 0, NULL, pErrorCode);
+ if (src != ubidi_getText(pBiDi)) {
+ log_err("Wrong value returned by ubidi_getText\n");
+ }
logicalLength=ubidi_writeReordered(pBiDi, logicalDest, LENGTHOF(logicalDest),
UBIDI_DO_MIRRORING|UBIDI_INSERT_LRM_FOR_NUMERIC, pErrorCode);
log_verbose(" v ");
@@ -1103,6 +1282,9 @@ testInverseBiDi(UBiDi *pBiDi, const UChar *src, int32_t srcLength, UBiDiLevel di
/* convert back to visual LTR */
ubidi_setInverse(pBiDi, FALSE);
+ if (ubidi_isInverse(pBiDi)) {
+ log_err("Error while doing ubidi_setInverse(FALSE)\n");
+ }
ubidi_setPara(pBiDi, logicalDest, logicalLength, 0, NULL, pErrorCode);
visualLength=ubidi_writeReordered(pBiDi, visualDest, LENGTHOF(visualDest),
UBIDI_DO_MIRRORING|UBIDI_REMOVE_BIDI_CONTROLS, pErrorCode);
@@ -1141,7 +1323,7 @@ testInverseBiDi(UBiDi *pBiDi, const UChar *src, int32_t srcLength, UBiDiLevel di
if(U_FAILURE(*pErrorCode)) {
log_err("inverse BiDi: *** error %s\n"
" turn on verbose mode to see details\n", u_errorName(*pErrorCode));
- } else if(srcLength==visualLength && uprv_memcmp(src, visualDest, srcLength*U_SIZEOF_UCHAR)==0) {
+ } else if(srcLength==visualLength && memcmp(src, visualDest, srcLength*U_SIZEOF_UCHAR)==0) {
++countRoundtrips;
log_verbose(" + roundtripped\n");
} else {
@@ -1162,7 +1344,7 @@ testWriteReverse() {
}, reverseRemoveControlsKeepCombiningDoMirror[]={
0x28, 0x31, 0x29, 0x20, 0x627, 0x64e, 0x650
};
- static UChar reverse[10];
+ UChar reverse[10];
UErrorCode errorCode;
int32_t length;
@@ -1172,18 +1354,18 @@ testWriteReverse() {
reverse, LENGTHOF(reverse),
UBIDI_KEEP_BASE_COMBINING,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(reverseKeepCombining) || uprv_memcmp(reverse, reverseKeepCombining, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(reverseKeepCombining) || memcmp(reverse, reverseKeepCombining, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in ubidi_writeReverse(UBIDI_KEEP_BASE_COMBINING): length=%d (should be %d), error code %s\n",
length, LENGTHOF(reverseKeepCombining), u_errorName(errorCode));
}
- uprv_memset(reverse, 0xa5, LENGTHOF(reverse)*U_SIZEOF_UCHAR);
+ memset(reverse, 0xa5, LENGTHOF(reverse)*U_SIZEOF_UCHAR);
errorCode=U_ZERO_ERROR;
length=ubidi_writeReverse(forward, LENGTHOF(forward),
reverse, LENGTHOF(reverse),
UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_DO_MIRRORING|UBIDI_KEEP_BASE_COMBINING,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(reverseRemoveControlsKeepCombiningDoMirror) || uprv_memcmp(reverse, reverseRemoveControlsKeepCombiningDoMirror, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(reverseRemoveControlsKeepCombiningDoMirror) || memcmp(reverse, reverseRemoveControlsKeepCombiningDoMirror, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in ubidi_writeReverse(UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_DO_MIRRORING|UBIDI_KEEP_BASE_COMBINING):\n"
" length=%d (should be %d), error code %s\n",
length, LENGTHOF(reverseRemoveControlsKeepCombiningDoMirror), u_errorName(errorCode));
@@ -1228,7 +1410,7 @@ doArabicShapingTest() {
dest, LENGTHOF(dest),
U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || uprv_memcmp(dest, en2an, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, en2an, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(en2an)\n");
}
@@ -1238,7 +1420,7 @@ doArabicShapingTest() {
dest, LENGTHOF(dest),
U_SHAPE_DIGITS_AN2EN|U_SHAPE_DIGIT_TYPE_AN_EXTENDED,
&errorCode);
- if(U_FAILURE(errorCode) || length!=u_strlen(source) || uprv_memcmp(dest, an2en, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=u_strlen(source) || memcmp(dest, an2en, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(an2en)\n");
}
@@ -1248,7 +1430,7 @@ doArabicShapingTest() {
dest, LENGTHOF(dest),
U_SHAPE_DIGITS_ALEN2AN_INIT_LR|U_SHAPE_DIGIT_TYPE_AN,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || uprv_memcmp(dest, logical_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, logical_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(logical_alen2an_init_lr)\n");
}
@@ -1258,7 +1440,7 @@ doArabicShapingTest() {
dest, LENGTHOF(dest),
U_SHAPE_DIGITS_ALEN2AN_INIT_AL|U_SHAPE_DIGIT_TYPE_AN_EXTENDED,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || uprv_memcmp(dest, logical_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, logical_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(logical_alen2an_init_al)\n");
}
@@ -1268,7 +1450,7 @@ doArabicShapingTest() {
dest, LENGTHOF(dest),
U_SHAPE_DIGITS_ALEN2AN_INIT_LR|U_SHAPE_DIGIT_TYPE_AN|U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || uprv_memcmp(dest, reverse_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, reverse_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(reverse_alen2an_init_lr)\n");
}
@@ -1278,7 +1460,7 @@ doArabicShapingTest() {
dest, LENGTHOF(dest),
U_SHAPE_DIGITS_ALEN2AN_INIT_AL|U_SHAPE_DIGIT_TYPE_AN_EXTENDED|U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || uprv_memcmp(dest, reverse_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, reverse_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(reverse_alen2an_init_al)\n");
}
@@ -1288,7 +1470,7 @@ doArabicShapingTest() {
dest, LENGTHOF(dest),
0,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || uprv_memcmp(dest, source, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, source, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(noop)\n");
}
@@ -1437,7 +1619,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_near) || uprv_memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_near) || memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_near)\n");
}
@@ -1449,7 +1631,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_at_end) || uprv_memcmp(dest, shape_at_end, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_at_end) || memcmp(dest, shape_at_end, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_at_end)\n");
}
@@ -1461,7 +1643,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_at_begin) || uprv_memcmp(dest, shape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_at_begin) || memcmp(dest, shape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_at_begin)\n");
}
@@ -1473,7 +1655,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || uprv_memcmp(dest, shape_grow_shrink, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || memcmp(dest, shape_grow_shrink, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_grow_shrink)\n");
}
@@ -1487,7 +1669,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_near) || uprv_memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_near) || memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_excepttashkeel_near)\n");
}
@@ -1499,7 +1681,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_at_end) || uprv_memcmp(dest,shape_excepttashkeel_at_end , length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_at_end) || memcmp(dest,shape_excepttashkeel_at_end , length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_excepttashkeel_at_end)\n");
}
@@ -1511,7 +1693,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_at_begin) || uprv_memcmp(dest, shape_excepttashkeel_at_begin, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_at_begin) || memcmp(dest, shape_excepttashkeel_at_begin, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_excepttashkeel_at_begin)\n");
}
@@ -1523,7 +1705,7 @@ doLamAlefSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || uprv_memcmp(dest, shape_excepttashkeel_grow_shrink, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || memcmp(dest, shape_excepttashkeel_grow_shrink, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(LAMALEF shape_excepttashkeel_grow_shrink)\n");
}
}
@@ -1563,7 +1745,7 @@ doTashkeelSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_near) || uprv_memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_near) || memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(TASHKEEL shape_near)\n");
}
@@ -1575,7 +1757,7 @@ doTashkeelSpecialVLTRArabicShapingTest() {
U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_near) || uprv_memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_near) || memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(TASHKEEL shape_excepttashkeel_near)\n");
}
}
@@ -1617,7 +1799,7 @@ doLOGICALArabicDeShapingTest() {
U_SHAPE_TEXT_DIRECTION_LOGICAL,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_near) || uprv_memcmp(dest, unshape_near, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_near) || memcmp(dest, unshape_near, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(unshape_near)\n");
}
@@ -1629,7 +1811,7 @@ doLOGICALArabicDeShapingTest() {
U_SHAPE_TEXT_DIRECTION_LOGICAL,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_at_end) || uprv_memcmp(dest, unshape_at_end, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_at_end) || memcmp(dest, unshape_at_end, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(unshape_at_end)\n");
}
@@ -1641,7 +1823,7 @@ doLOGICALArabicDeShapingTest() {
U_SHAPE_TEXT_DIRECTION_LOGICAL,
&errorCode);
- if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_at_begin) || uprv_memcmp(dest, unshape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_at_begin) || memcmp(dest, unshape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(unshape_at_begin)\n");
}
@@ -1653,7 +1835,7 @@ doLOGICALArabicDeShapingTest() {
U_SHAPE_TEXT_DIRECTION_LOGICAL,
&errorCode);
- if(U_FAILURE(errorCode) || uprv_memcmp(dest, unshape_grow_shrink, length*U_SIZEOF_UCHAR)!=0) {
+ if(U_FAILURE(errorCode) || memcmp(dest, unshape_grow_shrink, length*U_SIZEOF_UCHAR)!=0) {
log_err("failure in u_shapeArabic(unshape_grow_shrink)\n");
}
@@ -1680,18 +1862,17 @@ initCharFromDirProps() {
/* return a string with characters according to the desired directional properties */
static UChar *
-getStringFromDirProps(const uint8_t *dirProps, int32_t length) {
- static UChar s[MAX_STRING_LENGTH];
+getStringFromDirProps(const uint8_t *dirProps, int32_t length, UChar *buffer) {
int32_t i;
initCharFromDirProps();
/* this part would have to be modified for UTF-x */
for(i=0; i<length; ++i) {
- s[i]=charFromDirProp[dirProps[i]];
+ buffer[i]=charFromDirProp[dirProps[i]];
}
- s[i]=0;
- return s;
+ buffer[length]=0;
+ return buffer;
}
static void
@@ -1708,3 +1889,1124 @@ printUnicode(const UChar *s, int32_t length, const UBiDiLevel *levels) {
}
log_verbose(" }");
}
+
+/* new BIDI API */
+
+/* Reordering Mode BiDi --------------------------------------------------------- */
+
+static const UBiDiLevel paraLevels[] = { UBIDI_LTR, UBIDI_RTL };
+
+static UBool
+assertSuccessful(const char* message, UErrorCode* rc) {
+ if (rc != NULL && U_FAILURE(*rc)) {
+ log_err("%s() failed with error %s.\n", message, myErrorName(*rc));
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static UBool
+assertStringsEqual(const char* expected, const char* actual, const char* src,
+ const char* mode, const char* option, UBiDi* pBiDi) {
+ if (uprv_strcmp(expected, actual)) {
+ char formatChars[MAXLEN];
+ log_err("\nActual and expected output mismatch.\n"
+ "%20s %s\n%20s %s\n%20s %s\n%20s %s\n%20s %d %s\n%20s %u\n%20s %d %s\n",
+ "Input:", src,
+ "Actual output:", actual,
+ "Expected output:", expected,
+ "Levels:", formatLevels(pBiDi, formatChars),
+ "Reordering mode:", ubidi_getReorderingMode(pBiDi), mode,
+ "Paragraph level:", ubidi_getParaLevel(pBiDi),
+ "Reordering option:", ubidi_getReorderingOptions(pBiDi), option);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static UBiDi*
+getBiDiObject(void) {
+ UBiDi* pBiDi = ubidi_open();
+ if (pBiDi == NULL) {
+ log_err("Unable to allocate a UBiDi object. Tests are skipped.\n");
+ }
+ return pBiDi;
+}
+
+#define MAKE_ITEMS(val) val, #val
+
+static const struct {
+ uint32_t value;
+ const char* description;
+}
+modes[] = {
+ { MAKE_ITEMS(UBIDI_REORDER_GROUP_NUMBERS_WITH_R) },
+ { MAKE_ITEMS(UBIDI_REORDER_INVERSE_LIKE_DIRECT) },
+ { MAKE_ITEMS(UBIDI_REORDER_NUMBERS_SPECIAL) },
+ { MAKE_ITEMS(UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL) },
+ { MAKE_ITEMS(UBIDI_REORDER_INVERSE_NUMBERS_AS_L) }
+},
+options[] = {
+ { MAKE_ITEMS(UBIDI_OPTION_INSERT_MARKS) },
+ { MAKE_ITEMS(0) }
+};
+
+#define TC_COUNT LENGTHOF(textIn)
+#define MODES_COUNT LENGTHOF(modes)
+#define OPTIONS_COUNT LENGTHOF(options)
+#define LEVELS_COUNT LENGTHOF(paraLevels)
+
+static const char* const textIn[] = {
+/* (0) 123 */
+ "123",
+/* (1) .123->4.5 */
+ ".123->4.5",
+/* (2) 678 */
+ "678",
+/* (3) .678->8.9 */
+ ".678->8.9",
+/* (4) JIH1.2,3MLK */
+ "JIH1.2,3MLK",
+/* (5) FE.>12-> */
+ "FE.>12->",
+/* (6) JIH.>12->a */
+ "JIH.>12->a",
+/* (7) CBA.>67->89=a */
+ "CBA.>67->89=a",
+/* (8) CBA.123->xyz */
+ "CBA.123->xyz",
+/* (9) .>12->xyz */
+ ".>12->xyz",
+/* (10) a.>67->xyz */
+ "a.>67->xyz",
+/* (11) 123JIH */
+ "123JIH",
+/* (12) 123 JIH */
+ "123 JIH"
+};
+
+static const char* const textOut[] = {
+/* TC 0: 123 */
+ "123", /* (0) */
+/* TC 1: .123->4.5 */
+ ".123->4.5", /* (1) */
+ "4.5<-123.", /* (2) */
+/* TC 2: 678 */
+ "678", /* (3) */
+/* TC 3: .678->8.9 */
+ ".8.9<-678", /* (4) */
+ "8.9<-678.", /* (5) */
+ ".678->8.9", /* (6) */
+/* TC 4: MLK1.2,3JIH */
+ "KLM1.2,3HIJ", /* (7) */
+/* TC 5: FE.>12-> */
+ "12<.EF->", /* (8) */
+ "<-12<.EF", /* (9) */
+ "EF.>@12->", /* (10) */
+/* TC 6: JIH.>12->a */
+ "12<.HIJ->a", /* (11) */
+ "a<-12<.HIJ", /* (12) */
+ "HIJ.>@12->a", /* (13) */
+ "a&<-12<.HIJ", /* (14) */
+/* TC 7: CBA.>67->89=a */
+ "ABC.>@67->89=a", /* (15) */
+ "a=89<-67<.ABC", /* (16) */
+ "a&=89<-67<.ABC", /* (17) */
+ "89<-67<.ABC=a", /* (18) */
+/* TC 8: CBA.123->xyz */
+ "123.ABC->xyz", /* (19) */
+ "xyz<-123.ABC", /* (20) */
+ "ABC.@123->xyz", /* (21) */
+ "xyz&<-123.ABC", /* (22) */
+/* TC 9: .>12->xyz */
+ ".>12->xyz", /* (23) */
+ "xyz<-12<.", /* (24) */
+ "xyz&<-12<.", /* (25) */
+/* TC 10: a.>67->xyz */
+ "a.>67->xyz", /* (26) */
+ "a.>@67@->xyz", /* (27) */
+ "xyz<-67<.a", /* (28) */
+/* TC 11: 123JIH */
+ "123HIJ", /* (29) */
+ "HIJ123", /* (30) */
+/* TC 12: 123 JIH */
+ "123 HIJ", /* (31) */
+ "HIJ 123", /* (32) */
+};
+
+#define NO UBIDI_MAP_NOWHERE
+#define MAX_MAP_LENGTH 20
+
+static const int32_t forwardMap[][MAX_MAP_LENGTH] = {
+/* TC 0: 123 */
+ { 0, 1, 2 }, /* (0) */
+/* TC 1: .123->4.5 */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, /* (1) */
+ { 8, 5, 6, 7, 4, 3, 0, 1, 2 }, /* (2) */
+/* TC 2: 678 */
+ { 0, 1, 2 }, /* (3) */
+/* TC 3: .678->8.9 */
+ { 0, 6, 7, 8, 5, 4, 1, 2, 3 }, /* (4) */
+ { 8, 5, 6, 7, 4, 3, 0, 1, 2 }, /* (5) */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, /* (6) */
+/* TC 4: MLK1.2,3JIH */
+ { 10, 9, 8, 3, 4, 5, 6, 7, 2, 1, 0 }, /* (7) */
+/* TC 5: FE.>12-> */
+ { 5, 4, 3, 2, 0, 1, 6, 7 }, /* (8) */
+ { 7, 6, 5, 4, 2, 3, 1, 0 }, /* (9) */
+ { 1, 0, 2, 3, 5, 6, 7, 8 }, /* (10) */
+/* TC 6: JIH.>12->a */
+ { 6, 5, 4, 3, 2, 0, 1, 7, 8, 9 }, /* (11) */
+ { 9, 8, 7, 6, 5, 3, 4, 2, 1, 0 }, /* (12) */
+ { 2, 1, 0, 3, 4, 6, 7, 8, 9, 10 }, /* (13) */
+ { 10, 9, 8, 7, 6, 4, 5, 3, 2, 0 }, /* (14) */
+/* TC 7: CBA.>67->89=a */
+ { 2, 1, 0, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13 }, /* (15) */
+ { 12, 11, 10, 9, 8, 6, 7, 5, 4, 2, 3, 1, 0 }, /* (16) */
+ { 13, 12, 11, 10, 9, 7, 8, 6, 5, 3, 4, 2, 0 }, /* (17) */
+ { 10, 9, 8, 7, 6, 4, 5, 3, 2, 0, 1, 11, 12 }, /* (18) */
+/* TC 8: CBA.123->xyz */
+ { 6, 5, 4, 3, 0, 1, 2, 7, 8, 9, 10, 11 }, /* (19) */
+ { 11, 10, 9, 8, 5, 6, 7, 4, 3, 0, 1, 2 }, /* (20) */
+ { 2, 1, 0, 3, 5, 6, 7, 8, 9, 10, 11, 12 }, /* (21) */
+ { 12, 11, 10, 9, 6, 7, 8, 5, 4, 0, 1, 2 }, /* (22) */
+/* TC 9: .>12->xyz */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, /* (23) */
+ { 8, 7, 5, 6, 4, 3, 0, 1, 2 }, /* (24) */
+ { 9, 8, 6, 7, 5, 4, 0, 1, 2 }, /* (25) */
+/* TC 10: a.>67->xyz */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, /* (26) */
+ { 0, 1, 2, 4, 5, 7, 8, 9, 10, 11 }, /* (27) */
+ { 9, 8, 7, 5, 6, 4, 3, 0, 1, 2 }, /* (28) */
+/* TC 11: 123JIH */
+ { 0, 1, 2, 5, 4, 3 }, /* (29) */
+ { 3, 4, 5, 2, 1, 0 }, /* (30) */
+/* TC 12: 123 JIH */
+ { 0, 1, 2, 3, 6, 5, 4 }, /* (31) */
+ { 4, 5, 6, 3, 2, 1, 0 }, /* (32) */
+};
+
+static const int32_t inverseMap[][MAX_MAP_LENGTH] = {
+/* TC 0: 123 */
+ { 0, 1, 2 }, /* (0) */
+/* TC 1: .123->4.5 */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, /* (1) */
+ { 6, 7, 8, 5, 4, 1, 2, 3, 0 }, /* (2) */
+/* TC 2: 678 */
+ { 0, 1, 2 }, /* (3) */
+/* TC 3: .678->8.9 */
+ { 0, 6, 7, 8, 5, 4, 1, 2, 3 }, /* (4) */
+ { 6, 7, 8, 5, 4, 1, 2, 3, 0 }, /* (5) */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, /* (6) */
+/* TC 4: MLK1.2,3JIH */
+ { 10, 9, 8, 3, 4, 5, 6, 7, 2, 1, 0 }, /* (7) */
+/* TC 5: FE.>12-> */
+ { 4, 5, 3, 2, 1, 0, 6, 7 }, /* (8) */
+ { 7, 6, 4, 5, 3, 2, 1, 0 }, /* (9) */
+ { 1, 0, 2, 3, NO, 4, 5, 6, 7 }, /* (10) */
+/* TC 6: JIH.>12->a */
+ { 5, 6, 4, 3, 2, 1, 0, 7, 8, 9 }, /* (11) */
+ { 9, 8, 7, 5, 6, 4, 3, 2, 1, 0 }, /* (12) */
+ { 2, 1, 0, 3, 4, NO, 5, 6, 7, 8, 9 }, /* (13) */
+ { 9, NO, 8, 7, 5, 6, 4, 3, 2, 1, 0 }, /* (14) */
+/* TC 7: CBA.>67->89=a */
+ { 2, 1, 0, 3, 4, NO, 5, 6, 7, 8, 9, 10, 11, 12 }, /* (15) */
+ { 12, 11, 9, 10, 8, 7, 5, 6, 4, 3, 2, 1, 0 }, /* (16) */
+ { 12, NO, 11, 9, 10, 8, 7, 5, 6, 4, 3, 2, 1, 0 }, /* (17) */
+ { 9, 10, 8, 7, 5, 6, 4, 3, 2, 1, 0, 11, 12 }, /* (18) */
+/* TC 8: CBA.123->xyz */
+ { 4, 5, 6, 3, 2, 1, 0, 7, 8, 9, 10, 11 }, /* (19) */
+ { 9, 10, 11, 8, 7, 4, 5, 6, 3, 2, 1, 0 }, /* (20) */
+ { 2, 1, 0, 3, NO, 4, 5, 6, 7, 8, 9, 10, 11 }, /* (21) */
+ { 9, 10, 11, NO, 8, 7, 4, 5, 6, 3, 2, 1, 0 }, /* (22) */
+/* TC 9: .>12->xyz */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, /* (23) */
+ { 6, 7, 8, 5, 4, 2, 3, 1, 0 }, /* (24) */
+ { 6, 7, 8, NO, 5, 4, 2, 3, 1, 0 }, /* (25) */
+/* TC 10: a.>67->xyz */
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, /* (26) */
+ { 0, 1, 2, NO, 3, 4, NO, 5, 6, 7, 8, 9 }, /* (27) */
+ { 7, 8, 9, 6, 5, 3, 4, 2, 1, 0 }, /* (28) */
+/* TC 11: 123JIH */
+ { 0, 1, 2, 5, 4, 3 }, /* (29) */
+ { 5, 4, 3, 0, 1, 2 }, /* (30) */
+/* TC 12: 123 JIH */
+ { 0, 1, 2, 3, 6, 5, 4 }, /* (31) */
+ { 6, 5, 4, 3, 0, 1, 2 }, /* (32) */
+};
+
+static const char outIndices[TC_COUNT][MODES_COUNT - 1][OPTIONS_COUNT]
+ [LEVELS_COUNT] = {
+ { /* TC 0: 123 */
+ {{ 0, 0}, { 0, 0}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 0, 0}, { 0, 0}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 0, 0}, { 0, 0}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 0, 0}, { 0, 0}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 1: .123->4.5 */
+ {{ 1, 2}, { 1, 2}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 2}, { 1, 2}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 2}, { 1, 2}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 2}, { 1, 2}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 2: 678 */
+ {{ 3, 3}, { 3, 3}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 3, 3}, { 3, 3}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 3, 3}, { 3, 3}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 3, 3}, { 3, 3}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 3: .678->8.9 */
+ {{ 6, 5}, { 6, 5}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 4, 5}, { 4, 5}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 6, 5}, { 6, 5}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 6, 5}, { 6, 5}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 4: MLK1.2,3JIH */
+ {{ 7, 7}, { 7, 7}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 7, 7}, { 7, 7}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 7, 7}, { 7, 7}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 7, 7}, { 7, 7}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 5: FE.>12-> */
+ {{ 8, 9}, { 8, 9}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{10, 9}, { 8, 9}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 8, 9}, { 8, 9}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{10, 9}, { 8, 9}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 6: JIH.>12->a */
+ {{11, 12}, {11, 12}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{13, 14}, {11, 12}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{11, 12}, {11, 12}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{13, 14}, {11, 12}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 7: CBA.>67->89=a */
+ {{18, 16}, {18, 16}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{18, 17}, {18, 16}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{18, 16}, {18, 16}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{15, 17}, {18, 16}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 8: CBA.>124->xyz */
+ {{19, 20}, {19, 20}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{21, 22}, {19, 20}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{19, 20}, {19, 20}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{21, 22}, {19, 20}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 9: .>12->xyz */
+ {{23, 24}, {23, 24}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{23, 25}, {23, 24}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{23, 24}, {23, 24}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{23, 25}, {23, 24}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 10: a.>67->xyz */
+ {{26, 26}, {26, 26}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{26, 27}, {26, 28}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{26, 28}, {26, 28}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{26, 27}, {26, 28}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 11: 124JIH */
+ {{30, 30}, {30, 30}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{29, 30}, {29, 30}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{30, 30}, {30, 30}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{30, 30}, {30, 30}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ },
+ { /* TC 12: 124 JIH */
+ {{32, 32}, {32, 32}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{31, 32}, {31, 32}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{31, 32}, {31, 32}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{31, 32}, {31, 32}} /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ }
+};
+
+static UBool
+assertRoundTrip(UBiDi *pBiDi, int32_t tc, int32_t outIndex, const char *srcChars,
+ const char *destChars, const UChar *dest, int32_t destLen,
+ int mode, int option, UBiDiLevel level) {
+
+ static const char roundtrip[TC_COUNT][MODES_COUNT][OPTIONS_COUNT]
+ [LEVELS_COUNT] = {
+ { /* TC 0: 123 */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 1: .123->4.5 */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 2: 678 */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 3: .678->8.9 */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 0, 0}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 4: MLK1.2,3JIH */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 5: FE.>12-> */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 0, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 6: JIH.>12->a */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 0, 0}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 7: CBA.>67->89=a */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 0, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 0, 0}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 8: CBA.>123->xyz */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 0, 0}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 9: .>12->xyz */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 0}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 10: a.>67->xyz */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 0}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 11: 123JIH */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ },
+ { /* TC 12: 123 JIH */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_GROUP_NUMBERS_WITH_R */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_LIKE_DIRECT */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}}, /* UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL */
+ {{ 1, 1}, { 1, 1}} /* UBIDI_REORDER_INVERSE_NUMBERS_AS_L */
+ }
+ };
+
+ #define SET_ROUND_TRIP_MODE(mode) \
+ ubidi_setReorderingMode(pBiDi, mode); \
+ desc = #mode; \
+ break;
+
+ UErrorCode rc = U_ZERO_ERROR;
+ UChar dest2[MAXLEN];
+ int32_t destLen2;
+ const char* desc;
+ char destChars2[MAXLEN];
+ char destChars3[MAXLEN];
+
+ switch (modes[mode].value) {
+ case UBIDI_REORDER_NUMBERS_SPECIAL:
+ SET_ROUND_TRIP_MODE(UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL)
+ case UBIDI_REORDER_GROUP_NUMBERS_WITH_R:
+ SET_ROUND_TRIP_MODE(UBIDI_REORDER_GROUP_NUMBERS_WITH_R)
+ case UBIDI_REORDER_RUNS_ONLY:
+ SET_ROUND_TRIP_MODE(UBIDI_REORDER_RUNS_ONLY)
+ case UBIDI_REORDER_INVERSE_NUMBERS_AS_L:
+ SET_ROUND_TRIP_MODE(UBIDI_REORDER_DEFAULT)
+ case UBIDI_REORDER_INVERSE_LIKE_DIRECT:
+ SET_ROUND_TRIP_MODE(UBIDI_REORDER_DEFAULT)
+ case UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL:
+ SET_ROUND_TRIP_MODE(UBIDI_REORDER_NUMBERS_SPECIAL)
+ default:
+ SET_ROUND_TRIP_MODE(UBIDI_REORDER_INVERSE_LIKE_DIRECT)
+ }
+ ubidi_setReorderingOptions(pBiDi, UBIDI_OPTION_REMOVE_CONTROLS);
+
+ ubidi_setPara(pBiDi, dest, destLen, level, NULL, &rc);
+ assertSuccessful("ubidi_setPara", &rc);
+ *dest2 = 0;
+ destLen2 = ubidi_writeReordered(pBiDi, dest2, MAXLEN, UBIDI_DO_MIRRORING,
+ &rc);
+ assertSuccessful("ubidi_writeReordered", &rc);
+
+ u16ToPseudo(destLen, dest, destChars3);
+ u16ToPseudo(destLen2, dest2, destChars2);
+ if (strcmp(srcChars, destChars2)) {
+ if (roundtrip[tc][mode][option][level]) {
+ log_err("\nRound trip failed for case=%d mode=%d option=%d.\n"
+ "%20s %s\n%20s %s\n%20s %s\n%20s %s\n%20s %s"
+ "\n%20s %u\n", tc, mode, option,
+ "Original text:", srcChars,
+ "Round-tripped text:", destChars2,
+ "Intermediate text:", destChars3,
+ "Reordering mode:", modes[mode].description,
+ "Reordering option:", options[option].description,
+ "Paragraph level:", level);
+ }
+ else {
+ log_verbose("\nExpected round trip failure for case=%d mode=%d option=%d.\n"
+ "%20s %s\n%20s %s\n%20s %s\n%20s %s\n%20s %s"
+ "\n%20s %u\n", tc, mode, option,
+ "Original text:", srcChars,
+ "Round-tripped text:", destChars2,
+ "Intermediate text:", destChars3,
+ "Reordering mode:", modes[mode].description,
+ "Reordering option:", options[option].description,
+ "Paragraph level:", level);
+ }
+ return FALSE;
+ }
+ if (!checkResultLength(pBiDi, destChars, destChars2, dest2, destLen2,
+ desc, "UBIDI_OPTION_REMOVE_CONTROLS", level)) {
+ return FALSE;
+ }
+ if (outIndex > -1 && !testMaps(pBiDi, outIndex, srcChars, destChars,
+ desc, "UBIDI_OPTION_REMOVE_CONTROLS",
+ level, FALSE)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static UBool
+checkResultLength(UBiDi *pBiDi, const char *srcChars, const char *destChars,
+ const UChar *dest, int32_t destLen, const char* mode,
+ const char* option, UBiDiLevel level) {
+ int32_t actualLen;
+ if (strcmp(mode, "UBIDI_REORDER_INVERSE_NUMBERS_AS_L") == 0)
+ actualLen = strlen(destChars);
+ else
+ actualLen = ubidi_getResultLength(pBiDi);
+ if (actualLen != destLen) {
+ log_err("\nubidi_getResultLength failed.\n%20s %7d\n%20s %7d\n"
+ "%20s %s\n%20s %s\n%20s %s\n%20s %s\n%20s %u\n",
+ "Expected:", destLen, "Actual:", actualLen,
+ "Input:", srcChars, "Output:", destChars,
+ "Reordering mode:", mode, "Reordering option:", option,
+ "Paragraph level:", level);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void
+doReorderRunsTest(void) {
+ static const struct {
+ const char* textIn;
+ const char* textOut[2][2];
+ const char noroundtrip[2];
+ } testCases[] = {
+ {"ab 234 896 de", {{"de 896 ab 234", "de 896 ab 234"},
+ {"ab 234 @896@ de", "de 896 ab 234"}}, {0, 0}},
+ {"abcGHI", {{"GHIabc", "GHIabc"}, {"GHIabc", "GHIabc"}}, {0, 0}},
+ {"a.>67->", {{"<-67<.a", "<-67<.a"}, {"<-67<.a", "<-67<.a"}}, {0, 0}},
+ {"-=%$123/ *", {{"* /%$123=-", "* /%$123=-"},
+ {"* /%$123=-", "* /%$123=-"}}, {0, 0}},
+ {"abc->12..>JKL", {{"JKL<..12<-abc", "JKL<..abc->12"},
+ {"JKL<..12<-abc", "JKL<..abc->12"}}, {0, 0}},
+ {"JKL->12..>abc", {{"abc<..JKL->12", "abc<..12<-JKL"},
+ {"abc<..JKL->12", "abc<..12<-JKL"}}, {0, 0}},
+ {"123->abc", {{"abc<-123", "abc<-123"},
+ {"abc&<-123", "abc<-123"}}, {1, 0}},
+ {"123->JKL", {{"JKL<-123", "123->JKL"},
+ {"JKL<-123", "JKL<-@123"}}, {0, 1}},
+ {"*>12.>34->JKL", {{"JKL<-34<.12<*", "12.>34->JKL<*"},
+ {"JKL<-34<.12<*", "JKL<-@34<.12<*"}}, {0, 1}},
+ {"*>67.>89->JKL", {{"67.>89->JKL<*", "67.>89->JKL<*"},
+ {"67.>89->JKL<*", "67.>89->JKL<*"}}, {0, 0}},
+ {"* /abc-=$%123", {{"$%123=-abc/ *", "abc-=$%123/ *"},
+ {"$%123=-abc/ *", "abc-=$%123/ *"}}, {0, 0}},
+ {"* /$%def-=123", {{"123=-def%$/ *", "def-=123%$/ *"},
+ {"123=-def%$/ *", "def-=123%$/ *"}}, {0, 0}},
+ {"-=GHI* /123%$", {{"GHI* /123%$=-", "123%$/ *GHI=-"},
+ {"GHI* /123%$=-", "123%$/ *GHI=-"}}, {0, 0}},
+ {"-=%$JKL* /123", {{"JKL* /%$123=-", "123/ *JKL$%=-"},
+ {"JKL* /%$123=-", "123/ *JKL$%=-"}}, {0, 0}},
+ {"ab =#CD *?450", {{"CD *?450#= ab", "450?* CD#= ab"},
+ {"CD *?450#= ab", "450?* CD#= ab"}}, {0, 0}},
+ {"ab 234 896 de", {{"de 896 ab 234", "de 896 ab 234"},
+ {"ab 234 @896@ de", "de 896 ab 234"}}, {0, 0}},
+ {"abc-=%$LMN* /123", {{"LMN* /%$123=-abc", "123/ *LMN$%=-abc"},
+ {"LMN* /%$123=-abc", "123/ *LMN$%=-abc"}}, {0, 0}},
+ {"123->JKL&MN&P", {{"JKLMNP<-123", "123->JKLMNP"},
+ {"JKLMNP<-123", "JKLMNP<-@123"}}, {0, 1}}
+ };
+ UBiDi *pBiDi = getBiDiObject();
+ UBiDi *pL2VBiDi = getBiDiObject();
+ UChar src[MAXLEN], dest[MAXLEN], visual1[MAXLEN], visual2[MAXLEN];
+ char destChars[MAXLEN], vis1Chars[MAXLEN], vis2Chars[MAXLEN];
+ int32_t srcLen, destLen, vis1Len, vis2Len, option, i, j, nCases;
+ UErrorCode rc = U_ZERO_ERROR;
+ UBiDiLevel level;
+ if(!pL2VBiDi) {
+ ubidi_close(pBiDi); /* in case this one was allocated */
+ return;
+ }
+ ubidi_setReorderingMode(pBiDi, UBIDI_REORDER_RUNS_ONLY);
+ ubidi_setReorderingOptions(pL2VBiDi, UBIDI_OPTION_REMOVE_CONTROLS);
+
+ for (option = 0; option < 2; option++) {
+ ubidi_setReorderingOptions(pBiDi, option==0 ? UBIDI_OPTION_REMOVE_CONTROLS
+ : UBIDI_OPTION_INSERT_MARKS);
+ for (i = 0, nCases = LENGTHOF(testCases); i < nCases; i++) {
+ srcLen = strlen(testCases[i].textIn);
+ pseudoToU16(srcLen, testCases[i].textIn, src);
+ for(j = 0; j < 2; j++) {
+ level = paraLevels[j];
+ ubidi_setPara(pBiDi, src, srcLen, level, NULL, &rc);
+ assertSuccessful("ubidi_setPara", &rc);
+ *dest = 0;
+ destLen = ubidi_writeReordered(pBiDi, dest, MAXLEN, UBIDI_DO_MIRRORING, &rc);
+ assertSuccessful("ubidi_writeReordered", &rc);
+ u16ToPseudo(destLen, dest, destChars);
+ assertStringsEqual(testCases[i].textOut[option][level], destChars,
+ testCases[i].textIn, "UBIDI_REORDER_RUNS_ONLY",
+ option==0 ? "0" : "UBIDI_OPTION_INSERT_MARKS",
+ pBiDi);
+
+ if((option==0) && testCases[i].noroundtrip[level]) {
+ continue;
+ }
+ ubidi_setPara(pL2VBiDi, src, srcLen, level, NULL, &rc);
+ assertSuccessful("ubidi_setPara1", &rc);
+ *visual1 = 0;
+ vis1Len = ubidi_writeReordered(pL2VBiDi, visual1, MAXLEN, UBIDI_DO_MIRRORING, &rc);
+ assertSuccessful("ubidi_writeReordered1", &rc);
+ u16ToPseudo(vis1Len, visual1, vis1Chars);
+ ubidi_setPara(pL2VBiDi, dest, destLen, level^1, NULL, &rc);
+ assertSuccessful("ubidi_setPara2", &rc);
+ *visual2 = 0;
+ vis2Len = ubidi_writeReordered(pL2VBiDi, visual2, MAXLEN, UBIDI_DO_MIRRORING, &rc);
+ assertSuccessful("ubidi_writeReordered2", &rc);
+ u16ToPseudo(vis2Len, visual2, vis2Chars);
+ assertStringsEqual(vis1Chars, vis2Chars,
+ testCases[i].textIn, "UBIDI_REORDER_RUNS_ONLY (2)",
+ option==0 ? "0" : "UBIDI_OPTION_INSERT_MARKS",
+ pBiDi);
+ }
+ }
+ }
+ ubidi_close(pBiDi);
+ ubidi_close(pL2VBiDi);
+}
+
+static void
+doReorderingModeBidiTest() {
+
+ UChar src[MAXLEN], dest[MAXLEN];
+ char destChars[MAXLEN];
+ UBiDi *pBiDi = NULL, *pBiDi2 = NULL, *pBiDi3 = NULL;
+ UErrorCode rc;
+ int tc, mode, option, level;
+ uint32_t modeValue, modeBack, optionValue, optionBack;
+ int32_t srcLen, destLen, index;
+ const char *expectedChars;
+ UBool testOK = TRUE;
+
+ log_verbose("\n*** Bidi reordering mode test ***\n");
+
+ pBiDi = getBiDiObject();
+ pBiDi2 = getBiDiObject();
+ pBiDi3 = getBiDiObject();
+ if(!pBiDi3) {
+ ubidi_close(pBiDi); /* in case this one was allocated */
+ ubidi_close(pBiDi2); /* in case this one was allocated */
+ return;
+ }
+
+ ubidi_setInverse(pBiDi2, TRUE);
+
+ for (tc = 0; tc < TC_COUNT; tc++) {
+ const char* srcChars = textIn[tc];
+ srcLen = strlen(srcChars);
+ pseudoToU16(srcLen, srcChars, src);
+
+ for (mode = 0; mode < MODES_COUNT; mode++) {
+ modeValue = modes[mode].value;
+ ubidi_setReorderingMode(pBiDi, modeValue);
+ modeBack = ubidi_getReorderingMode(pBiDi);
+ if (modeValue != modeBack) {
+ log_err("Error while setting reordering mode to %d, returned %d\n",
+ modeValue, modeBack);
+ }
+
+ for (option = 0; option < OPTIONS_COUNT; option++) {
+ optionValue = options[option].value;
+ ubidi_setReorderingOptions(pBiDi, optionValue);
+ optionBack = ubidi_getReorderingOptions(pBiDi);
+ if (optionValue != optionBack) {
+ log_err("Error while setting reordering option to %d, returned %d\n",
+ optionValue, optionBack);
+ }
+
+ for (level = 0; level < LEVELS_COUNT; level++) {
+ log_verbose("starting test %d mode=%d option=%d level=%d\n",
+ tc, modes[mode].value, options[option].value, level);
+ rc = U_ZERO_ERROR;
+ ubidi_setPara(pBiDi, src, srcLen, paraLevels[level], NULL, &rc);
+ assertSuccessful("ubidi_setPara", &rc);
+
+ *dest = 0;
+ destLen = ubidi_writeReordered(pBiDi, dest, MAXLEN,
+ UBIDI_DO_MIRRORING, &rc);
+ assertSuccessful("ubidi_writeReordered", &rc);
+ u16ToPseudo(destLen, dest, destChars);
+
+ if (modes[mode].value == UBIDI_REORDER_INVERSE_NUMBERS_AS_L) {
+ index = -1;
+ expectedChars = inverseBasic(pBiDi2, src, srcLen,
+ options[option].value, paraLevels[level], destChars);
+ }
+ else {
+ index = outIndices[tc][mode][option][level];
+ expectedChars = textOut[index];
+ }
+ if (!assertStringsEqual(expectedChars, destChars, srcChars,
+ modes[mode].description,
+ options[option].description,
+ pBiDi)) {
+ testOK = FALSE;
+ }
+ else if (options[option].value == UBIDI_OPTION_INSERT_MARKS &&
+ !assertRoundTrip(pBiDi3, tc, index, srcChars,
+ destChars, dest, destLen,
+ mode, option, paraLevels[level])) {
+ testOK = FALSE;
+ }
+ else if (!checkResultLength(pBiDi, srcChars, destChars,
+ dest, destLen, modes[mode].description,
+ options[option].description,
+ paraLevels[level])) {
+ testOK = FALSE;
+ }
+ else if (index > -1 && !testMaps(pBiDi, index, srcChars,
+ destChars, modes[mode].description,
+ options[option].description, paraLevels[level],
+ TRUE)) {
+ testOK = FALSE;
+ }
+ }
+ }
+ }
+ }
+ if (testOK == TRUE) {
+ log_verbose("\nReordering mode test OK\n");
+ }
+ ubidi_close(pBiDi3);
+ ubidi_close(pBiDi2);
+ ubidi_close(pBiDi);
+}
+
+static const char* inverseBasic(UBiDi *pBiDi, const UChar *src, int32_t srcLen,
+ uint32_t option, UBiDiLevel level, char *result) {
+ UErrorCode rc = U_ZERO_ERROR;
+ int32_t destLen;
+ UChar dest2 [MAXLEN];
+
+ if (pBiDi == NULL || src == NULL) {
+ return NULL;
+ }
+ ubidi_setReorderingOptions(pBiDi, option);
+ ubidi_setPara(pBiDi, src, srcLen, level, NULL, &rc);
+ assertSuccessful("ubidi_setPara", &rc);
+
+ *dest2 = 0;
+ destLen = ubidi_writeReordered(pBiDi, dest2, MAXLEN,
+ UBIDI_DO_MIRRORING, &rc);
+ assertSuccessful("ubidi_writeReordered", &rc);
+ u16ToPseudo(destLen, dest2, result);
+ return result;
+}
+
+#define NULL_CHAR '\0'
+
+static void
+doBidiStreamingTest() {
+#define MAXPORTIONS 10
+
+ static const struct {
+ const char* textIn;
+ short int chunk;
+ short int nPortions[2];
+ char portionLens[2][MAXPORTIONS];
+ const char* message[2];
+ } testData[] = {
+ { "123\\u000A"
+ "abc45\\u000D"
+ "67890\\u000A"
+ "\\u000D"
+ "02468\\u000D"
+ "ghi",
+ 6, { 6, 6 }, {{ 6, 4, 6, 1, 6, 3}, { 4, 6, 6, 1, 6, 3 }},
+ {"6, 4, 6, 1, 6, 3", "4, 6, 6, 1, 6, 3"}
+ },
+ { "abcd\\u000Afgh\\u000D12345\\u000A456",
+ 6, { 4, 4 }, {{ 6, 3, 6, 3 }, { 5, 4, 6, 3 }},
+ {"6, 3, 6, 3", "5, 4, 6, 3"}
+ },
+ { "abcd\\u000Afgh\\u000D12345\\u000A45\\u000D",
+ 6, { 4, 4 }, {{ 6, 3, 6, 3 }, { 5, 4, 6, 3 }},
+ {"6, 3, 6, 3", "5, 4, 6, 3"}
+ },
+ { "abcde\\u000Afghi",
+ 10, { 1, 2 }, {{ 10 }, { 6, 4 }},
+ {"10", "6, 4"}
+ }
+ };
+ UChar src[MAXLEN];
+ UBiDi *pBiDi = NULL;
+ UChar *pSrc;
+ UErrorCode rc = U_ZERO_ERROR;
+ int32_t srcLen, processedLen, chunk, len, nPortions;
+ int i, j, levelIndex;
+ UBiDiLevel level;
+ int nTests = LENGTHOF(testData), nLevels = LENGTHOF(paraLevels);
+ UBool mismatch, testOK = TRUE;
+ char processedLenStr[MAXPORTIONS * 5];
+
+ log_verbose("\n*** Bidi streaming test ***\n");
+
+ pBiDi = getBiDiObject();
+
+ ubidi_orderParagraphsLTR(pBiDi, TRUE);
+
+ for (levelIndex = 0; levelIndex < nLevels; levelIndex++) {
+ for (i = 0; i < nTests; i++) {
+ srcLen = u_unescape(testData[i].textIn, src, MAXLEN);
+ chunk = testData[i].chunk;
+ nPortions = testData[i].nPortions[levelIndex];
+ level = paraLevels[levelIndex];
+ *processedLenStr = NULL_CHAR;
+
+ mismatch = FALSE;
+
+ ubidi_setReorderingOptions(pBiDi, UBIDI_OPTION_STREAMING);
+ for (j = 0, pSrc = src; j < MAXPORTIONS && srcLen > 0; j++) {
+
+ len = chunk < srcLen ? chunk : srcLen;
+ ubidi_setPara(pBiDi, pSrc, len, level, NULL, &rc);
+ assertSuccessful("ubidi_setPara", &rc);
+
+ processedLen = ubidi_getProcessedLength(pBiDi);
+ if (processedLen == 0) {
+ ubidi_setReorderingOptions(pBiDi, UBIDI_OPTION_DEFAULT);
+ j--;
+ continue;
+ }
+ ubidi_setReorderingOptions(pBiDi, UBIDI_OPTION_STREAMING);
+
+ mismatch = j >= nPortions ||
+ processedLen != testData[i].portionLens[levelIndex][j];
+
+ sprintf(processedLenStr + j * 4, "%4d", processedLen);
+ srcLen -= processedLen, pSrc += processedLen;
+ }
+
+ if (mismatch || j != nPortions) {
+ testOK = FALSE;
+ log_err("\nProcessed lengths mismatch.\n"
+ "\tParagraph level: %u\n"
+ "\tInput string: %s\n"
+ "\tActually processed portion lengths: { %s }\n"
+ "\tExpected portion lengths : { %s }\n",
+ paraLevels[levelIndex], testData[i].textIn,
+ processedLenStr, testData[i].message[levelIndex]);
+ }
+ }
+ }
+ ubidi_close(pBiDi);
+ if (testOK == TRUE) {
+ log_verbose("\nBiDi streaming test OK\n");
+ }
+}
+
+U_CDECL_BEGIN
+
+static UCharDirection U_CALLCONV
+overrideBidiClass(const void *context, UChar32 c) {
+
+#define DEF U_BIDI_CLASS_DEFAULT
+
+ static const UCharDirection customClasses[] = {
+ /* 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F */
+ DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 00-07 */
+ DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 08-0F */
+ DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 10-17 */
+ DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 18-1F */
+ DEF, DEF, DEF, DEF, DEF, DEF, R, DEF, /* 20-27 */
+ DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 28-2F */
+ EN, EN, EN, EN, EN, EN, AN, AN, /* 30-37 */
+ AN, AN, DEF, DEF, DEF, DEF, DEF, DEF, /* 38-3F */
+ L, AL, AL, AL, AL, AL, AL, R, /* 40-47 */
+ R, R, R, R, R, R, R, R, /* 48-4F */
+ R, R, R, R, R, R, R, R, /* 50-57 */
+ R, R, R, LRE, DEF, RLE, PDF, S, /* 58-5F */
+ NSM, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 60-67 */
+ DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 68-6F */
+ DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, /* 70-77 */
+ DEF, DEF, DEF, LRO, B, RLO, BN, DEF /* 78-7F */
+ };
+ static const int nEntries = LENGTHOF(customClasses);
+
+ return c >= nEntries ? U_BIDI_CLASS_DEFAULT : customClasses[c];
+}
+
+U_CDECL_END
+
+static void verifyCallbackParams(UBiDiClassCallback* fn, const void* context,
+ UBiDiClassCallback* expectedFn,
+ const void* expectedContext,
+ int32_t sizeOfContext) {
+ if (fn != expectedFn) {
+ log_err("Class callback pointer is not set properly.\n");
+ }
+ if (context != expectedContext) {
+ log_err("Class callback context is not set properly.\n");
+ }
+ else if (context != NULL &&
+ memcmp(context, expectedContext, sizeOfContext)) {
+ log_err("Callback context content doesn't match the expected one.\n");
+ }
+}
+
+static void doBidiClassOverrideTest(void) {
+ static const char* const textSrc = "JIH.>12->a \\u05D0\\u05D1 6 ABC78";
+ static const char* const textResult = "12<.HIJ->a 78CBA 6 \\u05D1\\u05D0";
+
+ UChar src[MAXLEN], dest[MAXLEN];
+ UErrorCode rc = U_ZERO_ERROR;
+ UBiDi *pBiDi = NULL;
+ UBiDiClassCallback* oldFn = NULL;
+ UBiDiClassCallback* newFn = overrideBidiClass;
+ const void* oldContext = NULL;
+ int32_t srcLen, destLen, textSrcSize = (int32_t)uprv_strlen(textSrc);
+ char* destChars = NULL;
+
+ log_verbose("\n*** Bidi class override test ***\n");
+
+ pBiDi = getBiDiObject();
+ if(!pBiDi) {
+ return;
+ }
+
+ ubidi_getClassCallback(pBiDi, &oldFn, &oldContext);
+ verifyCallbackParams(oldFn, oldContext, NULL, NULL, 0);
+
+ ubidi_setClassCallback(pBiDi, newFn, textSrc, &oldFn, &oldContext, &rc);
+ if (!assertSuccessful("ubidi_setClassCallback", &rc)) {
+ ubidi_close(pBiDi);
+ return;
+ }
+ verifyCallbackParams(oldFn, oldContext, NULL, NULL, 0);
+
+ ubidi_getClassCallback(pBiDi, &oldFn, &oldContext);
+ verifyCallbackParams(oldFn, oldContext, newFn, textSrc, textSrcSize);
+
+ ubidi_setClassCallback(pBiDi, newFn, textSrc, &oldFn, &oldContext, &rc);
+ if (!assertSuccessful("ubidi_setClassCallback", &rc)) {
+ ubidi_close(pBiDi);
+ return;
+ }
+ verifyCallbackParams(oldFn, oldContext, newFn, textSrc, textSrcSize);
+
+ srcLen = u_unescape(textSrc, src, MAXLEN);
+ ubidi_setPara(pBiDi, src, srcLen, UBIDI_LTR, NULL, &rc);
+ assertSuccessful("ubidi_setPara", &rc);
+
+ destLen = ubidi_writeReordered(pBiDi, dest, MAXLEN,
+ UBIDI_DO_MIRRORING, &rc);
+ assertSuccessful("ubidi_writeReordered", &rc);
+
+ destChars = aescstrdup(dest, destLen);
+ if (uprv_strcmp(textResult, destChars)) {
+ log_err("\nActual and expected output mismatch.\n"
+ "%20s %s\n%20s %s\n%20s %s\n",
+ "Input:", textSrc, "Actual output:", destChars,
+ "Expected output:", textResult);
+ }
+ else {
+ log_verbose("\nClass override test OK\n");
+ }
+ ubidi_close(pBiDi);
+}
+
+static char * formatMap(const int32_t * map, int len, char * buffer)
+{
+ int32_t i, k;
+ char c;
+ for (i = 0; i < len; i++) {
+ k = map[i];
+ if (k < 0)
+ c = '-';
+ else if (k >= sizeof columns)
+ c = '+';
+ else
+ c = columns[k];
+ buffer[i] = c;
+ }
+ buffer[len] = '\0';
+ return buffer;
+}
+
+static UBool
+testMaps(UBiDi *pBiDi, int32_t stringIndex, const char *src, const char *dest,
+ const char *mode, const char* option, UBiDiLevel level, UBool forward)
+{
+ int32_t actualLogicalMap[MAX_MAP_LENGTH];
+ int32_t actualVisualMap[MAX_MAP_LENGTH];
+ int32_t getIndexMap[MAX_MAP_LENGTH];
+ int32_t i, srcLen, resLen, index;
+ const int32_t *expectedLogicalMap, *expectedVisualMap;
+ UErrorCode rc = U_ZERO_ERROR;
+ UBool testOK = TRUE;
+
+ if (forward) {
+ expectedLogicalMap = forwardMap[stringIndex];
+ expectedVisualMap = inverseMap[stringIndex];
+ }
+ else {
+ expectedLogicalMap = inverseMap[stringIndex];
+ expectedVisualMap = forwardMap[stringIndex];
+ }
+ ubidi_getLogicalMap(pBiDi, actualLogicalMap, &rc);
+ if (!assertSuccessful("ubidi_getLogicalMap", &rc)) {
+ testOK = FALSE;
+ }
+ srcLen = ubidi_getProcessedLength(pBiDi);
+ if (memcmp(expectedLogicalMap, actualLogicalMap, srcLen * sizeof(int32_t))) {
+ char expChars[MAX_MAP_LENGTH];
+ char actChars[MAX_MAP_LENGTH];
+ log_err("\nubidi_getLogicalMap() returns unexpected map for output string "
+ "index %d\n"
+ "source: %s\n"
+ "dest : %s\n"
+ "Scale : %s\n"
+ "ExpMap: %s\n"
+ "Actual: %s\n"
+ "Paragraph level : %d == %d\n"
+ "Reordering mode : %s == %d\n"
+ "Reordering option: %s == %d\n"
+ "Forward flag : %d\n",
+ stringIndex, src, dest, columns,
+ formatMap(expectedLogicalMap, srcLen, expChars),
+ formatMap(actualLogicalMap, srcLen, actChars),
+ level, ubidi_getParaLevel(pBiDi),
+ mode, ubidi_getReorderingMode(pBiDi),
+ option, ubidi_getReorderingOptions(pBiDi),
+ forward
+ );
+ testOK = FALSE;
+ }
+ resLen = ubidi_getResultLength(pBiDi);
+ ubidi_getVisualMap(pBiDi, actualVisualMap, &rc);
+ assertSuccessful("ubidi_getVisualMap", &rc);
+ if (memcmp(expectedVisualMap, actualVisualMap, resLen * sizeof(int32_t))) {
+ char expChars[MAX_MAP_LENGTH];
+ char actChars[MAX_MAP_LENGTH];
+ log_err("\nubidi_getVisualMap() returns unexpected map for output string "
+ "index %d\n"
+ "source: %s\n"
+ "dest : %s\n"
+ "Scale : %s\n"
+ "ExpMap: %s\n"
+ "Actual: %s\n"
+ "Paragraph level : %d == %d\n"
+ "Reordering mode : %s == %d\n"
+ "Reordering option: %s == %d\n"
+ "Forward flag : %d\n",
+ stringIndex, src, dest, columns,
+ formatMap(expectedVisualMap, resLen, expChars),
+ formatMap(actualVisualMap, resLen, actChars),
+ level, ubidi_getParaLevel(pBiDi),
+ mode, ubidi_getReorderingMode(pBiDi),
+ option, ubidi_getReorderingOptions(pBiDi),
+ forward
+ );
+ testOK = FALSE;
+ }
+ for (i = 0; i < srcLen; i++) {
+ index = ubidi_getVisualIndex(pBiDi, i, &rc);
+ assertSuccessful("ubidi_getVisualIndex", &rc);
+ getIndexMap[i] = index;
+ }
+ if (memcmp(actualLogicalMap, getIndexMap, srcLen * sizeof(int32_t))) {
+ char actChars[MAX_MAP_LENGTH];
+ char gotChars[MAX_MAP_LENGTH];
+ log_err("\nMismatch between ubidi_getLogicalMap and ubidi_getVisualIndex for output string "
+ "index %d\n"
+ "source: %s\n"
+ "dest : %s\n"
+ "Scale : %s\n"
+ "ActMap: %s\n"
+ "IdxMap: %s\n"
+ "Paragraph level : %d == %d\n"
+ "Reordering mode : %s == %d\n"
+ "Reordering option: %s == %d\n"
+ "Forward flag : %d\n",
+ stringIndex, src, dest, columns,
+ formatMap(actualLogicalMap, srcLen, actChars),
+ formatMap(getIndexMap, srcLen, gotChars),
+ level, ubidi_getParaLevel(pBiDi),
+ mode, ubidi_getReorderingMode(pBiDi),
+ option, ubidi_getReorderingOptions(pBiDi),
+ forward
+ );
+ testOK = FALSE;
+ }
+ for (i = 0; i < resLen; i++) {
+ index = ubidi_getLogicalIndex(pBiDi, i, &rc);
+ assertSuccessful("ubidi_getLogicalIndex", &rc);
+ getIndexMap[i] = index;
+ }
+ if (memcmp(actualVisualMap, getIndexMap, resLen * sizeof(int32_t))) {
+ char actChars[MAX_MAP_LENGTH];
+ char gotChars[MAX_MAP_LENGTH];
+ log_err("\nMismatch between ubidi_getVisualMap and ubidi_getLogicalIndex for output string "
+ "index %d\n"
+ "source: %s\n"
+ "dest : %s\n"
+ "Scale : %s\n"
+ "ActMap: %s\n"
+ "IdxMap: %s\n"
+ "Paragraph level : %d == %d\n"
+ "Reordering mode : %s == %d\n"
+ "Reordering option: %s == %d\n"
+ "Forward flag : %d\n",
+ stringIndex, src, dest, columns,
+ formatMap(actualVisualMap, resLen, actChars),
+ formatMap(getIndexMap, resLen, gotChars),
+ level, ubidi_getParaLevel(pBiDi),
+ mode, ubidi_getReorderingMode(pBiDi),
+ option, ubidi_getReorderingOptions(pBiDi),
+ forward
+ );
+ testOK = FALSE;
+ }
+ return testOK;
+}
+
diff --git a/Build/source/libs/icu-xetex/test/cintltst/ccaltst.c b/Build/source/libs/icu-xetex/test/cintltst/ccaltst.c
index fd1e14ef253..08a81699e38 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/ccaltst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/ccaltst.c
@@ -1,16 +1,16 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
-/********************************************************************************
+/******************************************************************************
*
* File CCALTST.C
*
* Modification History:
* Name Description
* Madhu Katragadda Creation
-*********************************************************************************/
+*******************************************************************************/
/* C API AND FUNCTIONALITY TEST FOR CALENDAR (ucol.h)*/
@@ -28,6 +28,8 @@
#include "ccaltst.h"
#include "cformtst.h"
+void TestGregorianChange(void);
+
void addCalTest(TestNode** root);
void addCalTest(TestNode** root)
@@ -40,7 +42,7 @@ void addCalTest(TestNode** root)
addTest(root, &TestGetLimits, "tsformat/ccaltst/TestGetLimits");
addTest(root, &TestDOWProgression, "tsformat/ccaltst/TestDOWProgression");
addTest(root, &TestGMTvsLocal, "tsformat/ccaltst/TestGMTvsLocal");
-
+ addTest(root, &TestGregorianChange, "tsformat/ccaltst/TestGregorianChange");
}
/* "GMT" */
@@ -894,7 +896,7 @@ static void TestGetLimits()
val = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
min = ucal_getLimit(cal, UCAL_DAY_OF_WEEK, UCAL_MINIMUM, &status);
max = ucal_getLimit(cal, UCAL_DAY_OF_WEEK, UCAL_MAXIMUM, &status);
- if ( (min != UCAL_SUNDAY || max != UCAL_SATURDAY ) && (min > val > max) && (val != UCAL_FRIDAY)){
+ if ( (min != UCAL_SUNDAY || max != UCAL_SATURDAY ) && (min > val && val > max) && (val != UCAL_FRIDAY)){
log_err("FAIL: Min/max bad\n");
log_err("FAIL: Day of week %d out of range\n", val);
log_err("FAIL: FAIL: Day of week should be SUNDAY Got %d\n", val);
@@ -905,7 +907,7 @@ static void TestGetLimits()
val = ucal_get(cal, UCAL_DAY_OF_WEEK_IN_MONTH, &status);
min = ucal_getLimit(cal, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_MINIMUM, &status);
max = ucal_getLimit(cal, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_MAXIMUM, &status);
- if ( (min != 0 || max != 5 ) && (min > val > max) && (val != 1)){
+ if ( (min != 0 || max != 5 ) && (min > val && val > max) && (val != 1)){
log_err("FAIL: Min/max bad\n");
log_err("FAIL: Day of week in month %d out of range\n", val);
log_err("FAIL: FAIL: Day of week in month should be SUNDAY Got %d\n", val);
@@ -937,7 +939,7 @@ static void TestGetLimits()
ac_min=ucal_getLimit(cal, UCAL_MINUTE, UCAL_ACTUAL_MINIMUM, &status);
ac_max=ucal_getLimit(cal, UCAL_SECOND, UCAL_ACTUAL_MAXIMUM, &status);
if( (min!=0 || max!= 11 || gr_min!=0 || le_max!=60 || ac_min!=0 || ac_max!=60) &&
- (min>val>max) && val!=4){
+ (min>val && val>max) && val!=4){
log_err("FAIL: Min/max bad\n");
log_err("FAIL: Hour of Day %d out of range\n", val);
@@ -1273,4 +1275,50 @@ static void verify2(const char* msg, UCalendar* c, UDateFormat* dat, int32_t yea
}
+void TestGregorianChange() {
+ static const UChar utc[] = { 0x45, 0x74, 0x63, 0x2f, 0x47, 0x4d, 0x54, 0 }; /* "Etc/GMT" */
+ const int32_t dayMillis = 86400 * INT64_C(1000); /* 1 day = 86400 seconds */
+ UCalendar *cal;
+ UDate date;
+ UErrorCode errorCode = U_ZERO_ERROR;
+
+ /* Test ucal_setGregorianChange() on a Gregorian calendar. */
+ errorCode = U_ZERO_ERROR;
+ cal = ucal_open(utc, -1, "", UCAL_GREGORIAN, &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucal_open(UTC) failed: %s\n", u_errorName(errorCode));
+ return;
+ }
+ ucal_setGregorianChange(cal, -365 * (dayMillis * (UDate)1), &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucal_setGregorianChange(1969) failed: %s\n", u_errorName(errorCode));
+ } else {
+ date = ucal_getGregorianChange(cal, &errorCode);
+ if(U_FAILURE(errorCode) || date != -365 * (dayMillis * (UDate)1)) {
+ log_err("ucal_getGregorianChange() failed: %s, date = %f\n", u_errorName(errorCode), date);
+ }
+ }
+ ucal_close(cal);
+
+ /* Test ucal_setGregorianChange() on a non-Gregorian calendar where it should fail. */
+ errorCode = U_ZERO_ERROR;
+ cal = ucal_open(utc, -1, "th@calendar=buddhist", UCAL_TRADITIONAL, &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucal_open(UTC, non-Gregorian) failed: %s\n", u_errorName(errorCode));
+ return;
+ }
+ ucal_setGregorianChange(cal, -730 * (dayMillis * (UDate)1), &errorCode);
+ if(errorCode != U_UNSUPPORTED_ERROR) {
+ log_err("ucal_setGregorianChange(non-Gregorian calendar) did not yield U_UNSUPPORTED_ERROR but %s\n",
+ u_errorName(errorCode));
+ }
+ errorCode = U_ZERO_ERROR;
+ date = ucal_getGregorianChange(cal, &errorCode);
+ if(errorCode != U_UNSUPPORTED_ERROR) {
+ log_err("ucal_getGregorianChange(non-Gregorian calendar) did not yield U_UNSUPPORTED_ERROR but %s\n",
+ u_errorName(errorCode));
+ }
+ ucal_close(cal);
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/Build/source/libs/icu-xetex/test/cintltst/ccapitst.c b/Build/source/libs/icu-xetex/test/cintltst/ccapitst.c
index dfe75b05f35..daa73bd5aeb 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/ccapitst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/ccapitst.c
@@ -1,16 +1,16 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
-/********************************************************************************
+/*******************************************************************************
*
* File CU_CAPITST.C
*
* Modification History:
* Name Description
* Madhu Katragadda Ported for C API
-*********************************************************************************
+********************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
@@ -22,6 +22,7 @@
#include "unicode/putil.h"
#include "unicode/ustring.h"
#include "ucnv_bld.h" /* for sizeof(UConverter) */
+#include "cmemory.h" /* for UAlignedMemory */
#include "cintltst.h"
#include "ccapitst.h"
@@ -100,13 +101,21 @@ static void TestCCSID(void);
static void TestJ932(void);
static void TestJ1968(void);
static void TestLMBCSMaxChar(void);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestConvertSafeCloneCallback(void);
+#endif
+
static void TestEBCDICSwapLFNL(void);
static void TestConvertEx(void);
static void TestConvertAlgorithmic(void);
void TestDefaultConverterError(void); /* defined in cctest.c */
static void TestToUCountPending(void);
-static void TestFromUCountPending(void);
+static void TestFromUCountPending(void);
+static void TestDefaultName(void);
+static void TestCompareNames(void);
+static void TestSubstString(void);
+
void addTestConvert(TestNode** root);
void addTestConvert(TestNode** root)
@@ -116,8 +125,12 @@ void addTestConvert(TestNode** root)
addTest(root, &TestFlushCache, "tsconv/ccapitst/TestFlushCache");
addTest(root, &TestAlias, "tsconv/ccapitst/TestAlias");
addTest(root, &TestDuplicateAlias, "tsconv/ccapitst/TestDuplicateAlias");
- addTest(root, &TestConvertSafeClone, "tsconv/ccapitst/TestConvertSafeClone");
- addTest(root, &TestConvertSafeCloneCallback,"tsconv/ccapitst/TestConvertSafeCloneCallback");
+ addTest(root, &TestConvertSafeClone, "tsconv/ccapitst/TestConvertSafeClone");
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
+ addTest(root, &TestConvertSafeCloneCallback,"tsconv/ccapitst/TestConvertSafeCloneCallback");
+#endif
+
addTest(root, &TestCCSID, "tsconv/ccapitst/TestCCSID");
addTest(root, &TestJ932, "tsconv/ccapitst/TestJ932");
addTest(root, &TestJ1968, "tsconv/ccapitst/TestJ1968");
@@ -128,6 +141,9 @@ void addTestConvert(TestNode** root)
addTest(root, &TestDefaultConverterError, "tsconv/ccapitst/TestDefaultConverterError");
addTest(root, &TestToUCountPending, "tsconv/ccapitst/TestToUCountPending");
addTest(root, &TestFromUCountPending, "tsconv/ccapitst/TestFromUCountPending");
+ addTest(root, &TestDefaultName, "tsconv/ccapitst/TestDefaultName");
+ addTest(root, &TestCompareNames, "tsconv/ccapitst/TestCompareNames");
+ addTest(root, &TestSubstString, "tsconv/ccapitst/TestSubstString");
}
static void ListNames(void) {
@@ -153,7 +169,10 @@ static void ListNames(void) {
count1++;
log_verbose("read \"%s\", length %i\n", string, len);
}
- err = U_ZERO_ERROR;
+ if (U_FAILURE(err)) {
+ log_err("FAILURE! uenum_next(allNamesEnum...) set an error: %s\n", u_errorName(err));
+ err = U_ZERO_ERROR;
+ }
uenum_reset(allNamesEnum, &err);
while ((string = uenum_next(allNamesEnum, &len, &err))) {
count2++;
@@ -241,6 +260,7 @@ static void ListNames(void) {
static void TestConvert()
{
+#if !UCONFIG_NO_LEGACY_CONVERSION
char myptr[4];
char save[4];
int32_t testLong1 = 0;
@@ -511,23 +531,6 @@ static void TestConvert()
log_verbose("getName(someConverters[1]) returned %s\n", ucnv_getName(someConverters[1], &err));
}
- /*Testing ucnv_getDefaultName() and ucnv_setDefaultNAme()*/
- {
- static char defaultName[UCNV_MAX_CONVERTER_NAME_LENGTH + 1];
- strcpy(defaultName, ucnv_getDefaultName());
-
- log_verbose("getDefaultName returned %s\n", defaultName);
-
- /*change the default name by setting it */
- ucnv_setDefaultName("changed");
- if(strcmp(ucnv_getDefaultName(), "changed")==0)
- log_verbose("setDefaultName o.k");
- else
- log_err("setDefaultName failed");
- /*set the default name back*/
- ucnv_setDefaultName(defaultName);
- }
-
ucnv_close(someConverters[0]);
ucnv_close(someConverters[1]);
ucnv_close(someConverters[2]);
@@ -1067,6 +1070,7 @@ static void TestConvert()
free((void*)output_cp_buffer);
free((void*)ucs_file_buffer);
free((void*)my_ucs_file_buffer);
+#endif
}
static UConverterFromUCallback otherUnicodeAction(UConverterFromUCallback MIA)
@@ -1081,6 +1085,7 @@ static UConverterToUCallback otherCharAction(UConverterToUCallback MIA)
}
static void TestFlushCache(void) {
+#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode err = U_ZERO_ERROR;
UConverter* someConverters[5];
int flushCount = 0;
@@ -1150,7 +1155,7 @@ static void TestFlushCache(void) {
log_verbose("Flush cache ok\n");
else
log_data_err("Flush Cache failed line %d, expected 1 got %d \n", __LINE__, flushCount);
-
+#endif
}
/**
@@ -1399,6 +1404,7 @@ static void TSCC_fromU(const void *context,
UErrorCode subErr = U_ZERO_ERROR;
TSCCContext *newCtx;
TSCCContext *junkCtx;
+ TSCCContext **pjunkCtx = &junkCtx;
/* "recreate" it */
log_verbose("TSCC_fromU: cloning..\n");
@@ -1409,7 +1415,7 @@ static void TSCC_fromU(const void *context,
}
/* now, SET it */
- ucnv_getFromUCallBack(fromUArgs->converter, &junkFrom, (const void**)&junkCtx);
+ ucnv_getFromUCallBack(fromUArgs->converter, &junkFrom, (const void**)pjunkCtx);
ucnv_setFromUCallBack(fromUArgs->converter, junkFrom, newCtx, NULL, NULL, &subErr);
if(U_FAILURE(subErr)) {
@@ -1445,6 +1451,7 @@ static void TSCC_toU(const void *context,
UErrorCode subErr = U_ZERO_ERROR;
TSCCContext *newCtx;
TSCCContext *junkCtx;
+ TSCCContext **pjunkCtx = &junkCtx;
/* "recreate" it */
log_verbose("TSCC_toU: cloning..\n");
@@ -1455,7 +1462,7 @@ static void TSCC_toU(const void *context,
}
/* now, SET it */
- ucnv_getToUCallBack(toUArgs->converter, &junkFrom, (const void**)&junkCtx);
+ ucnv_getToUCallBack(toUArgs->converter, &junkFrom, (const void**)pjunkCtx);
ucnv_setToUCallBack(toUArgs->converter, junkFrom, newCtx, NULL, NULL, &subErr);
if(U_FAILURE(subErr)) {
@@ -1490,11 +1497,13 @@ static void TSCC_print_log(TSCCContext *q, const char *name)
}
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestConvertSafeCloneCallback()
{
UErrorCode err = U_ZERO_ERROR;
TSCCContext from1, to1;
TSCCContext *from2, *from3, *to2, *to3;
+ TSCCContext **pfrom2 = &from2, **pfrom3 = &from3, **pto2 = &to2, **pto3 = &to3;
char hunk[8192];
int32_t hunkSize = 8192;
UConverterFromUCallback junkFrom;
@@ -1532,8 +1541,8 @@ static void TestConvertSafeCloneCallback()
log_verbose("Cloned to conv2=%p.\n", conv2);
/********** from *********************/
- ucnv_getFromUCallBack(conv2, &junkFrom, (const void**)&from2);
- ucnv_getFromUCallBack(conv1, &junkFrom, (const void**)&from3);
+ ucnv_getFromUCallBack(conv2, &junkFrom, (const void**)pfrom2);
+ ucnv_getFromUCallBack(conv1, &junkFrom, (const void**)pfrom3);
TSCC_print_log(from2, "from2");
TSCC_print_log(from3, "from3(==from1)");
@@ -1565,8 +1574,8 @@ static void TestConvertSafeCloneCallback()
}
/********** to *********************/
- ucnv_getToUCallBack(conv2, &junkTo, (const void**)&to2);
- ucnv_getToUCallBack(conv1, &junkTo, (const void**)&to3);
+ ucnv_getToUCallBack(conv2, &junkTo, (const void**)pto2);
+ ucnv_getToUCallBack(conv1, &junkTo, (const void**)pto3);
TSCC_print_log(to2, "to2");
TSCC_print_log(to3, "to3(==to1)");
@@ -1654,6 +1663,7 @@ static void TestConvertSafeCloneCallback()
free(from2); /* from1 is stack based */
}
}
+#endif
static UBool
containsAnyOtherByte(uint8_t *p, int32_t length, uint8_t b) {
@@ -1671,28 +1681,39 @@ static void TestConvertSafeClone()
{
/* one 'regular' & all the 'private stateful' converters */
static const char *const names[] = {
+#if !UCONFIG_NO_LEGACY_CONVERSION
"ibm-1047",
"ISO_2022,locale=zh,version=1",
+#endif
"SCSU",
+#if !UCONFIG_NO_LEGACY_CONVERSION
"HZ",
"lmbcs",
"ISCII,version=0",
"ISO_2022,locale=kr,version=1",
"ISO_2022,locale=jp,version=2",
+#endif
"BOCU-1",
"UTF-7",
+#if !UCONFIG_NO_LEGACY_CONVERSION
"IMAP-mailbox-name",
"ibm-1047-s390"
+#else
+ "IMAP=mailbox-name"
+#endif
};
+ /* store the actual sizes of each converter */
+ int32_t actualSizes[LENGTHOF(names)];
+
static const int32_t bufferSizes[] = {
U_CNV_SAFECLONE_BUFFERSIZE,
(int32_t)(3*sizeof(UConverter))/2, /* 1.5*sizeof(UConverter) */
(int32_t)sizeof(UConverter)/2 /* 0.5*sizeof(UConverter) */
};
- char charBuffer [21]; /* Leave at an odd number for alignment testing */
- uint8_t buffer [3] [U_CNV_SAFECLONE_BUFFERSIZE];
+ char charBuffer[21]; /* Leave at an odd number for alignment testing */
+ uint8_t buffer[3] [U_CNV_SAFECLONE_BUFFERSIZE];
int32_t bufferSize, maxBufferSize;
const char *maxName;
UConverter * cnv, *cnv2;
@@ -1701,9 +1722,9 @@ static void TestConvertSafeClone()
char *pCharBuffer;
const char *pConstCharBuffer;
const char *charBufferLimit = charBuffer + sizeof(charBuffer)/sizeof(*charBuffer);
- UChar uniBuffer [] = {0x0058, 0x0059, 0x005A}; /* "XYZ" */
- UChar uniCharBuffer [20];
- char charSourceBuffer [] = { 0x1b, 0x24, 0x42 };
+ UChar uniBuffer[] = {0x0058, 0x0059, 0x005A}; /* "XYZ" */
+ UChar uniCharBuffer[20];
+ char charSourceBuffer[] = { 0x1b, 0x24, 0x42 };
const char *pCharSource = charSourceBuffer;
const char *pCharSourceLimit = charSourceBuffer + sizeof(charSourceBuffer);
UChar *pUCharTarget = uniCharBuffer;
@@ -1808,10 +1829,10 @@ static void TestConvertSafeClone()
if(j == 0) {
/* preflight to get maxBufferSize */
- bufferSize = 0;
- ucnv_safeClone(cnv, NULL, &bufferSize, &err);
- if(bufferSize > maxBufferSize) {
- maxBufferSize = bufferSize;
+ actualSizes[index] = 0;
+ ucnv_safeClone(cnv, NULL, &actualSizes[index], &err);
+ if(actualSizes[index] > maxBufferSize) {
+ maxBufferSize = actualSizes[index];
maxName = names[index];
}
}
@@ -1824,6 +1845,12 @@ static void TestConvertSafeClone()
/* close the original immediately to make sure that the clone works by itself */
ucnv_close(cnv);
+ if( actualSizes[index] <= (bufferSizes[j] - (int32_t)sizeof(UAlignedMemory)) &&
+ err == U_SAFECLONE_ALLOCATED_WARNING
+ ) {
+ log_err("ucnv_safeClone(%s) did a heap clone although the buffer was large enough\n", names[index]);
+ }
+
/* check if the clone function overwrote any bytes that it is not supposed to touch */
if(bufferSize <= bufferSizes[j]) {
/* used the stack buffer */
@@ -1880,9 +1907,14 @@ static void TestConvertSafeClone()
log_verbose("ucnv_safeClone(): sizeof(UConverter)=%lu max preflighted clone size=%d (%s) U_CNV_SAFECLONE_BUFFERSIZE=%d\n",
sizeof(UConverter), maxBufferSize, maxName, (int)U_CNV_SAFECLONE_BUFFERSIZE);
+ if(maxBufferSize > U_CNV_SAFECLONE_BUFFERSIZE) {
+ log_err("ucnv_safeClone(): max preflighted clone size=%d (%s) is larger than U_CNV_SAFECLONE_BUFFERSIZE=%d\n",
+ maxBufferSize, maxName, (int)U_CNV_SAFECLONE_BUFFERSIZE);
+ }
}
static void TestCCSID() {
+#if !UCONFIG_NO_LEGACY_CONVERSION
UConverter *cnv;
UErrorCode errorCode;
int32_t ccsids[]={ 37, 850, 943, 949, 950, 1047, 1252, 1392, 33722 };
@@ -1909,6 +1941,7 @@ static void TestCCSID() {
ucnv_close(cnv);
}
+#endif
}
/* jitterbug 932: ucnv_convert() bugs --------------------------------------- */
@@ -1946,6 +1979,7 @@ TestJ932(void)
*/
static void bug1()
{
+#if !UCONFIG_NO_LEGACY_CONVERSION
static char char_in[CHUNK_SIZE+32];
static char char_out[CHUNK_SIZE*2];
@@ -1985,6 +2019,7 @@ static void bug1()
log_err("error j932 bug 1: expected success, got U_TRUNCATED_CHAR_FOUND\n");
}
}
+#endif
}
/* bug2: pre-flighting loop bug: simple overflow causes bug */
@@ -2059,6 +2094,7 @@ static void bug2()
*/
static void bug3()
{
+#if !UCONFIG_NO_LEGACY_CONVERSION
static char char_in[CHUNK_SIZE*4];
static char target[5];
UErrorCode err = U_ZERO_ERROR;
@@ -2113,6 +2149,7 @@ static void bug3()
*/
log_data_err("error j932 bug 3b: expected 0x%04x, got 0x%04x\n", sizeof(char_in) * 2, size);
}
+#endif
}
static void
@@ -2221,6 +2258,7 @@ convertExMultiStreaming(UConverter *srcCnv, UConverter *targetCnv,
}
static void TestConvertEx() {
+#if !UCONFIG_NO_LEGACY_CONVERSION
static const uint8_t
utf8[]={
/* 4e00 30a1 ff61 0410 */
@@ -2349,12 +2387,24 @@ static void TestConvertEx() {
log_err("ucnv_convertEx(*source==NULL) sets %s\n", u_errorName(errorCode));
}
+ /* streaming conversion without a pivot buffer */
+ errorCode=U_ZERO_ERROR;
+ src=srcBuffer;
+ pivotSource=pivotBuffer;
+ ucnv_convertEx(cnv2, cnv1, &target, targetBuffer+sizeof(targetBuffer), &src, NULL,
+ NULL, &pivotSource, &pivotTarget, pivotBuffer+1, TRUE, FALSE, &errorCode);
+ if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("ucnv_convertEx(pivotStart==NULL) sets %s\n", u_errorName(errorCode));
+ }
+
ucnv_close(cnv1);
ucnv_close(cnv2);
+#endif
}
static void
TestConvertAlgorithmic() {
+#if !UCONFIG_NO_LEGACY_CONVERSION
static const uint8_t
utf8[]={
/* 4e00 30a1 ff61 0410 */
@@ -2475,6 +2525,7 @@ TestConvertAlgorithmic() {
log_err("ucnv_fromAlgorithmic(illegal alg. type) sets %s\n", u_errorName(errorCode));
}
ucnv_close(cnv);
+#endif
}
static void TestLMBCSMaxChar(void) {
@@ -2634,6 +2685,7 @@ static void TestJ1968(void) {
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void
testSwap(const char *name, UBool swap) {
/*
@@ -2787,10 +2839,17 @@ TestEBCDICSwapLFNL() {
testSwap(tests[i].name, tests[i].swap);
}
}
+#else
+static void
+TestEBCDICSwapLFNL() {
+ /* test nothing... */
+}
+#endif
+
static const UVersionInfo ICU_34 = {3,4,0,0};
static void TestFromUCountPending(){
-
+#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode status = U_ZERO_ERROR;
/* const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0xfffd}; */
static const struct {
@@ -2889,10 +2948,12 @@ static void TestFromUCountPending(){
}
}
ucnv_close(cnv);
+#endif
}
static void
TestToUCountPending(){
+#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode status = U_ZERO_ERROR;
static const struct {
char input[6];
@@ -3000,5 +3061,188 @@ TestToUCountPending(){
}
ucnv_close(cnv);
}
+#endif
+}
+
+static void TestOneDefaultNameChange(const char *name) {
+ UErrorCode status = U_ZERO_ERROR;
+ UConverter *cnv;
+ ucnv_setDefaultName(name);
+ if(strcmp(ucnv_getDefaultName(), name)==0)
+ log_verbose("setDefaultName of %s works.\n", name);
+ else
+ log_err("setDefaultName of %s failed\n", name);
+ cnv=ucnv_open(NULL, &status);
+ if (U_FAILURE(status) || cnv == NULL) {
+ log_err("opening the default converter of %s failed\n", name);
+ return;
+ }
+ if(strcmp(ucnv_getName(cnv, &status), name)==0)
+ log_verbose("ucnv_getName of %s works.\n", name);
+ else
+ log_err("ucnv_getName of %s failed\n", name);
+ ucnv_close(cnv);
+}
+
+static void TestDefaultName(void) {
+ /*Testing ucnv_getDefaultName() and ucnv_setDefaultNAme()*/
+ static char defaultName[UCNV_MAX_CONVERTER_NAME_LENGTH + 1];
+ strcpy(defaultName, ucnv_getDefaultName());
+
+ log_verbose("getDefaultName returned %s\n", defaultName);
+
+ /*change the default name by setting it */
+ TestOneDefaultNameChange("UTF-8");
+#if !UCONFIG_NO_LEGACY_CONVERSION
+ TestOneDefaultNameChange("ISCII,version=1");
+ TestOneDefaultNameChange("ISCII,version=2");
+#endif
+ TestOneDefaultNameChange("ISO-8859-1");
+
+ /*set the default name back*/
+ ucnv_setDefaultName(defaultName);
+}
+
+/* Test that ucnv_compareNames() matches names according to spec. ----------- */
+
+static U_INLINE int
+sign(int n) {
+ if(n==0) {
+ return 0;
+ } else if(n<0) {
+ return -1;
+ } else /* n>0 */ {
+ return 1;
+ }
+}
+
+static void
+compareNames(const char **names) {
+ const char *relation, *name1, *name2;
+ int rel, result;
+
+ relation=*names++;
+ if(*relation=='=') {
+ rel = 0;
+ } else if(*relation=='<') {
+ rel = -1;
+ } else {
+ rel = 1;
+ }
+
+ name1=*names++;
+ if(name1==NULL) {
+ return;
+ }
+ while((name2=*names++)!=NULL) {
+ result=ucnv_compareNames(name1, name2);
+ if(sign(result)!=rel) {
+ log_err("ucnv_compareNames(\"%s\", \"%s\")=%d, sign!=%d\n", name1, name2, result, rel);
+ }
+ name1=name2;
+ }
+}
+static void
+TestCompareNames() {
+ static const char *equalUTF8[]={ "=", "UTF-8", "utf_8", "u*T@f08", "Utf 8", NULL };
+ static const char *equalIBM[]={ "=", "ibm-37", "IBM037", "i-B-m 00037", "ibm-0037", "IBM00037", NULL };
+ static const char *lessMac[]={ "<", "macos-0_1-10.2", "macos-1-10.0.2", "macos-1-10.2", NULL };
+ static const char *lessUTF080[]={ "<", "UTF-0008", "utf$080", "u*T@f0800", "Utf 0000000009", NULL };
+
+ compareNames(equalUTF8);
+ compareNames(equalIBM);
+ compareNames(lessMac);
+ compareNames(lessUTF080);
+}
+
+static void
+TestSubstString() {
+ static const UChar surrogate[1]={ 0xd900 };
+ char buffer[16];
+
+ static const UChar sub[5]={ 0x61, 0x62, 0x63, 0x64, 0x65 };
+ static const char subChars[5]={ 0x61, 0x62, 0x63, 0x64, 0x65 };
+ UConverter *cnv;
+ UErrorCode errorCode;
+ int32_t length;
+ int8_t len8;
+
+ /* UTF-16/32: test that the BOM is output before the sub character */
+ errorCode=U_ZERO_ERROR;
+ cnv=ucnv_open("UTF-16", &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucnv_open(UTF-16) failed - %s\n", u_errorName(errorCode));
+ return;
+ }
+ length=ucnv_fromUChars(cnv, buffer, (int32_t)sizeof(buffer), surrogate, 1, &errorCode);
+ ucnv_close(cnv);
+ if(U_FAILURE(errorCode) ||
+ length!=4 ||
+ NULL == ucnv_detectUnicodeSignature(buffer, length, NULL, &errorCode)
+ ) {
+ log_err("ucnv_fromUChars(UTF-16, U+D900) did not write a BOM\n");
+ }
+
+ errorCode=U_ZERO_ERROR;
+ cnv=ucnv_open("UTF-32", &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucnv_open(UTF-32) failed - %s\n", u_errorName(errorCode));
+ return;
+ }
+ length=ucnv_fromUChars(cnv, buffer, (int32_t)sizeof(buffer), surrogate, 1, &errorCode);
+ ucnv_close(cnv);
+ if(U_FAILURE(errorCode) ||
+ length!=8 ||
+ NULL == ucnv_detectUnicodeSignature(buffer, length, NULL, &errorCode)
+ ) {
+ log_err("ucnv_fromUChars(UTF-32, U+D900) did not write a BOM\n");
+ }
+
+ /* Simple API test of ucnv_setSubstString() + ucnv_getSubstChars(). */
+ errorCode=U_ZERO_ERROR;
+ cnv=ucnv_open("ISO-8859-1", &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucnv_open(ISO-8859-1) failed - %s\n", u_errorName(errorCode));
+ return;
+ }
+ ucnv_setSubstString(cnv, sub, LENGTHOF(sub), &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucnv_setSubstString(ISO-8859-1, sub[5]) failed - %s\n", u_errorName(errorCode));
+ } else {
+ len8 = sizeof(buffer);
+ ucnv_getSubstChars(cnv, buffer, &len8, &errorCode);
+ /* Stateless converter, we expect the string converted to charset bytes. */
+ if(U_FAILURE(errorCode) || len8!=sizeof(subChars) || 0!=uprv_memcmp(buffer, subChars, len8)) {
+ log_err("ucnv_getSubstChars(ucnv_setSubstString(ISO-8859-1, sub[5])) failed - %s\n", u_errorName(errorCode));
+ }
+ }
+ ucnv_close(cnv);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
+ errorCode=U_ZERO_ERROR;
+ cnv=ucnv_open("HZ", &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucnv_open(HZ) failed - %s\n", u_errorName(errorCode));
+ return;
+ }
+ ucnv_setSubstString(cnv, sub, LENGTHOF(sub), &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucnv_setSubstString(HZ, sub[5]) failed - %s\n", u_errorName(errorCode));
+ } else {
+ len8 = sizeof(buffer);
+ ucnv_getSubstChars(cnv, buffer, &len8, &errorCode);
+ /* Stateful converter, we expect that the Unicode string was set and that we get an empty char * string now. */
+ if(U_FAILURE(errorCode) || len8!=0) {
+ log_err("ucnv_getSubstChars(ucnv_setSubstString(HZ, sub[5])) failed - %s\n", u_errorName(errorCode));
+ }
+ }
+ ucnv_close(cnv);
+#endif
+ /*
+ * Further testing of ucnv_setSubstString() is done via intltest convert.
+ * We do not test edge cases of illegal arguments and similar because the
+ * function implementation uses all of its parameters in calls to other
+ * functions with UErrorCode parameters.
+ */
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cdattst.c b/Build/source/libs/icu-xetex/test/cintltst/cdattst.c
index 728a1165f8c..3fcdb47e3c0 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cdattst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cdattst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -126,9 +126,9 @@ static void TestDateFormat()
for(i=0;i<numlocales;i++) {
UErrorCode subStatus = U_ZERO_ERROR;
log_verbose("Testing open of %s\n", udat_getAvailable(i));
- any = udat_open(UDAT_SHORT, UDAT_SHORT, udat_getAvailable(i), NULL ,0, NULL, 0, &status);
+ any = udat_open(UDAT_SHORT, UDAT_SHORT, udat_getAvailable(i), NULL ,0, NULL, 0, &subStatus);
if(U_FAILURE(subStatus)) {
- log_data_err("FAIL: date format %s (getAvailable(%d)) is not instantiable: %s\n", udat_getAvailable(i), i, u_errorName(subStatus));
+ log_data_err("FAIL: date format %s (getAvailable(%d)) is not instantiable: %s\n", udat_getAvailable(i), i, u_errorName(subStatus));
}
udat_close(any);
}
@@ -395,6 +395,7 @@ static void TestSymbols()
if(udat_countSymbols(def, UDAT_ERAS)!=2 || udat_countSymbols(def, UDAT_MONTHS)!=12 ||
udat_countSymbols(def, UDAT_SHORT_MONTHS)!=12 || udat_countSymbols(def, UDAT_WEEKDAYS)!=8 ||
udat_countSymbols(def, UDAT_SHORT_WEEKDAYS)!=8 || udat_countSymbols(def, UDAT_AM_PMS)!=2 ||
+ udat_countSymbols(def, UDAT_QUARTERS) != 4 || udat_countSymbols(def, UDAT_SHORT_QUARTERS) != 4 ||
udat_countSymbols(def, UDAT_LOCALIZED_CHARS)!=1)
{
log_err("FAIL: error in udat_countSymbols\n");
@@ -445,6 +446,10 @@ static void TestSymbols()
VerifygetSymbols(def, UDAT_AM_PMS, 1, "PM");
VerifygetSymbols(fr, UDAT_SHORT_MONTHS, 0, "janv.");
VerifygetSymbols(def, UDAT_SHORT_MONTHS, 11, "Dec");
+ VerifygetSymbols(fr, UDAT_QUARTERS, 0, "1er trimestre");
+ VerifygetSymbols(def, UDAT_QUARTERS, 3, "4th quarter");
+ VerifygetSymbols(fr, UDAT_SHORT_QUARTERS, 1, "T2");
+ VerifygetSymbols(def, UDAT_SHORT_QUARTERS, 2, "Q3");
VerifygetSymbols(def,UDAT_LOCALIZED_CHARS, 0, "GyMdkHmsSEDFwWahKzYeugAZvcL");
@@ -541,11 +546,24 @@ free(pattern);
/*run series of tests to test setSymbols regressively*/
log_verbose("\nTesting setSymbols regressively\n");
- VerifysetSymbols(def, UDAT_WEEKDAYS, 1, "Sundayweek");
VerifysetSymbols(def, UDAT_ERAS, 0, "BeforeChrist");
+ VerifysetSymbols(def, UDAT_ERA_NAMES, 1, "AnnoDomini");
+ VerifysetSymbols(def, UDAT_WEEKDAYS, 1, "Sundayweek");
VerifysetSymbols(def, UDAT_SHORT_WEEKDAYS, 7, "Satweek");
+ VerifysetSymbols(def, UDAT_NARROW_WEEKDAYS, 4, "M");
+ VerifysetSymbols(def, UDAT_STANDALONE_WEEKDAYS, 1, "Sonntagweek");
+ VerifysetSymbols(def, UDAT_STANDALONE_SHORT_WEEKDAYS, 7, "Sams");
+ VerifysetSymbols(def, UDAT_STANDALONE_NARROW_WEEKDAYS, 4, "V");
VerifysetSymbols(fr, UDAT_MONTHS, 11, "december");
VerifysetSymbols(fr, UDAT_SHORT_MONTHS, 0, "Jan");
+ VerifysetSymbols(fr, UDAT_NARROW_MONTHS, 1, "R");
+ VerifysetSymbols(fr, UDAT_STANDALONE_MONTHS, 11, "dezember");
+ VerifysetSymbols(fr, UDAT_STANDALONE_SHORT_MONTHS, 7, "Aug");
+ VerifysetSymbols(fr, UDAT_STANDALONE_NARROW_MONTHS, 2, "M");
+ VerifysetSymbols(fr, UDAT_QUARTERS, 0, "1. Quart");
+ VerifysetSymbols(fr, UDAT_SHORT_QUARTERS, 1, "QQ2");
+ VerifysetSymbols(fr, UDAT_STANDALONE_QUARTERS, 2, "3rd Quar.");
+ VerifysetSymbols(fr, UDAT_STANDALONE_SHORT_QUARTERS, 3, "4QQ");
/*run series of tests to test get and setSymbols regressively*/
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cdtdptst.c b/Build/source/libs/icu-xetex/test/cintltst/cdtdptst.c
index 31391eb4ccf..d19b7eedac4 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cdtdptst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cdtdptst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -233,11 +233,11 @@ void TestCzechMonths459()
UErrorCode status = U_ZERO_ERROR;
UChar *date;
- ctest_setTimeZone(NULL, &status);
+ ctest_setTimeZone(NULL, &status);
fmt = udat_open(UDAT_FULL, UDAT_FULL, "cs", NULL, 0, NULL, 0, &status);
if(U_FAILURE(status)){
log_err("Error in constructing the date format\n");
- ctest_resetTimeZone();
+ ctest_resetTimeZone();
return;
}
lneed=0;
@@ -267,10 +267,17 @@ void TestCzechMonths459()
}
d = udat_parse(fmt, juneStr, u_strlen(juneStr), &pos, &status);
date = myDateFormat(fmt, d);
- if(u_strcmp(myDateFormat(fmt, june), myDateFormat(fmt, d) ) !=0)
- log_err("Error in handling the czech month june\n");
- else
- log_verbose("Pass: Date = %s (czech month June)\n", aescstrdup(date, -1));
+
+ if(U_SUCCESS(status)){
+ UChar* out1 = myDateFormat(fmt, june);
+ UChar* out2 = myDateFormat(fmt, d);
+ if(u_strcmp(out1, out2) !=0)
+ log_err("Error in handling the czech month june\n");
+ else
+ log_verbose("Pass: Date = %s (czech month June)\n", aescstrdup(date, -1));
+ }else{
+ log_err("udat_parse failed. Error. %s\n",u_errorName(status));
+ }
pos=0;
d = udat_parse(fmt, julyStr, u_strlen(julyStr), &pos, &status);
date = myDateFormat(fmt, d);
@@ -279,7 +286,7 @@ void TestCzechMonths459()
else
log_verbose("Pass: Date = %s (czech month July)\n", aescstrdup(date, -1));
- ctest_resetTimeZone();
+ ctest_resetTimeZone();
udat_close(fmt);
ucal_close(cal);
free(pattern);
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cdtrgtst.c b/Build/source/libs/icu-xetex/test/cintltst/cdtrgtst.c
index 7d5b3cbd1ab..3ef0f780af0 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cdtrgtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cdtrgtst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2003, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -179,7 +179,10 @@ void Test4056591()
gotdate=myFormatit(def, got);
expdate=myFormatit(def, exp);
- if(u_strcmp(gotdate, expdate) !=0){
+ if (gotdate == NULL || expdate == NULL) {
+ log_err("myFormatit failed!\n");
+ }
+ else if(u_strcmp(gotdate, expdate) !=0){
log_err("set2DigitYearStart broken for %s \n got: %s, expected: %s\n", austrdup(s),
austrdup(gotdate), austrdup(expdate) );
}
@@ -191,6 +194,7 @@ void Test4056591()
/**
+ * SimpleDateFormat does not properly parse date strings without delimiters
* @bug 4059917
*/
void Test4059917()
@@ -219,7 +223,7 @@ void Test4059917()
udat_close(def);
u_uastrcpy(pattern, "yyyyMMdd");
- def = udat_open(UDAT_IGNORE,UDAT_IGNORE,NULL,NULL,0,pattern, u_strlen(pattern),&status);
+ def = udat_open(UDAT_IGNORE,UDAT_IGNORE,NULL,tzID,-1,pattern, u_strlen(pattern),&status);
if(U_FAILURE(status))
{
log_err("FAIL: error in creating the dateformat using openPattern: %s\n", myErrorName(status));
@@ -388,48 +392,46 @@ void Test4073003()
return;
}
u_uastrcpy(temp, "m/D/yy");
- udat_applyPattern(fmt, TRUE, temp, u_strlen(temp));
+ udat_applyPattern(fmt, FALSE, temp, u_strlen(temp));
+
+ for(i= 0; i < 4; i+=2) {
+ status=U_ZERO_ERROR;
+ datestr=(UChar*)malloc(sizeof(UChar) * (strlen(tests[i])+1));
+ u_uastrcpy(datestr, tests[i]);
+
+ pos=0;
+ d = udat_parse(fmt, datestr, u_strlen(datestr), &pos, &status);
+ if(U_FAILURE(status)){
+ log_err("ERROR : in test 4073003: %s\n", myErrorName(status));
+ }
+
+ free(datestr);
+ datestr=(UChar*)malloc(sizeof(UChar) * (strlen(tests[i+1])+1));
+ u_uastrcpy(datestr, tests[i+1]);
- for(i= 0; i < 4; i+=2) {
- status=U_ZERO_ERROR;
- datestr=(UChar*)malloc(sizeof(UChar) * (strlen(tests[i])+1));
- u_uastrcpy(datestr, tests[i]);
-
- pos=0;
- d = udat_parse(fmt, datestr, u_strlen(datestr), &pos, &status);
- if(U_FAILURE(status)){
- log_err("ERROR : in test 4073003: %s\n", myErrorName(status));
- }
-
- free(datestr);
- datestr=(UChar*)malloc(sizeof(UChar) * (strlen(tests[i+1])+1));
- u_uastrcpy(datestr, tests[i+1]);
+ pos=0;
+ status=U_ZERO_ERROR;
+ dd = udat_parse(fmt, datestr, u_strlen(datestr), &pos, &status);
+ if(U_FAILURE(status)){
+ log_err("ERROR : in test 4073003: %s\n", myErrorName(status));
+ }
+ free(datestr);
- pos=0;
- status=U_ZERO_ERROR;
- dd = udat_parse(fmt, datestr, u_strlen(datestr), &pos, &status);
- if(U_FAILURE(status)){
- log_err("ERROR : in test 4073003: %s\n", myErrorName(status));
- }
- free(datestr);
-
- result =myFormatit(fmt, d);
- result2 =myFormatit(fmt, dd);
- if(!result || !result2) {
- log_data_err("Fail: could not format - exitting test");
- return;
- }
- if (u_strcmp(result, result2)!=0){
- log_err("Fail: %s != %s\n", austrdup(result), austrdup(result2) );
- }
- else{
+ result =myFormatit(fmt, d);
+ result2 =myFormatit(fmt, dd);
+ if(!result || !result2) {
+ log_data_err("Fail: could not format - exitting test\n");
+ return;
+ }
+ if (u_strcmp(result, result2)!=0){
+ log_err("Fail: %s != %s\n", austrdup(result), austrdup(result2) );
+ }
+ else{
log_verbose("Ok: %s == %s\n", austrdup(result), austrdup(result2) );
- }
-
-
-
}
- udat_close(fmt);
+
+ }
+ udat_close(fmt);
}
/**
@@ -455,12 +457,12 @@ void Test4162071()
pos=0;
x = udat_parse(df, datestr, u_strlen(datestr), &pos, &status);
if(U_FAILURE(status)){
- log_data_err("ERROR : parse format %s fails : %s\n", austrdup(format), myErrorName(status));
- }
+ log_data_err("ERROR : parse format %s fails : %s\n", austrdup(format), myErrorName(status));
+ }
else{
log_verbose("Parse format \"%s \" ok.\n", austrdup(format) );
}
- log_verbose("date= %s\n", austrdup(myFormatit(df, x)) );
+ /*log_verbose("date= %s\n", austrdup(myFormatit(df, x)) );*/
udat_close(df);
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/chashtst.c b/Build/source/libs/icu-xetex/test/cintltst/chashtst.c
index 8dd66b45189..c70ae2bca5d 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/chashtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/chashtst.c
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 2000-2004, International Business Machines
+* Copyright (C) 2000-2005, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* Date Name Description
@@ -103,7 +103,7 @@ static void TestBasic(void) {
UErrorCode status = U_ZERO_ERROR;
UHashtable *hash;
- hash = uhash_open(hashChars, isEqualChars, &status);
+ hash = uhash_open(hashChars, isEqualChars, NULL, &status);
if (U_FAILURE(status)) {
log_err("FAIL: uhash_open failed with %s and returned 0x%08x\n",
u_errorName(status), hash);
@@ -163,7 +163,7 @@ static void TestOtherAPI(void){
static const UChar five[6] = {0x0066, 0x0069, 0x0076, 0x0065, 0}; /* L"five" */
static const UChar five2[6] = {0x0066, 0x0069, 0x0076, 0x0065, 0}; /* L"five" */
- hash = uhash_open(uhash_hashUChars, uhash_compareUChars, &status);
+ hash = uhash_open(uhash_hashUChars, uhash_compareUChars, NULL, &status);
if (U_FAILURE(status)) {
log_err("FAIL: uhash_open failed with %s and returned 0x%08x\n",
u_errorName(status), hash);
@@ -287,7 +287,7 @@ static void hashIChars(void) {
UErrorCode status = U_ZERO_ERROR;
UHashtable *hash;
- hash = uhash_open(uhash_hashIChars, uhash_compareIChars, &status);
+ hash = uhash_open(uhash_hashIChars, uhash_compareIChars, NULL, &status);
if (U_FAILURE(status)) {
log_err("FAIL: uhash_open failed with %s and returned 0x%08x\n",
u_errorName(status), hash);
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cintltst.vcproj b/Build/source/libs/icu-xetex/test/cintltst/cintltst.vcproj
index ed6a9b2bfcc..6f6a923d41c 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cintltst.vcproj
+++ b/Build/source/libs/icu-xetex/test/cintltst/cintltst.vcproj
@@ -28,6 +28,7 @@
RuntimeLibrary="1"
BufferSecurityCheck="TRUE"
DisableLanguageExtensions="TRUE"
+ TreatWChar_tAsBuiltInType="TRUE"
PrecompiledHeaderFile=".\Debug/cintltst.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
@@ -90,6 +91,7 @@
BufferSecurityCheck="TRUE"
EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE"
+ TreatWChar_tAsBuiltInType="TRUE"
PrecompiledHeaderFile=".\Release/cintltst.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
@@ -268,9 +270,6 @@
RelativePath=".\trietest.c">
</File>
<File
- RelativePath=".\ucmptst.c">
- </File>
- <File
RelativePath=".\uenumtst.c">
</File>
</Filter>
@@ -319,6 +318,9 @@
<File
RelativePath=".\stdnmtst.c">
</File>
+ <File
+ RelativePath=".\ucsdetst.c">
+ </File>
</Filter>
<Filter
Name="data &amp; memory"
@@ -476,9 +478,6 @@
RelativePath=".\cucdtst.c">
</File>
<File
- RelativePath=".\cucdtst.h">
- </File>
- <File
RelativePath=".\usettest.c">
</File>
</Filter>
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cldrtest.c b/Build/source/libs/icu-xetex/test/cintltst/cldrtest.c
index eba37fa5129..fe4716eddee 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cldrtest.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cldrtest.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@@ -16,7 +16,51 @@
#include "locmap.h"
#include "uresimp.h"
-static UBool isCurrencyPreEuro(const char* currencyKey){
+/*--------------------------------------------------------------------
+ Time bomb - allows temporary behavior that expires at a given
+ release
+ ---------------------------------------------------------------------*/
+static const UVersionInfo ICU_37 = {3,7,0,0};
+
+/*
+returns a new UnicodeSet that is a flattened form of the original
+UnicodeSet.
+*/
+static USet*
+createFlattenSet(USet *origSet, UErrorCode *status) {
+
+
+ USet *newSet = NULL;
+ int32_t origItemCount = 0;
+ int32_t idx, graphmeSize;
+ UChar32 start, end;
+ UChar graphme[64];
+ if (U_FAILURE(*status)) {
+ log_err("createFlattenSet called with %s\n", u_errorName(*status));
+ return NULL;
+ }
+ newSet = uset_open(1, 0);
+ origItemCount = uset_getItemCount(origSet);
+ for (idx = 0; idx < origItemCount; idx++) {
+ graphmeSize = uset_getItem(origSet, idx,
+ &start, &end,
+ graphme, (int32_t)(sizeof(graphme)/sizeof(graphme[0])),
+ status);
+ if (U_FAILURE(*status)) {
+ log_err("ERROR: uset_getItem returned %s\n", u_errorName(*status));
+ *status = U_ZERO_ERROR;
+ }
+ if (graphmeSize) {
+ uset_addAllCodePoints(newSet, graphme, graphmeSize);
+ }
+ else {
+ uset_addRange(newSet, start, end);
+ }
+ }
+ return newSet;
+}
+static UBool
+isCurrencyPreEuro(const char* currencyKey){
if( strcmp(currencyKey, "PTE") == 0 ||
strcmp(currencyKey, "ESP") == 0 ||
strcmp(currencyKey, "LUF") == 0 ||
@@ -117,26 +161,8 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName,
if (U_SUCCESS(errorCode)
&& (ures_getType(subSubBundle) == URES_ARRAY || ures_getType(subSubRootBundle) == URES_ARRAY))
{
- /* TODO: Properly check for 2D arrays and zoneStrings */
- if (subBundleKey != NULL && strcmp(subBundleKey, "zoneStrings") == 0) {
-/* int32_t minSize = ures_getSize(subBundle);
- int32_t idx;
-
- for (idx = 0; idx < minSize; idx++) {
- UResourceBundle *subSubBundleAtIndex = ures_getByIndex(subBundle, idx, NULL, &errorCode);
- if (ures_getSize(subSubBundleAtIndex) != 6) {
- log_err("zoneStrings at index %d has wrong size for locale \"%s\". array size=%d\n",
- idx,
- locale,
- ures_getSize(subSubBundleAtIndex));
- }
- ures_close(subSubBundleAtIndex);
- }*/
- }
- else {
- /* Here is one of the recursive parts */
- TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale);
- }
+ /* Here is one of the recursive parts */
+ TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale);
}
else {
int32_t minSize = ures_getSize(subRootBundle);
@@ -283,7 +309,8 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName,
subBundleKey,
ures_getKey(currentBundle),
locale);
- } else if (strcmp(subBundleKey, "localPatternChars") == 0) {
+ } else if (strcmp(subBundleKey, "localPatternChars") == 0 &&
+ isICUVersionAtLeast(ICU_37)) {
/* Check well-formedness of localPatternChars. First, the
* length must match the number of fields defined by
* DateFormat. Second, each character in the string must
@@ -348,8 +375,13 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName,
#endif
}
else if (ures_getType(subBundle) == URES_TABLE) {
- /* Here is one of the recursive parts */
- TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale);
+ if (strcmp(subBundleKey, "availableFormats")!=0) {
+ /* Here is one of the recursive parts */
+ TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale);
+ }
+ else {
+ log_verbose("Skipping key %s in %s\n", subBundleKey, locale);
+ }
}
else if (ures_getType(subBundle) == URES_BINARY || ures_getType(subBundle) == URES_INT) {
/* Can't do anything to check it */
@@ -737,17 +769,21 @@ findStringSetMismatch(const char *currLoc, const UChar *string, int32_t langSize
const UChar *exemplarCharacters, int32_t exemplarLen,
UBool ignoreNumbers) {
UErrorCode errorCode = U_ZERO_ERROR;
- USet *exemplarSet = uset_openPatternOptions(exemplarCharacters, exemplarLen, USET_CASE_INSENSITIVE, &errorCode);
+ USet *origSet = uset_openPatternOptions(exemplarCharacters, exemplarLen, USET_CASE_INSENSITIVE, &errorCode);
+ USet *exemplarSet = createFlattenSet(origSet, &errorCode);
int32_t strIdx;
+ uset_close(origSet);
if (U_FAILURE(errorCode)) {
- log_err("%s: error uset_openPattern returned %s\n", currLoc, u_errorName(errorCode));
+ log_err("%s: error uset_openPattern returned %s\n", currLoc, u_errorName(errorCode));
return -1;
}
for (strIdx = 0; strIdx < langSize; strIdx++) {
if (!uset_contains(exemplarSet, string[strIdx])
- && string[strIdx] != 0x0020 && string[strIdx] != 0x00A0 && string[strIdx] != 0x002e && string[strIdx] != 0x002c && string[strIdx] != 0x002d && string[strIdx] != 0x0027) {
+ && string[strIdx] != 0x0020 && string[strIdx] != 0x00A0 && string[strIdx] != 0x002e && string[strIdx] != 0x002c && string[strIdx] != 0x002d && string[strIdx] != 0x0027
+ && string[strIdx] != 0x200C && string[strIdx] != 0x200D) {
if (!ignoreNumbers || (ignoreNumbers && (string[strIdx] < 0x30 || string[strIdx] > 0x39))) {
+ uset_close(exemplarSet);
return strIdx;
}
}
@@ -755,7 +791,19 @@ findStringSetMismatch(const char *currLoc, const UChar *string, int32_t langSize
uset_close(exemplarSet);
return -1;
}
-
+/* include non-invariant chars */
+static int32_t
+myUCharsToChars(const UChar* us, char* cs, int32_t len){
+ int32_t i=0;
+ for(; i< len; i++){
+ if(us[i] < 0x7f){
+ cs[i] = (char)us[i];
+ }else{
+ return -1;
+ }
+ }
+ return i;
+}
static void
findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen,
USet *exemplarSet,
@@ -797,7 +845,7 @@ findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen,
UChar32 end = 0;
UChar *str = NULL;
int32_t strCapacity = 0;
-
+
strCapacity = uset_getItem(exemplarSet, i, &start, &end, str, strCapacity, &status);
if(U_SUCCESS(status)){
int32_t j;
@@ -809,6 +857,16 @@ findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen,
}
}
if(existsInScript == FALSE){
+ for( j = 0; j < scriptsLen; j++){
+ UChar toPattern[500]={'\0'};
+ char pat[500]={'\0'};
+ int32_t len = uset_toPattern(scripts[j], toPattern, 500, TRUE, &status);
+ len = myUCharsToChars(toPattern, pat, len);
+ log_err("uset_indexOf(\\u%04X)=%i uset_indexOf(\\u%04X)=%i\n", start, uset_indexOf(scripts[0], start), end, uset_indexOf(scripts[0], end));
+ if(len!=-1){
+ log_err("Pattern: %s\n",pat);
+ }
+ }
log_err("ExemplarCharacters and LocaleScript containment test failed for locale %s. \n", locale);
}
}else{
@@ -840,10 +898,6 @@ findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen,
}
static void VerifyTranslation(void) {
-#if U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM == 4
- /* Disabled until the CLDR data can be fixed. */
- return;
-#else
UResourceBundle *root, *currentLocale;
int32_t locCount = uloc_countAvailable();
int32_t locIndex;
@@ -857,7 +911,6 @@ static void VerifyTranslation(void) {
int32_t end;
UResourceBundle *resArray;
- log_err("This test fails in exhaustive mode. Please fix the CLDR data\n");
if (locCount <= 1) {
log_data_err("At least root needs to be installed\n");
}
@@ -1031,7 +1084,6 @@ static void VerifyTranslation(void) {
}
ures_close(root);
-#endif
}
/* adjust this limit as appropriate */
@@ -1043,6 +1095,7 @@ static void TestExemplarSet(void){
UErrorCode ec = U_ZERO_ERROR;
UEnumeration* avail;
USet* exemplarSets[2];
+ USet* unassignedSet;
UScriptCode code[MAX_SCRIPTS_PER_LOCALE];
USet* codeSets[MAX_SCRIPTS_PER_LOCALE];
int32_t codeLen;
@@ -1053,7 +1106,9 @@ static void TestExemplarSet(void){
int32_t strLen;
UChar32 start, end;
- exemplarSets[0] = exemplarSets[1] = NULL;
+ unassignedSet = NULL;
+ exemplarSets[0] = NULL;
+ exemplarSets[1] = NULL;
for (i=0; i<MAX_SCRIPTS_PER_LOCALE; ++i) {
codeSets[i] = NULL;
}
@@ -1063,6 +1118,10 @@ static void TestExemplarSet(void){
n = uenum_count(avail, &ec);
if (!assertSuccess("uenum_count", &ec)) goto END;
+ u_uastrcpy(ubuf, "[:unassigned:]");
+ unassignedSet = uset_openPattern(ubuf, -1, &ec);
+ if (!assertSuccess("uset_openPattern", &ec)) goto END;
+
for(i=0; i<n; i++){
const char* locale = uenum_next(avail, NULL, &ec);
if (!assertSuccess("uenum_next", &ec)) goto END;
@@ -1076,6 +1135,9 @@ static void TestExemplarSet(void){
exemplarSets[k] = exemplarSet;
if (!assertSuccess("ulocaledata_getExemplarSet", &ec)) goto END;
+ if (uset_containsSome(exemplarSet, unassignedSet)) {
+ log_err("ExemplarSet contains unassigned characters for locale : %s\n", locale);
+ }
codeLen = uscript_getCode(locale, code, 8, &ec);
if (!assertSuccess("uscript_getCode", &ec)) goto END;
@@ -1085,6 +1147,10 @@ static void TestExemplarSet(void){
}
for (j=0; j<codeLen; ++j) {
uprv_strcpy(cbuf, "[:");
+ if(code[j]==-1){
+ log_err("USCRIPT_INVALID_CODE returned for locale: %s\n", locale);
+ continue;
+ }
uprv_strcat(cbuf, uscript_getShortName(code[j]));
uprv_strcat(cbuf, ":]");
u_uastrcpy(ubuf, cbuf);
@@ -1101,14 +1167,14 @@ static void TestExemplarSet(void){
if (!assertSuccess("uset_getItem", &ec)) goto END;
if (strLen == 0) {
for (j=0; j<codeLen; ++j) {
- if (uset_containsRange(codeSets[j], start, end)) {
+ if (codeSets[j]!=NULL && uset_containsRange(codeSets[j], start, end)) {
existsInScript = TRUE;
break;
}
}
} else {
for (j=0; j<codeLen; ++j) {
- if (uset_containsString(codeSets[j], ubuf, strLen)) {
+ if (codeSets[j]!=NULL && uset_containsString(codeSets[j], ubuf, strLen)) {
existsInScript = TRUE;
break;
}
@@ -1135,11 +1201,45 @@ static void TestExemplarSet(void){
uenum_close(avail);
uset_close(exemplarSets[0]);
uset_close(exemplarSets[1]);
+ uset_close(unassignedSet);
for (i=0; i<MAX_SCRIPTS_PER_LOCALE; ++i) {
uset_close(codeSets[i]);
}
}
+static void TestCoverage(void){
+ ULocaleDataDelimiterType types[] = {
+ ULOCDATA_QUOTATION_START, /* Quotation start */
+ ULOCDATA_QUOTATION_END, /* Quotation end */
+ ULOCDATA_ALT_QUOTATION_START, /* Alternate quotation start */
+ ULOCDATA_ALT_QUOTATION_END, /* Alternate quotation end */
+ ULOCDATA_DELIMITER_COUNT
+ };
+ int i;
+ UBool sub;
+ UErrorCode status = U_ZERO_ERROR;
+ ULocaleData *uld = ulocdata_open(uloc_getDefault(), &status);
+
+ if(U_FAILURE(status)){
+ log_err("ulocdata_open error");
+ return;
+ }
+
+
+ for(i = 0; i < ULOCDATA_DELIMITER_COUNT; i++){
+ UChar result[32] = {0,};
+ status = U_ZERO_ERROR;
+ ulocdata_getDelimiter(uld, types[i], result, 32, &status);
+ if (U_FAILURE(status)){
+ log_err("ulocdata_getgetDelimiter error with type %d", types[i]);
+ }
+ }
+
+ sub = ulocdata_getNoSubstitute(uld);
+ ulocdata_setNoSubstitute(uld,sub);
+ ulocdata_close(uld);
+}
+
static void TestCurrencyList(void){
#if !UCONFIG_NO_FORMATTING
UErrorCode errorCode = U_ZERO_ERROR;
@@ -1186,4 +1286,5 @@ void addCLDRTest(TestNode** root)
TESTCASE(VerifyTranslation);
TESTCASE(TestExemplarSet);
TESTCASE(TestCurrencyList);
+ TESTCASE(TestCoverage);
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cloctst.c b/Build/source/libs/icu-xetex/test/cintltst/cloctst.c
index 4d7bb6b2cb5..d4253384198 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cloctst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cloctst.c
@@ -1,16 +1,16 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
-/********************************************************************************
+/*******************************************************************************
*
* File CLOCTST.C
*
* Modification History:
* Name Description
* Madhu Katragadda Ported for C API
-*********************************************************************************
+********************************************************************************
*/
#include "cloctst.h"
#include <stdlib.h>
@@ -19,6 +19,7 @@
#include "cintltst.h"
#include "cstring.h"
#include "uparse.h"
+#include "uresimp.h"
#include "unicode/putil.h"
#include "unicode/ubrk.h"
@@ -37,6 +38,7 @@
static void TestNullDefault(void);
static void TestNonexistentLanguageExemplars(void);
+static void TestLanguageExemplarsFallbacks(void);
void PrintDataTable();
@@ -64,7 +66,7 @@ static const char* rawData2[LOCALE_INFO_SIZE][LOCALE_SIZE] = {
/* ISO-3 country */
{ "USA", "FRA", "ESP", "GRC", "NOR", "CHN", "DEU", "", "JPN" },
/* LCID */
- { "409", "40c", "403", "408", "814", "804", "407", "a", "411" },
+ { "409", "40c", "403", "408", "814", "804", "10407", "40a", "411" },
/* display language (English) */
{ "English", "French", "Catalan", "Greek", "Norwegian", "Chinese", "German", "Spanish", "Japanese" },
@@ -82,14 +84,14 @@ static const char* rawData2[LOCALE_INFO_SIZE][LOCALE_SIZE] = {
/* display language (French) */
{ "anglais", "fran\\u00E7ais", "catalan", "grec", "norv\\u00E9gien", "chinois", "allemand", "espagnol", "japonais" },
/* display script code (French) */
- { "", "", "", "", "", "han simplifi\\u00E9", "", "", "" },
+ { "", "", "", "", "", "id\\u00e9ogrammes han (variante simplifi\\u00e9e)", "", "", "" },
/* display country (French) */
{ "\\u00C9tats-Unis", "France", "Espagne", "Gr\\u00E8ce", "Norv\\u00E8ge", "Chine", "Allemagne", "", "Japon" },
/* display variant (French) */
{ "", "", "", "", "NY", "", "", "", "" },
/* display name (French) */
{ "anglais (\\u00C9tats-Unis)", "fran\\u00E7ais (France)", "catalan (Espagne)",
- "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)", "chinois (han simplifi\\u00E9, Chine)",
+ "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)", "chinois (id\\u00e9ogrammes han (variante simplifi\\u00e9e), Chine)",
"allemand (Allemagne, Ordonnancement=Ordre de l\\u2019annuaire)", "espagnol (Ordonnancement=Ordre traditionnel)", "japonais (Japon, Calendrier=Calendrier japonais)" },
/* display language (Catalan) */
@@ -206,7 +208,6 @@ void addLocaleTest(TestNode** root)
TESTCASE(TestUninstalledISO3Names);
TESTCASE(TestSimpleDisplayNames);
TESTCASE(TestVariantParsing);
- /*TESTCASE(MoreVariants);*/
TESTCASE(TestKeywordVariants);
TESTCASE(TestKeywordVariantParsing);
TESTCASE(TestCanonicalization);
@@ -218,7 +219,14 @@ void addLocaleTest(TestNode** root)
TESTCASE(TestGetLocale);
TESTCASE(TestDisplayNameWarning);
TESTCASE(TestNonexistentLanguageExemplars);
- TESTCASE(TestAcceptLanguage);
+ TESTCASE(TestLanguageExemplarsFallbacks);
+ TESTCASE(TestCalendar);
+ TESTCASE(TestDateFormat);
+ TESTCASE(TestCollation);
+ TESTCASE(TestULocale);
+ TESTCASE(TestUResourceBundle);
+ TESTCASE(TestDisplayName);
+ TESTCASE(TestAcceptLanguage);
}
@@ -925,7 +933,7 @@ static void TestISOFunctions()
if(!strcmp(test,"ZR"))
log_err("FAIL getISOCountries() has obsolete country code %s\n", test);
}
- expect=240;
+ expect=244;
if(count!=expect)
{
log_err("There is an error in getISOCountries, got %d, expected %d \n", count, expect);
@@ -1347,35 +1355,6 @@ static void TestObsoleteNames(void)
}
-static void MoreVariants(void)
-{
- struct {
- const char *localeID;
- const char *keyword;
- const char *expectedValue;
- } testCases[] = {
- { "de_DE_EURO@collation=PHONEBOOK", "collation", "PHONEBOOK" },
- { "es_ES.utf8@euro", "collation", ""},
- { "es_ES.hello.utf8@euro", "", "" },
- { " s pa c e d _ more spaces _ spaced variant ", "", ""}
- };
-
- UErrorCode status = U_ZERO_ERROR;
-
- int32_t i = 0;
- int32_t resultLen = 0;
- char buffer[256];
-
- for(i = 0; i < sizeof(testCases)/sizeof(testCases[0]); i++) {
- *buffer = 0;
- resultLen = uloc_getName(testCases[i].localeID, buffer, 256, &status);
- if(uprv_strcmp(testCases[i].expectedValue, buffer) != 0) {
- log_err("Expected to extract \"%s\" from \"%s\" for keyword \"%s\". Got \"%s\" instead\n",
- testCases[i].expectedValue, testCases[i].localeID, testCases[i].keyword, buffer);
- }
- }
-}
-
static void TestKeywordVariants(void)
{
struct {
@@ -1737,8 +1716,9 @@ static void TestCanonicalization(void)
{ "en-BOONT", "en_BOONT", "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 */
@@ -1770,7 +1750,10 @@ static void TestCanonicalization(void)
{ "root@kw=foo", "root@kw=foo", "root@kw=foo" },
{ "@calendar=gregorian", "@calendar=gregorian", "@calendar=gregorian" },
{ "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese", "ja_JP@calendar=Japanese" },
- { "ja_JP", "ja_JP", "ja_JP" }
+ { "ja_JP", "ja_JP", "ja_JP" },
+
+ /* test case for "i-default" */
+ { "i-default", NULL, NULL }
};
static const char* label[] = { "getName", "canonicalize" };
@@ -1784,6 +1767,11 @@ static void TestCanonicalization(void)
const char* expected = (j==0) ? testCases[i].getNameID : testCases[i].canonicalID;
*buffer = 0;
status = U_ZERO_ERROR;
+
+ if (expected == NULL) {
+ expected = uloc_getDefault();
+ }
+
/* log_verbose("testing %s -> %s\n", testCases[i], testCases[i].canonicalID); */
origResultLen = _canonicalize(j, testCases[i].localeID, NULL, 0, &status);
if (status != U_BUFFER_OVERFLOW_ERROR) {
@@ -2267,13 +2255,32 @@ static void TestNonexistentLanguageExemplars(void) {
/* JB 4068 - Nonexistent language */
UErrorCode ec = U_ZERO_ERROR;
ULocaleData *uld = ulocdata_open("qqq",&ec);
- USet *nothing = ulocdata_getExemplarSet(uld, NULL, 0, ULOCDATA_ES_STANDARD, &ec);
- uset_close(nothing);
- ulocdata_close(uld);
if (ec != U_USING_DEFAULT_WARNING) {
log_err("Exemplar set for \"qqq\", expecting U_USING_DEFAULT_WARNING, but got %s\n",
u_errorName(ec));
}
+ uset_close(ulocdata_getExemplarSet(uld, NULL, 0, ULOCDATA_ES_STANDARD, &ec));
+ ulocdata_close(uld);
+}
+
+static void TestLanguageExemplarsFallbacks(void) {
+ /* Test that en_US fallsback, but en doesn't fallback. */
+ UErrorCode ec = U_ZERO_ERROR;
+ ULocaleData *uld = ulocdata_open("en_US",&ec);
+ uset_close(ulocdata_getExemplarSet(uld, NULL, 0, ULOCDATA_ES_STANDARD, &ec));
+ if (ec != U_USING_FALLBACK_WARNING) {
+ log_err("Exemplar set for \"en_US\", expecting U_USING_FALLBACK_WARNING, but got %s\n",
+ u_errorName(ec));
+ }
+ ulocdata_close(uld);
+ ec = U_ZERO_ERROR;
+ uld = ulocdata_open("en",&ec);
+ uset_close(ulocdata_getExemplarSet(uld, NULL, 0, ULOCDATA_ES_STANDARD, &ec));
+ if (ec != U_ZERO_ERROR) {
+ log_err("Exemplar set for \"en\", expecting U_ZERO_ERROR, but got %s\n",
+ u_errorName(ec));
+ }
+ ulocdata_close(uld);
}
static void TestAcceptLanguage(void) {
@@ -2337,3 +2344,280 @@ static void TestAcceptLanguage(void) {
}
}
}
+
+static const char* LOCALE_ALIAS[][2] = {
+ {"in", "id"},
+ {"in_ID", "id_ID"},
+ {"iw", "he"},
+ {"iw_IL", "he_IL"},
+ {"ji", "yi"},
+ {"en_BU", "en_MM"},
+ {"en_DY", "en_BJ"},
+ {"en_HV", "en_BF"},
+ {"en_NH", "en_VU"},
+ {"en_RH", "en_ZW"},
+ {"en_TP", "en_TL"},
+ {"en_ZR", "en_CD"}
+};
+static UBool isLocaleAvailable(UResourceBundle* resIndex, const char* loc){
+ UErrorCode status = U_ZERO_ERROR;
+ int32_t len = 0;
+ ures_getStringByKey(resIndex, loc,&len, &status);
+ if(U_FAILURE(status)){
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void TestCalendar() {
+#if !UCONFIG_NO_FORMATTING
+ int i;
+ UErrorCode status = U_ZERO_ERROR;
+ UResourceBundle *resIndex = ures_open(NULL,"res_index", &status);
+ if(U_FAILURE(status)){
+ log_err("Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
+ return;
+ }
+ for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+ const char* oldLoc = LOCALE_ALIAS[i][0];
+ const char* newLoc = LOCALE_ALIAS[i][1];
+ UCalendar* c1 = NULL;
+ UCalendar* c2 = NULL;
+
+ /*Test function "getLocale(ULocale.VALID_LOCALE)"*/
+ const char* l1 = ucal_getLocaleByType(c1, ULOC_VALID_LOCALE, &status);
+ const char* l2 = ucal_getLocaleByType(c2, ULOC_VALID_LOCALE, &status);
+
+ if(!isLocaleAvailable(resIndex, newLoc)){
+ continue;
+ }
+ c1 = ucal_open(NULL, -1, oldLoc, UCAL_GREGORIAN, &status);
+ c2 = ucal_open(NULL, -1, newLoc, UCAL_GREGORIAN, &status);
+
+ if (strcmp(newLoc,l1)!=0 || strcmp(l1,l2)!=0 || status!=U_ZERO_ERROR) {
+ log_err("The locales are not equal!.Old: %s, New: %s \n", oldLoc, newLoc);
+ }
+ log_verbose("ucal_getLocaleByType old:%s new:%s\n", l1, l2);
+ ucal_close(c1);
+ ucal_close(c2);
+ }
+ ures_close(resIndex);
+#endif
+}
+
+static void TestDateFormat() {
+#if !UCONFIG_NO_FORMATTING
+ int i;
+ UErrorCode status = U_ZERO_ERROR;
+ UResourceBundle *resIndex = ures_open(NULL,"res_index", &status);
+ if(U_FAILURE(status)){
+ log_err("Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
+ return;
+ }
+ for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+ const char* oldLoc = LOCALE_ALIAS[i][0];
+ const char* newLoc = LOCALE_ALIAS[i][1];
+ UDateFormat* df1 = NULL;
+ UDateFormat* df2 = NULL;
+ const char* l1 = NULL;
+ const char* l2 = NULL;
+
+ if(!isLocaleAvailable(resIndex, newLoc)){
+ continue;
+ }
+ df1 = udat_open(UDAT_FULL, UDAT_FULL,oldLoc, NULL, 0, NULL, -1, &status);
+ df2 = udat_open(UDAT_FULL, UDAT_FULL,newLoc, NULL, 0, NULL, -1, &status);
+ if(U_FAILURE(status)){
+ log_err("Creation of date format failed %s\n", u_errorName(status));
+ return;
+ }
+ /*Test function "getLocale"*/
+ l1 = udat_getLocaleByType(df1, ULOC_VALID_LOCALE, &status);
+ l2 = udat_getLocaleByType(df2, ULOC_VALID_LOCALE, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the locale by type failed. %s\n", u_errorName(status));
+ }
+ if (strcmp(newLoc,l1)!=0 || strcmp(l1,l2)!=0) {
+ log_err("The locales are not equal!.Old: %s, New: %s \n", oldLoc, newLoc);
+ }
+ log_verbose("udat_getLocaleByType old:%s new:%s\n", l1, l2);
+ udat_close(df1);
+ udat_close(df2);
+ }
+ ures_close(resIndex);
+#endif
+}
+
+static void TestCollation() {
+#if !UCONFIG_NO_COLLATION
+ int i;
+ UErrorCode status = U_ZERO_ERROR;
+ UResourceBundle *resIndex = ures_open(NULL,"res_index", &status);
+ if(U_FAILURE(status)){
+ log_err("Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
+ return;
+ }
+ for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+ const char* oldLoc = LOCALE_ALIAS[i][0];
+ const char* newLoc = LOCALE_ALIAS[i][1];
+ UCollator* c1 = NULL;
+ UCollator* c2 = NULL;
+ const char* l1 = NULL;
+ const char* l2 = NULL;
+
+ status = U_ZERO_ERROR;
+ if(!isLocaleAvailable(resIndex, newLoc)){
+ continue;
+ }
+ if(U_FAILURE(status)){
+ log_err("Creation of collators failed %s\n", u_errorName(status));
+ return;
+ }
+ c1 = ucol_open(oldLoc, &status);
+ c2 = ucol_open(newLoc, &status);
+ l1 = ucol_getLocaleByType(c1, ULOC_VALID_LOCALE, &status);
+ l2 = ucol_getLocaleByType(c2, ULOC_VALID_LOCALE, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the locale names failed failed %s\n", u_errorName(status));
+ }
+ if (strcmp(newLoc,l1)!=0 || strcmp(l1,l2)!=0) {
+ log_err("The locales are not equal!.Old: %s, New: %s \n", oldLoc, newLoc);
+ }
+ log_verbose("ucol_getLocaleByType old:%s new:%s\n", l1, l2);
+ ucol_close(c1);
+ ucol_close(c2);
+ }
+ ures_close(resIndex);
+#endif
+}
+
+static void TestULocale() {
+ int i;
+ UErrorCode status = U_ZERO_ERROR;
+ UResourceBundle *resIndex = ures_open(NULL,"res_index", &status);
+ if(U_FAILURE(status)){
+ log_err("Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
+ return;
+ }
+ for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+ const char* oldLoc = LOCALE_ALIAS[i][0];
+ const char* newLoc = LOCALE_ALIAS[i][1];
+ UChar name1[256], name2[256];
+ char names1[256], names2[256];
+ int32_t capacity = 256;
+
+ status = U_ZERO_ERROR;
+ if(!isLocaleAvailable(resIndex, newLoc)){
+ continue;
+ }
+ uloc_getDisplayName(oldLoc, ULOC_US, name1, capacity, &status);
+ if(U_FAILURE(status)){
+ log_err("uloc_getDisplayName(%s) failed %s\n", oldLoc, u_errorName(status));
+ }
+
+ uloc_getDisplayName(newLoc, ULOC_US, name2, capacity, &status);
+ if(U_FAILURE(status)){
+ log_err("uloc_getDisplayName(%s) failed %s\n", newLoc, u_errorName(status));
+ }
+
+ if (u_strcmp(name1, name2)!=0) {
+ log_err("The locales are not equal!.Old: %s, New: %s \n", oldLoc, newLoc);
+ }
+ u_austrcpy(names1, name1);
+ u_austrcpy(names2, name2);
+ log_verbose("uloc_getDisplayName old:%s new:%s\n", names1, names2);
+ }
+ ures_close(resIndex);
+
+}
+
+static void TestUResourceBundle() {
+ const char* us1;
+ const char* us2;
+
+ UResourceBundle* rb1 = NULL;
+ UResourceBundle* rb2 = NULL;
+ UErrorCode status = U_ZERO_ERROR;
+ int i;
+ UResourceBundle *resIndex = NULL;
+ if(U_FAILURE(status)){
+ log_err("Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
+ return;
+ }
+ resIndex = ures_open(NULL,"res_index", &status);
+ for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+
+ const char* oldLoc = LOCALE_ALIAS[i][0];
+ const char* newLoc = LOCALE_ALIAS[i][1];
+ if(!isLocaleAvailable(resIndex, newLoc)){
+ continue;
+ }
+ rb1 = ures_open(NULL, oldLoc, &status);
+ if (U_FAILURE(U_ZERO_ERROR)) {
+ log_err("ures_open(%s) failed %s\n", oldLoc, u_errorName(status));
+ }
+
+ us1 = ures_getLocale(rb1, &status);
+
+ status = U_ZERO_ERROR;
+ rb2 = ures_open(NULL, newLoc, &status);
+ if (U_FAILURE(U_ZERO_ERROR)) {
+ log_err("ures_open(%s) failed %s\n", oldLoc, u_errorName(status));
+ }
+ us2 = ures_getLocale(rb2, &status);
+
+ if (strcmp(us1,newLoc)!=0 || strcmp(us1,us2)!=0 ) {
+ log_err("The locales are not equal!.Old: %s, New: %s \n", oldLoc, newLoc);
+ }
+
+ log_verbose("ures_getStringByKey old:%s new:%s\n", us1, us2);
+ ures_close(rb1);
+ rb1 = NULL;
+ ures_close(rb2);
+ rb2 = NULL;
+ }
+ ures_close(resIndex);
+}
+
+static void TestDisplayName() {
+
+ UChar oldCountry[256] = {'\0'};
+ UChar newCountry[256] = {'\0'};
+ UChar oldLang[256] = {'\0'};
+ UChar newLang[256] = {'\0'};
+ char country[256] ={'\0'};
+ char language[256] ={'\0'};
+ int32_t capacity = 256;
+ int i =0;
+ int j=0;
+ for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+ const char* oldLoc = LOCALE_ALIAS[i][0];
+ const char* newLoc = LOCALE_ALIAS[i][1];
+ UErrorCode status = U_ZERO_ERROR;
+ int32_t available = uloc_countAvailable();
+
+ for(j=0; j<available; j++){
+
+ const char* dispLoc = uloc_getAvailable(j);
+ int32_t oldCountryLen = uloc_getDisplayCountry(oldLoc,dispLoc, oldCountry, capacity, &status);
+ int32_t newCountryLen = uloc_getDisplayCountry(newLoc, dispLoc, newCountry, capacity, &status);
+ int32_t oldLangLen = uloc_getDisplayLanguage(oldLoc, dispLoc, oldLang, capacity, &status);
+ int32_t newLangLen = uloc_getDisplayLanguage(newLoc, dispLoc, newLang, capacity, &status );
+
+ int32_t countryLen = uloc_getCountry(newLoc, country, capacity, &status);
+ int32_t langLen = uloc_getLanguage(newLoc, language, capacity, &status);
+ /* there is a display name for the current country ID */
+ if(countryLen != newCountryLen ){
+ if(u_strncmp(oldCountry,newCountry,oldCountryLen)!=0){
+ log_err("uloc_getDisplayCountry() failed for %s in display locale %s \n", oldLoc, dispLoc);
+ }
+ }
+ /* there is a display name for the current lang ID */
+ if(langLen!=newLangLen){
+ if(u_strncmp(oldLang,newLang,oldLangLen)){
+ log_err("uloc_getDisplayLanguage() failed for %s in display locale %s \n", oldLoc, dispLoc); }
+ }
+ }
+ }
+}
+
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cloctst.h b/Build/source/libs/icu-xetex/test/cintltst/cloctst.h
index b419119804f..bc098b70fb8 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cloctst.h
+++ b/Build/source/libs/icu-xetex/test/cintltst/cloctst.h
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -61,9 +61,6 @@ static void TestDisplayNames(void);
**/
static void TestVariantParsing(void);
- /* Make sure we can pass "de_DE@Collation=PHONEBOOK" */
- static void MoreVariants(void);
-
/* Test getting keyword enumeratin */
static void TestKeywordVariants(void);
@@ -99,4 +96,16 @@ static void cleanUpDataTable(void);
/*static void displayDataTable(void);*/
static void TestAcceptLanguage(void);
+/**
+ * test locale aliases
+*/
+static void TestCalendar(void);
+static void TestDateFormat(void);
+static void TestCollation(void);
+static void TestULocale(void);
+static void TestUResourceBundle(void);
+static void TestDisplayName(void);
+
+static void TestAcceptLanguage(void);
+
#endif
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cmsccoll.c b/Build/source/libs/icu-xetex/test/cintltst/cmsccoll.c
index 17ebdae8997..8b193195512 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cmsccoll.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cmsccoll.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2001-2005, International Business Machines Corporation and
+ * Copyright (c) 2001-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*******************************************************************************
@@ -3296,7 +3296,7 @@ static void TestNewJapanese(void) {
static const char *test2[] = {
"\\u306f\\u309d", /* H\\u309d */
- /*"\\u30cf\\u30fd",*/ /* K\\u30fd */
+ "\\u30cf\\u30fd", /* K\\u30fd */
"\\u306f\\u306f", /* HH */
"\\u306f\\u30cf", /* HK */
"\\u30cf\\u30cf", /* KK */
@@ -3379,7 +3379,7 @@ static void TestStrCollIdenticalPrefix(void) {
"ab\\ud9b0\\udc70",
"ab\\ud9b0\\udc71"
};
- genericRulesTestWithResult(rule, test, sizeof(test)/sizeof(test[0]), UCOL_EQUAL);
+ genericRulesStarterWithResult(rule, test, sizeof(test)/sizeof(test[0]), UCOL_EQUAL);
}
/* Contractions should have all their canonically equivalent */
/* strings included */
@@ -3398,7 +3398,7 @@ static void TestContractionClosure(void) {
for(i = 0; i<(sizeof(tests)/sizeof(tests[0])); i++) {
- genericRulesTestWithResult(tests[i].rules, tests[i].data, tests[i].len, UCOL_EQUAL);
+ genericRulesStarterWithResult(tests[i].rules, tests[i].data, tests[i].len, UCOL_EQUAL);
}
}
@@ -3560,7 +3560,7 @@ static void TestRuleOptions(void) {
},
{ "&[last variable]<a &[before 3][last variable]<<<c<<<b ",
- { "c", "b", "\\uD802\\uDE47", "a", "\\u02d0" }, 5
+ { "c", "b", "\\uD834\\uDF71", "a", "\\u02d0" }, 5
},
{ "&[first regular]<a"
@@ -3570,7 +3570,7 @@ static void TestRuleOptions(void) {
{ "&[before 1][last regular]<b"
"&[last regular]<a",
- { "b", "\\uD800\\uDFCF", "a", "\\u4e00" }, 4
+ { "b", "\\uD808\\uDF6E", "a", "\\u4e00" }, 4
},
{ "&[before 1][first implicit]<b"
@@ -4637,9 +4637,12 @@ TestThaiSortKey(void)
UErrorCode status = U_ZERO_ERROR;
uint8_t key[256];
int32_t keyLen = 0;
+ /* NOTE: there is a Thai tailoring that moves Yammakan. It should not move it, */
+ /* since it stays in the same relative position. This should be addressed in CLDR */
/* UCA 4.0 uint8_t expectedKey[256] = { 0x01, 0xd9, 0xb2, 0x01, 0x05, 0x00 }; */
- /* UCA 4.1 moves Yammakan */
- uint8_t expectedKey[256] = { 0x01, 0xdb, 0x3a, 0x01, 0x05, 0x00 };
+ /* UCA 4.1 uint8_t expectedKey[256] = { 0x01, 0xdb, 0x3a, 0x01, 0x05, 0x00 }; */
+ /* UCA 5.0 moves Yammakan */
+ uint8_t expectedKey[256] = { 0x01, 0xdc, 0xce, 0x01, 0x05, 0x00 };
UCollator *coll = ucol_open("th", &status);
if(U_FAILURE(status)) {
log_err("Could not open a collator, exiting (%s)\n", u_errorName(status));
@@ -4654,6 +4657,101 @@ TestThaiSortKey(void)
ucol_close(coll);
}
+static void
+TestUpperFirstQuaternary(void)
+{
+ const char* tests[] = { "B", "b", "Bb", "bB" };
+ UColAttribute att[] = { UCOL_STRENGTH, UCOL_CASE_FIRST };
+ UColAttributeValue attVals[] = { UCOL_QUATERNARY, UCOL_UPPER_FIRST };
+ genericLocaleStarterWithOptions("root", tests, sizeof(tests)/sizeof(tests[0]), att, attVals, sizeof(att)/sizeof(att[0]));
+}
+
+static void
+TestJ4960(void)
+{
+ const char* tests[] = { "\\u00e2T", "aT" };
+ UColAttribute att[] = { UCOL_STRENGTH, UCOL_CASE_LEVEL };
+ UColAttributeValue attVals[] = { UCOL_PRIMARY, UCOL_ON };
+ const char* tests2[] = { "a", "A" };
+ const char* rule = "&[first tertiary ignorable]=A=a";
+ UColAttribute att2[] = { UCOL_CASE_LEVEL };
+ UColAttributeValue attVals2[] = { UCOL_ON };
+ /* Test whether we correctly ignore primary ignorables on case level when */
+ /* we have only primary & case level */
+ genericLocaleStarterWithOptionsAndResult("root", tests, sizeof(tests)/sizeof(tests[0]), att, attVals, sizeof(att)/sizeof(att[0]), UCOL_EQUAL);
+ /* Test whether ICU4J will make case level for sortkeys that have primary strength */
+ /* and case level */
+ genericLocaleStarterWithOptions("root", tests2, sizeof(tests2)/sizeof(tests2[0]), att, attVals, sizeof(att)/sizeof(att[0]));
+ /* Test whether completely ignorable letters have case level info (they shouldn't) */
+ genericRulesStarterWithOptionsAndResult(rule, tests2, sizeof(tests2)/sizeof(tests2[0]), att2, attVals2, sizeof(att2)/sizeof(att2[0]), UCOL_EQUAL);
+}
+
+static void
+TestJ5223(void)
+{
+ static const char *test = "this is a test string";
+ UChar ustr[256];
+ int32_t ustr_length = u_unescape(test, ustr, 256);
+ unsigned char sortkey[256];
+ int32_t sortkey_length;
+ UErrorCode status = U_ZERO_ERROR;
+ static UCollator *coll = NULL;
+ coll = ucol_open("root", &status);
+ if(U_FAILURE(status)) {
+ log_err("Couldn't open UCA\n");
+ return;
+ }
+ ucol_setStrength(coll, UCOL_PRIMARY);
+ ucol_setAttribute(coll, UCOL_STRENGTH, UCOL_PRIMARY, &status);
+ ucol_setAttribute(coll, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
+ if (U_FAILURE(status)) {
+ log_err("Failed setting atributes\n");
+ return;
+ }
+ sortkey_length = ucol_getSortKey(coll, ustr, ustr_length, NULL, 0);
+ if (sortkey_length > 256) return;
+
+ /* we mark the position where the null byte should be written in advance */
+ sortkey[sortkey_length-1] = 0xAA;
+
+ /* we set the buffer size one byte higher than needed */
+ sortkey_length = ucol_getSortKey(coll, ustr, ustr_length, sortkey,
+ sortkey_length+1);
+
+ /* no error occurs (for me) */
+ if (sortkey[sortkey_length-1] == 0xAA) {
+ log_err("Hit bug at first try\n");
+ }
+
+ /* we mark the position where the null byte should be written again */
+ sortkey[sortkey_length-1] = 0xAA;
+
+ /* this time we set the buffer size to the exact amount needed */
+ sortkey_length = ucol_getSortKey(coll, ustr, ustr_length, sortkey,
+ sortkey_length);
+
+ /* now the trailing null byte is not written */
+ if (sortkey[sortkey_length-1] == 0xAA) {
+ log_err("Hit bug at second try\n");
+ }
+
+ ucol_close(coll);
+}
+
+/* Regression test for Thai partial sort key problem */
+static void
+TestJ5232(void)
+{
+ const static char *test[] = {
+ "\\u0e40\\u0e01\\u0e47\\u0e1a\\u0e40\\u0e25\\u0e47\\u0e21",
+ "\\u0e40\\u0e01\\u0e47\\u0e1a\\u0e40\\u0e25\\u0e48\\u0e21"
+ };
+
+ genericLocaleStarter("th", test, sizeof(test)/sizeof(test[0]));
+}
+
+
+
#define TEST(x) addTest(root, &x, "tscoll/cmsccoll/" # x)
void addMiscCollTest(TestNode** root)
@@ -4718,6 +4816,10 @@ void addMiscCollTest(TestNode** root)
/*TEST(TestMoreBefore);*/
TEST(TestTailorNULL);
TEST(TestThaiSortKey);
+ TEST(TestUpperFirstQuaternary);
+ TEST(TestJ4960);
+ TEST(TestJ5223);
+ TEST(TestJ5232);
}
#endif /* #if !UCONFIG_NO_COLLATION */
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cmsgtst.c b/Build/source/libs/icu-xetex/test/cintltst/cmsgtst.c
index 72d08cad1d8..f35a755a70c 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cmsgtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cmsgtst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -42,7 +42,7 @@ static const char* const txt_testResultStrings[] = {
"Quotes ', {, a 1 {0}",
"Quotes ', {, a 1 {0}",
"You deposited 1 times an amount of $3,456.00 on 1/12/70",
- "{2,time,full}, for 3,456, 1 is 5:46:40 AM PST and full date is Monday, January 12, 1970",
+ "{2,time,full}, for 3,456, 1 is 5:46:40 AM PT and full date is Monday, January 12, 1970",
"{1,number,percent} for 1 is 345,600%"
};
@@ -257,7 +257,7 @@ static void MessageFormatTest( void )
/*test u_formatMessage() with sample patterns */
-static void TestSampleMessageFormat()
+static void TestSampleMessageFormat(void)
{
UChar *str;
UChar *result;
@@ -557,7 +557,7 @@ static void TestSampleFormatAndParseWithError(void)
}
/* Test u_formatMessage() and u_parseMessage() , format and parse sequence and round trip */
-static void TestSampleFormatAndParse()
+static void TestSampleFormatAndParse(void)
{
UChar *result, *tzID, *str;
@@ -650,7 +650,7 @@ static void TestSampleFormatAndParse()
}
/* test message format with a choice option */
-static void TestMsgFormatChoice()
+static void TestMsgFormatChoice(void)
{
UChar* str;
UErrorCode status = U_ZERO_ERROR;
@@ -737,7 +737,7 @@ static void TestMsgFormatChoice()
}
/*test u_parseMessage() with various test patterns */
-static void TestParseMessage()
+static void TestParseMessage(void)
{
UChar pattern[100];
UChar source[100];
@@ -1033,6 +1033,19 @@ static void MessageLength(void)
}
}
+static void TestErrorChaining(void) {
+ UErrorCode status = U_USELESS_COLLATOR_ERROR;
+
+ umsg_open(NULL, 0, NULL, NULL, &status);
+ umsg_applyPattern(NULL, NULL, 0, NULL, &status);
+ umsg_clone(NULL, &status);
+ umsg_close(NULL);
+
+ /* All of this code should have done nothing. */
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("Status got changed to %s\n", u_errorName(status));
+ }
+}
void addMsgForTest(TestNode** root);
@@ -1050,6 +1063,7 @@ void addMsgForTest(TestNode** root)
addTest(root, &TestParseMessageWithValist, "tsformat/cmsgtst/TestParseMessageWithValist");
addTest(root, &TestJ904, "tsformat/cmsgtst/TestJ904");
addTest(root, &MessageLength, "tsformat/cmsgtst/MessageLength");
+ addTest(root, &TestErrorChaining, "tsformat/cmsgtst/TestErrorChaining");
}
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cnmdptst.c b/Build/source/libs/icu-xetex/test/cintltst/cnmdptst.c
index 8b1f114c18b..24982323ade 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cnmdptst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cnmdptst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation
+ * Copyright (c) 1997-2006, International Business Machines Corporation
* and others. All Rights Reserved.
********************************************************************/
/*******************************************************************************
@@ -194,42 +194,44 @@ static void TestExponential(void)
double a;
UErrorCode status = U_ZERO_ERROR;
#ifdef OS390
- double val[] = { 0.01234, 123456789, 1.23e75, -3.141592653e-78 };
+ static const double val[] = { 0.01234, 123456789, 1.23e75, -3.141592653e-78 };
#else
- double val[] = { 0.01234, 123456789, 1.23e300, -3.141592653e-271 };
+ static const double val[] = { 0.01234, 123456789, 1.23e300, -3.141592653e-271 };
#endif
- const char* pat[] = { "0.####E0", "00.000E00", "##0.######E000", "0.###E0;[0.###E0]" };
- int32_t lval[] = { 0, -1, 1, 123456789 };
+ static const char* pat[] = { "0.####E0", "00.000E00", "##0.######E000", "0.###E0;[0.###E0]" };
+ static const int32_t lval[] = { 0, -1, 1, 123456789 };
- const char* valFormat[] =
+ static const char* valFormat[] =
{
"1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271",
- "12.340E-03", "12.346E07", "12.300E299", "-31.416E-272",
- "12.34E-003", "123.4568E006", "1.23E300", "-314.1593E-273",
- "1.234E-2", "1.235E8", "1.23E300", "[3.142E-271]"
+ "12.340E-03", "12.346E07", "12.300E299", "-31.416E-272",
+ "12.34E-003", "123.4568E006", "1.23E300", "-314.1593E-273",
+ "1.234E-2", "1.235E8", "1.23E300", "[3.142E-271]"
};
- const char* lvalFormat[] =
+ static const char* lvalFormat[] =
{
"0E0", "-1E0", "1E0", "1.2346E8",
- "00.000E00", "-10.000E-01", "10.000E-01", "12.346E07",
- "0E000", "-1E000", "1E000", "123.4568E006",
- "0E0", "[1E0]", "1E0", "1.235E8"
+ "00.000E00", "-10.000E-01", "10.000E-01", "12.346E07",
+ "0E000", "-1E000", "1E000", "123.4568E006",
+ "0E0", "[1E0]", "1E0", "1.235E8"
};
- double valParse[] =
+ static const double valParse[] =
{
#ifdef OS390
0.01234, 123460000, 1.23E75, -3.1416E-78,
- 0.01234, 123460000, 1.23E75, -3.1416E-78,
- 0.01234, 123456800, 1.23E75, -3.141593E-78,
- 0.01234, 123500000, 1.23E75, -3.142E-78
+ 0.01234, 123460000, 1.23E75, -3.1416E-78,
+ 0.01234, 123456800, 1.23E75, -3.141593E-78,
+ 0.01234, 123500000, 1.23E75, -3.142E-78
#else
- 0.01234, 123460000, 1.23E300, -3.1416E-271,
- 0.01234, 123460000, 1.23E300, -3.1416E-271,
- 0.01234, 123456800, 1.23E300, -3.141593E-271,
- 0.01234, 123500000, 1.23E300, -3.142E-271
+ /* We define the whole IEEE 754 number in the 4th column because
+ Visual Age 7 has a bug in rounding numbers. */
+ 0.01234, 123460000, 1.23E300, -3.1415999999999999E-271,
+ 0.01234, 123460000, 1.23E300, -3.1415999999999999E-271,
+ 0.01234, 123456800, 1.23E300, -3.1415929999999999E-271,
+ 0.01234, 123500000, 1.23E300, -3.1420000000000001E-271
#endif
};
- int32_t lvalParse[] =
+ static const int32_t lvalParse[] =
{
0, -1, 1, 123460000,
0, -1, 1, 123460000,
@@ -465,7 +467,7 @@ static void TestCurrencyPreEuro(void)
};
const char* result[]={
- "\\u20A7 2", "2 F", "\\u00A31.50", "1,50 mk", "1,50 F", "\\u20A4 2",
+ "\\u20A7 2", "2 F", "\\u00A31.50", "1,50 mk", "2 F", "\\u20A4 2",
"1$50 Esc.", "\\u00F6S 1,50", "1,50 \\u0394\\u03C1\\u03C7", "2 \\u20A7", "1,50 FB", "\\u00a31.50",
"1,50 BF", "1,50 DM", "1,50 BF", "\\u20A7 2", "1,50 F", "\\u20A7 2",
"fl 1,50"
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cnumtst.c b/Build/source/libs/icu-xetex/test/cintltst/cnumtst.c
index a5b867cc47e..cc366b9cce6 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cnumtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cnumtst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -44,7 +44,7 @@ void addNumForTest(TestNode** root)
TESTCASE(TestNumberFormatPadding);
TESTCASE(TestInt64Format);
TESTCASE(TestNonExistentCurrency);
- /*TESTCASE(TestCurrencyRegression);*/
+ TESTCASE(TestCurrencyRegression);
TESTCASE(TestRBNFFormat);
}
@@ -97,7 +97,7 @@ static void TestNumberFormat()
int32_t resultlength;
int32_t resultlengthneeded;
int32_t parsepos;
- double d1;
+ double d1 = -1.0;
int32_t l1;
double d = -10456.37;
double a = 1234.56, a1 = 1235.0;
@@ -248,7 +248,7 @@ free(result);
{
log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status));
}
- if(u_strcmp(result, temp1)==0)
+ if(result && u_strcmp(result, temp1)==0)
log_verbose("Pass: Number Formatting using unum_formatDouble() Successful\n");
else
log_err("FAIL: Error in number formatting using unum_formatDouble()\n");
@@ -262,10 +262,14 @@ free(result);
/* Testing unum_parse() and unum_parseDouble() */
log_verbose("\nTesting unum_parseDouble()\n");
/* for (i = 0; i < 100000; i++)*/
+ if (result != NULL)
{
parsepos=0;
d1=unum_parseDouble(cur_def, result, u_strlen(result), &parsepos, &status);
}
+ else {
+ log_err("result is NULL\n");
+ }
if(U_FAILURE(status))
{
log_err("parse failed. The error is : %s\n", myErrorName(status));
@@ -305,26 +309,31 @@ free(result);
if (pos2.beginIndex == 1 && pos2.endIndex == 6) {
log_verbose("Pass: Complete number formatting using unum_format() successful\n");
} else {
- log_err("Fail: Error in complete number Formatting using unum_formatDouble()\nGot: b=%d end=%d\nExpected: b=1 end=6",
+ log_err("Fail: Error in complete number Formatting using unum_formatDouble()\nGot: b=%d end=%d\nExpected: b=1 end=6\n",
pos1.beginIndex, pos1.endIndex);
}
log_verbose("\nTesting unum_parseDoubleCurrency\n");
parsepos=0;
- d1=unum_parseDoubleCurrency(cur_def, result, u_strlen(result), &parsepos, temp2, &status);
- if (U_FAILURE(status)) {
- log_err("parse failed. The error is : %s\n", myErrorName(status));
- }
- /* Note: a==1234.56, but on parse expect a1=1235.0 */
- if (d1!=a1) {
- log_err("Fail: Error in parsing currency, got %f, expected %f\n", d1, a1);
- } else {
- log_verbose("Pass: parsed currency ammount successfully\n");
+ if (result == NULL) {
+ log_err("result is NULL\n");
}
- if (u_strcmp(temp2, temp)==0) {
- log_verbose("Pass: parsed correct currency\n");
- } else {
- log_err("Fail: parsed incorrect currency\n");
+ else {
+ d1=unum_parseDoubleCurrency(cur_def, result, u_strlen(result), &parsepos, temp2, &status);
+ if (U_FAILURE(status)) {
+ log_err("parse failed. The error is : %s\n", myErrorName(status));
+ }
+ /* Note: a==1234.56, but on parse expect a1=1235.0 */
+ if (d1!=a1) {
+ log_err("Fail: Error in parsing currency, got %f, expected %f\n", d1, a1);
+ } else {
+ log_verbose("Pass: parsed currency ammount successfully\n");
+ }
+ if (u_strcmp(temp2, temp)==0) {
+ log_verbose("Pass: parsed correct currency\n");
+ } else {
+ log_err("Fail: parsed incorrect currency\n");
+ }
}
free(result);
@@ -1287,7 +1296,7 @@ static void TestRBNFFormat() {
}
}
-static void TestCurrencyRegression() {
+static void TestCurrencyRegression(void) {
/*
I've found a case where unum_parseDoubleCurrency is not doing what I
expect. The value I pass in is $1234567890q123460000.00 and this
@@ -1334,7 +1343,7 @@ their data!
u_austrcpy(acurrency, currency);
- if(U_SUCCESS(status) || (pos != expected)) {
+ if(U_FAILURE(status) || (pos != expected)) {
log_err("unum_parseDoubleCurrency should have failed with pos %d, but gave: value %.9f, err %s, pos=%d, currency [%s]\n",
expected, d, u_errorName(status), pos, acurrency);
} else {
diff --git a/Build/source/libs/icu-xetex/test/cintltst/crestst.c b/Build/source/libs/icu-xetex/test/cintltst/crestst.c
index b6cec878f69..dce4e10fd6a 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/crestst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/crestst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2005, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*******************************************************************************
@@ -459,7 +459,7 @@ static void TestFallback()
static void
TestOpenDirect(void) {
- UResourceBundle *idna_rules, *item;
+ UResourceBundle *idna_rules, *casing, *te_IN, *ne, *item;
UErrorCode errorCode;
/*
@@ -468,7 +468,7 @@ TestOpenDirect(void) {
* from root or similar
*/
errorCode=U_ZERO_ERROR;
- idna_rules=ures_openDirect("testdata", "idna_rules", &errorCode);
+ idna_rules=ures_openDirect(loadTestData(&errorCode), "idna_rules", &errorCode);
if(U_FAILURE(errorCode)) {
log_err("ures_openDirect(\"idna_rules\") failed: %s\n", u_errorName(errorCode));
return;
@@ -489,7 +489,7 @@ TestOpenDirect(void) {
}
/* try an item in root, must fail */
- item=ures_getByKey(idna_rules, "Languages", NULL, &errorCode);
+ item=ures_getByKey(idna_rules, "ShortLanguage", NULL, &errorCode);
if(U_FAILURE(errorCode)) {
errorCode=U_ZERO_ERROR;
} else {
@@ -527,6 +527,80 @@ TestOpenDirect(void) {
return;
}
ures_close(idna_rules);
+
+ /*
+ * ICU 3.6 has new resource bundle syntax and data for bundles that do not
+ * participate in locale fallback. Now,
+ * - ures_open() works like ures_openDirect() on a bundle with a top-level
+ * type of ":table(nofallback)" _if_ the bundle exists
+ * - ures_open() will continue to find a root bundle if the requested one
+ * does not exist, unlike ures_openDirect()
+ *
+ * Test with a different bundle than above to avoid confusion in the cache.
+ */
+
+ /*
+ * verify that ures_open("casing"), which now has a nofallback declaration,
+ * does not enable fallbacks
+ */
+ errorCode=U_ZERO_ERROR;
+ casing=ures_open("testdata", "casing", &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ures_open(\"casing\") failed: %s\n", u_errorName(errorCode));
+ return;
+ }
+
+ errorCode=U_ZERO_ERROR;
+ item=ures_getByKey(casing, "Info", NULL, &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("casing.getByKey(Info) failed - %s\n", u_errorName(errorCode));
+ } else {
+ ures_close(item);
+ }
+
+ errorCode=U_ZERO_ERROR;
+ item=ures_getByKey(casing, "ShortLanguage", NULL, &errorCode);
+ if(U_SUCCESS(errorCode)) {
+ log_err("casing.getByKey(root key) succeeded despite nofallback declaration - %s\n", u_errorName(errorCode));
+ ures_close(item);
+ }
+ ures_close(casing);
+
+ /*
+ * verify that ures_open("ne") finds the root bundle but
+ * ures_openDirect("ne") does not
+ */
+ errorCode=U_ZERO_ERROR;
+ ne=ures_open("testdata", "ne", &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ures_open(\"ne\") failed (expected to get root): %s\n", u_errorName(errorCode));
+ }
+ if(errorCode!=U_USING_DEFAULT_WARNING || 0!=uprv_strcmp("root", ures_getLocale(ne, &errorCode))) {
+ log_err("ures_open(\"ne\") found something other than \"root\" - %s\n", u_errorName(errorCode));
+ }
+ ures_close(ne);
+
+ errorCode=U_ZERO_ERROR;
+ ne=ures_openDirect("testdata", "ne", &errorCode);
+ if(U_SUCCESS(errorCode)) {
+ log_err("ures_openDirect(\"ne\") succeeded unexpectedly\n");
+ ures_close(ne);
+ }
+
+ /* verify that ures_openDirect("te_IN") does not enable fallbacks */
+ errorCode=U_ZERO_ERROR;
+ te_IN=ures_openDirect("testdata", "te_IN", &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ures_open(\"te_IN\") failed: %s\n", u_errorName(errorCode));
+ return;
+ }
+ errorCode=U_ZERO_ERROR;
+ item=ures_getByKey(te_IN, "ShortLanguage", NULL, &errorCode);
+ if(U_SUCCESS(errorCode)) {
+ log_err("te_IN.getByKey(root key) succeeded despite use of ures_openDirect() - %s\n", u_errorName(errorCode));
+ ures_close(item);
+ }
+ ures_close(te_IN);
}
static int32_t
diff --git a/Build/source/libs/icu-xetex/test/cintltst/creststn.c b/Build/source/libs/icu-xetex/test/cintltst/creststn.c
index a79fc6232c0..f2cfa9cd727 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/creststn.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/creststn.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -25,6 +25,7 @@
#include "cstring.h"
#include "unicode/uchar.h"
#include "ucol_imp.h" /* for U_ICUDATA_COLL */
+#include "ubrkimpl.h" /* for U_ICUDATA_BRKITR */
#define RESTEST_HEAP_CHECK 0
#include "unicode/uloc.h"
@@ -175,6 +176,8 @@ static void TestGetKeywordValues(void);
static void TestGetFunctionalEquivalent(void);
static void TestCLDRStyleAliases(void);
static void TestFallbackCodes(void);
+static void TestGetUTF8String(void);
+
/***************************************************************************************/
/* Array of our test objects */
@@ -184,7 +187,7 @@ void addNEWResourceBundleTest(TestNode** root)
addTest(root, &TestErrorCodes, "tsutil/creststn/TestErrorCodes");
addTest(root, &TestEmptyBundle, "tsutil/creststn/TestEmptyBundle");
addTest(root, &TestConstruction1, "tsutil/creststn/TestConstruction1");
- addTest(root, &TestResourceBundles, "tsutil/creststn/TestResourceBundle");
+ addTest(root, &TestResourceBundles, "tsutil/creststn/TestResourceBundles");
addTest(root, &TestFallback, "tsutil/creststn/TestFallback");
addTest(root, &TestGetVersion, "tsutil/creststn/TestGetVersion");
addTest(root, &TestGetVersionColl, "tsutil/creststn/TestGetVersionColl");
@@ -203,6 +206,8 @@ void addNEWResourceBundleTest(TestNode** root)
addTest(root, &TestXPath, "tsutil/creststn/TestXPath");
addTest(root, &TestCLDRStyleAliases, "tsutil/creststn/TestCLDRStyleAliases");
addTest(root, &TestFallbackCodes, "tsutil/creststn/TestFallbackCodes");
+ addTest(root, &TestStackReuse, "tsutil/creststn/TestStackReuse");
+ addTest(root, &TestGetUTF8String, "tsutil/creststn/TestGetUTF8String");
}
@@ -414,7 +419,7 @@ static void TestDecodedBundle(){
int32_t num =0;
const char *testdatapath = loadTestData(&error);
resB = ures_open(testdatapath, "iscii", &error);
- srcFromRes=ures_getStringByKey(resB,"str",&len,&error);
+ srcFromRes=tres_getString(resB,-1,"str",&len,&error);
if(U_FAILURE(error)){
#if UCONFIG_NO_LEGACY_CONVERSION
log_info("Couldn't load iscii.bin from test data bundle, (because UCONFIG_NO_LEGACY_CONVERSION is turned on)\n");
@@ -466,7 +471,7 @@ static void TestNewTypes() {
theBundle = ures_open(testdatapath, "testtypes", &status);
- empty = ures_getStringByKey(theBundle, "emptystring", &len, &status);
+ empty = tres_getString(theBundle, -1, "emptystring", &len, &status);
if(empty && (*empty != 0 || len != 0)) {
log_err("Empty string returned invalid value\n");
}
@@ -483,7 +488,7 @@ static void TestNewTypes() {
res = ures_getByKey(theBundle, "zerotest", res, &status);
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
CONFIRM_INT_EQ(ures_getType(res), URES_STRING);
- zeroString=ures_getString(res, &len, &status);
+ zeroString=tres_getString(res, -1, NULL, &len, &status);
if(U_SUCCESS(status)){
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
CONFIRM_INT_EQ(len, 7);
@@ -569,7 +574,7 @@ static void TestNewTypes() {
/* this tests if escapes are preserved or not */
{
- const UChar* str = ures_getStringByKey(theBundle,"testescape",&len,&status);
+ const UChar* str = tres_getString(theBundle,-1,"testescape",&len,&status);
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
if(U_SUCCESS(status)){
u_charsToUChars(expect,uExpect,(int32_t)strlen(expect)+1);
@@ -608,7 +613,7 @@ static void TestNewTypes() {
patternLen = (int32_t)uprv_strlen(pattern);
expectedEscaped = (UChar*)malloc(U_SIZEOF_UCHAR * patternLen);
- got = ures_getStringByKey(theBundle,"test_unescaping",&len,&status);
+ got = tres_getString(theBundle,-1,"test_unescaping",&len,&status);
expectedLen = u_unescape(pattern,expectedEscaped,patternLen);
if(got==NULL || u_strncmp(expectedEscaped,got,expectedLen)!=0 || expectedLen != len){
log_err("genrb failed to unescape string\n");
@@ -625,7 +630,7 @@ static void TestNewTypes() {
}
/* test for jitterbug#1435 */
{
- const UChar* str = ures_getStringByKey(theBundle,"test_underscores",&len,&status);
+ const UChar* str = tres_getString(theBundle,-1,"test_underscores",&len,&status);
expect ="test message ....";
u_charsToUChars(expect,uExpect,(int32_t)strlen(expect)+1);
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
@@ -634,6 +639,7 @@ static void TestNewTypes() {
}
}
/* test for jitterbug#2626 */
+#if !UCONFIG_NO_COLLATION
{
UResourceBundle* resB = NULL;
const UChar* str = NULL;
@@ -642,7 +648,7 @@ static void TestNewTypes() {
status = U_ZERO_ERROR;
resB = ures_getByKey(theBundle, "collations", resB, &status);
resB = ures_getByKey(resB, "standard", resB, &status);
- str = ures_getStringByKey(resB,"Sequence",&strLength,&status);
+ str = tres_getString(resB,-1,"Sequence",&strLength,&status);
if(!str || U_FAILURE(status)) {
log_data_err("Could not load collations from theBundle: %s\n", u_errorName(status));
} else if(u_strcmp(my,str) != 0){
@@ -650,6 +656,7 @@ static void TestNewTypes() {
}
ures_close(resB);
}
+#endif
{
const char *sourcePath = ctest_dataSrcDir();
int32_t srcPathLen = (int32_t)strlen(sourcePath);
@@ -665,7 +672,7 @@ static void TestNewTypes() {
status = U_ZERO_ERROR;
{
int32_t strLen =0;
- const UChar* str = ures_getStringByKey(theBundle, "testincludeUTF",&strLen,&status);
+ const UChar* str = tres_getString(theBundle, -1, "testincludeUTF",&strLen,&status);
strcpy(path, "riwords.txt");
path[strlen("riwords.txt")]=0;
if(U_FAILURE(status)){
@@ -702,7 +709,7 @@ static void TestNewTypes() {
status = U_ZERO_ERROR;
{
int32_t strLen =0;
- const UChar* str = ures_getStringByKey(theBundle, "testinclude",&strLen,&status);
+ const UChar* str = tres_getString(theBundle, -1, "testinclude",&strLen,&status);
strcpy(path, "translit_rules.txt");
path[strlen("translit_rules.txt")]=0;
@@ -775,7 +782,7 @@ static void TestEmptyTypes() {
res = ures_getByKey(theBundle, "emptyexplicitstring", res, &status);
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
CONFIRM_INT_EQ(ures_getType(res), URES_STRING);
- zeroString=ures_getString(res, &len, &status);
+ zeroString=tres_getString(res, -1, NULL, &len, &status);
if(U_SUCCESS(status)){
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
CONFIRM_INT_EQ(len, 0);
@@ -790,7 +797,7 @@ static void TestEmptyTypes() {
res = ures_getByKey(theBundle, "emptystring", res, &status);
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
CONFIRM_INT_EQ(ures_getType(res), URES_STRING);
- zeroString=ures_getString(res, &len, &status);
+ zeroString=tres_getString(res, -1, NULL, &len, &status);
if(U_SUCCESS(status)){
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
CONFIRM_INT_EQ(len, 0);
@@ -973,6 +980,7 @@ static void TestAPI() {
const char* testdatapath;
UChar* utestdatapath=NULL;
char convOutput[256];
+ UChar largeBuffer[1025];
UResourceBundle *teRes = NULL;
UResourceBundle *teFillin=NULL;
UResourceBundle *teFillin2=NULL;
@@ -1000,8 +1008,18 @@ static void TestAPI() {
}
#endif
+ u_memset(largeBuffer, 0x0030, sizeof(largeBuffer)/sizeof(largeBuffer[0]));
+ largeBuffer[sizeof(largeBuffer)/sizeof(largeBuffer[0])-1] = 0;
+
/*Test ures_openU */
+ status = U_ZERO_ERROR;
+ ures_close(ures_openU(largeBuffer, "root", &status));
+ if(status != U_ILLEGAL_ARGUMENT_ERROR){
+ log_err("ERROR: ures_openU() worked when the path is very large. It returned %s\n", myErrorName(status));
+ }
+
+ status = U_ZERO_ERROR;
ures_close(ures_openU(NULL, "root", &status));
if(U_FAILURE(status)){
log_err("ERROR: ures_openU() failed path = NULL with %s\n", myErrorName(status));
@@ -1056,7 +1074,7 @@ static void TestAPI() {
if(U_FAILURE(status)){
log_err("ERROR: ures_getByIndex on string resource failed\n");
}
- if(strcmp(u_austrcpy(convOutput, ures_getString(teFillin2, &len, &status)), "TE") != 0){
+ if(strcmp(u_austrcpy(convOutput, tres_getString(teFillin2, -1, NULL, &len, &status)), "TE") != 0){
status=U_ZERO_ERROR;
log_err("ERROR: ures_getByIndex on string resource fetched the key=%s, expected \"TE\" \n", austrdup(ures_getString(teFillin2, &len, &status)));
}
@@ -1155,8 +1173,8 @@ static void TestErrorConditions(){
log_verbose("Testing ures_openFillIn with UResourceBundle = NULL.....\n");
status=U_ZERO_ERROR;
ures_openFillIn(NULL, testdatapath, "te", &status);
- if(status != U_INTERNAL_PROGRAM_ERROR){
- log_err("ERROR: ures_openFillIn with UResourceBundle= NULL should fail. Expected U_INTERNAL_PROGRAM_ERROR, Got: %s\n",
+ if(status != U_ILLEGAL_ARGUMENT_ERROR){
+ log_err("ERROR: ures_openFillIn with UResourceBundle= NULL should fail. Expected U_ILLEGAL_ARGUMENT_ERROR, Got: %s\n",
myErrorName(status));
}
/*Test ures_getLocale() with status != U_ZERO_ERROR*/
@@ -1409,7 +1427,7 @@ static void TestGetVersionColl(){
return;
}
/* test NUL termination of UCARules */
- rules = ures_getStringByKey(resB,"UCARules",&len, &status);
+ rules = tres_getString(resB,-1,"UCARules",&len, &status);
if(!rules || U_FAILURE(status)) {
log_data_err("Could not load UCARules for locale %s\n", locName);
continue;
@@ -1502,8 +1520,8 @@ static void TestConstruction1()
log_err("construction of %s did not succeed : %s \n", locale, myErrorName(status));
return;
}
- result1= ures_getStringByKey(test1, "string_in_Root_te_te_IN", &len1, &err);
- result2= ures_getStringByKey(test2, "string_in_Root_te_te_IN", &len2, &err);
+ result1= tres_getString(test1, -1, "string_in_Root_te_te_IN", &len1, &err);
+ result2= tres_getString(test2, -1, "string_in_Root_te_te_IN", &len2, &err);
if (U_FAILURE(err) || len1==0 || len2==0) {
log_err("Something threw an error in TestConstruction(): %s\n", myErrorName(status));
return;
@@ -1670,7 +1688,7 @@ static UBool testTag(const char* frag,
status = U_ZERO_ERROR;
len=0;
- string=ures_getStringByKey(theBundle, tag, &len, &status);
+ string=tres_getString(theBundle, -1, tag, &len, &status);
if(U_SUCCESS(status)) {
expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 4));
u_strcpy(expected_string,base);
@@ -1716,7 +1734,7 @@ static UBool testTag(const char* frag,
u_strcat(expected_string, element);
arrayItem1=ures_getNextResource(array, arrayItem1, &status);
if(U_SUCCESS(status)){
- CONFIRM_EQ(ures_getString(arrayItem1, &len, &status),expected_string);
+ CONFIRM_EQ(tres_getString(arrayItem1, -1, NULL, &len, &status),expected_string);
}
}
@@ -1808,7 +1826,7 @@ static UBool testTag(const char* frag,
u_strcat(expected_string, element);
arrayItem1=ures_getNextResource(tableRow, arrayItem1, &status);
if(U_SUCCESS(status)){
- const UChar *stringValue=ures_getString(arrayItem1, &len, &status);
+ const UChar *stringValue=tres_getString(arrayItem1, -1, NULL, &len, &status);
CONFIRM_EQ(stringValue, expected_string);
}
}
@@ -1925,7 +1943,7 @@ static UBool testTag(const char* frag,
}else{
record_fail();
}
- t=(UChar*)ures_getString(tagelement, &len, &status);
+ t=(UChar*)tres_getString(tagelement, -1, NULL, &len, &status);
if(!U_FAILURE(status)){
string=t;
}
@@ -1994,11 +2012,11 @@ static void TestFallback()
/* clear it out.. just do some calls to get the gears turning */
- junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);
+ junk = tres_getString(fr_FR, -1, "LocaleID", &resultLen, &status);
status = U_ZERO_ERROR;
- junk = ures_getStringByKey(fr_FR, "LocaleString", &resultLen, &status);
+ junk = tres_getString(fr_FR, -1, "LocaleString", &resultLen, &status);
status = U_ZERO_ERROR;
- junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);
+ junk = tres_getString(fr_FR, -1, "LocaleID", &resultLen, &status);
status = U_ZERO_ERROR;
/* OK first one. This should be a Default value. */
@@ -2013,7 +2031,7 @@ static void TestFallback()
ures_close(subResource);
/* and this is a Fallback, to fr */
- junk = ures_getStringByKey(fr_FR, "Countries", &resultLen, &status);
+ junk = tres_getString(fr_FR, -1, "Countries", &resultLen, &status);
if(status != U_USING_FALLBACK_WARNING)
{
log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get Countries from fr_FR, got %d\n",
@@ -2030,18 +2048,20 @@ static void TestFallback()
UResourceBundle* myResB = ures_open(NULL,"no_NO_NY",&err);
UResourceBundle* resLocID = ures_getByKey(myResB, "Version", NULL, &err);
UResourceBundle* tResB;
- static const UChar versionStr[] = { 0x0031, 0x002E, 0x0032, 0x0037, 0x0000};
+ const UChar* version = NULL;
+ static const UChar versionStr[] = { 0x0031, 0x002E, 0x0033, 0x0037, 0x0000};
if(err != U_ZERO_ERROR){
log_data_err("Expected U_ZERO_ERROR when trying to test no_NO_NY aliased to nn_NO for Version err=%s\n",u_errorName(err));
return;
}
- if(u_strcmp(ures_getString(resLocID, &resultLen, &err), versionStr) != 0){
+ version = tres_getString(resLocID, -1, NULL, &resultLen, &err);
+ if(u_strcmp(version, versionStr) != 0){
log_data_err("ures_getString(resLocID, &resultLen, &err) returned an unexpected version value\n");
}
- tResB = ures_getByKey(myResB, "calendar", NULL, &err);
+ tResB = ures_getByKey(myResB, "zoneStrings", NULL, &err);
if(err != U_USING_FALLBACK_WARNING){
- log_err("Expected U_USING_FALLBACK_ERROR when trying to test no_NO_NY aliased with nn_NO_NY for calendar err=%s\n",u_errorName(err));
+ log_err("Expected U_USING_FALLBACK_ERROR when trying to test no_NO_NY aliased with nn_NO_NY for zoneStrings err=%s\n",u_errorName(err));
}
ures_close(resLocID);
ures_close(myResB);
@@ -2064,8 +2084,8 @@ static void TestResourceLevelAliasing(void) {
UResourceBundle *en = NULL, *uk = NULL, *testtypes = NULL;
const char* testdatapath = NULL;
const UChar *string = NULL, *sequence = NULL;
- const uint8_t *binary = NULL, *binSequence = NULL;
- int32_t strLen = 0, seqLen = 0, binLen = 0, binSeqLen = 0;
+ /*const uint8_t *binary = NULL, *binSequence = NULL;*/
+ int32_t strLen = 0, seqLen = 0;/*, binLen = 0, binSeqLen = 0;*/
char buffer[100];
char *s;
@@ -2114,16 +2134,16 @@ static void TestResourceLevelAliasing(void) {
goto cleanup;
}
- sequence = ures_getString(uk, &seqLen, &status);
+ sequence = tres_getString(uk, -1, NULL, &seqLen, &status);
tb = ures_getByKey(aliasB, "referencingalias", tb, &status);
- string = ures_getString(tb, &strLen, &status);
+ string = tres_getString(tb, -1, NULL, &strLen, &status);
if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
log_err("Referencing alias didn't get the right string\n");
}
- string = ures_getStringByKey(aliasB, "referencingalias", &strLen, &status);
+ string = tres_getString(aliasB, -1, "referencingalias", &strLen, &status);
if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
log_err("Referencing alias didn't get the right string\n");
}
@@ -2133,7 +2153,7 @@ static void TestResourceLevelAliasing(void) {
checkStatus(__LINE__, U_ZERO_ERROR, status);
tb = ures_getByIndex(tb, 2, tb, &status);
checkStatus(__LINE__, U_ZERO_ERROR, status);
- string = ures_getString(tb, &strLen, &status);
+ string = tres_getString(tb, -1, NULL, &strLen, &status);
checkStatus(__LINE__, U_ZERO_ERROR, status);
if(U_FAILURE(status)) {
@@ -2142,28 +2162,34 @@ static void TestResourceLevelAliasing(void) {
log_err("Referencing alias didn't get the right string\n");
}
- /* check whether the binary collation data is properly referenced by an alias */
- uk = ures_findResource("th/BreakDictionaryData", uk, &status);
- binSequence = ures_getBinary(uk, &binSeqLen, &status);
-
- tb = ures_getByKey(aliasB, "BreakDictionaryData", tb, &status);
- binary = ures_getBinary(tb, &binLen, &status);
-
- if(U_FAILURE(status)) {
- log_err("%s trying to read binary BreakDictionaryData\n");
- } else if(binSeqLen != binLen || memcmp(binSequence, binary, binSeqLen) != 0) {
- log_err("Referencing alias didn't get the right data\n");
+
+ {
+ UResourceBundle* ja = ures_open(U_ICUDATA_BRKITR,"ja", &status);
+ const UChar *got = NULL, *exp=NULL;
+ int32_t gotLen = 0, expLen=0;
+ ja = ures_getByKey(ja, "boundaries", ja, &status);
+ exp = tres_getString(ja, -1, "word", &expLen, &status);
+
+ tb = ures_getByKey(aliasB, "boundaries", tb, &status);
+ got = tres_getString(tb, -1, "word", &gotLen, &status);
+
+ if(U_FAILURE(status)) {
+ log_err("%s trying to read str boundaries\n");
+ } else if(gotLen != expLen || u_strncmp(exp, got, gotLen) != 0) {
+ log_err("Referencing alias didn't get the right data\n");
+ }
+ ures_close(ja);
+ status = U_ZERO_ERROR;
}
-
/* simple alias */
testtypes = ures_open(testdatapath, "testtypes", &status);
strcpy(buffer, "menu/file/open");
s = buffer;
uk = ures_findSubResource(testtypes, s, uk, &status);
- sequence = ures_getString(uk, &seqLen, &status);
+ sequence = tres_getString(uk, -1, NULL, &seqLen, &status);
tb = ures_getByKey(aliasB, "simplealias", tb, &status);
- string = ures_getString(tb, &strLen, &status);
+ string = tres_getString(tb, -1, NULL, &strLen, &status);
if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
log_err("Referencing alias didn't get the right string\n");
@@ -2173,10 +2199,10 @@ static void TestResourceLevelAliasing(void) {
tb = ures_getByKey(aliasB, "zoneTests", tb, &status);
tb = ures_getByKey(tb, "zoneAlias2", tb, &status);
- string = ures_getString(tb, &strLen, &status);
+ string = tres_getString(tb, -1, NULL, &strLen, &status);
en = ures_findResource("en/zoneStrings/3/0", en, &status);
- sequence = ures_getString(en, &seqLen, &status);
+ sequence = tres_getString(en, -1, NULL, &seqLen, &status);
if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
log_err("Referencing alias didn't get the right string\n");
@@ -2207,23 +2233,35 @@ static void TestResourceLevelAliasing(void) {
log_err("Couldn't get testGetStringByKeyAliasing resource\n");
}
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = ures_getStringByKey(tb, keys[i], &resultLen, &status);
+ result = tres_getString(tb, -1, keys[i], &resultLen, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
uBufferLen = u_unescape(strings[i], uBuffer, 256);
if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
log_err("Didn't get correct string while accesing alias table by key (%s)\n", keys[i]);
}
}
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = ures_getStringByIndex(tb, i, &resultLen, &status);
+ result = tres_getString(tb, i, NULL, &resultLen, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
log_err("Didn't get correct string while accesing alias table by index (%s)\n", strings[i]);
}
}
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
result = ures_getNextString(tb, &resultLen, &key, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
log_err("Didn't get correct string while iterating over alias table (%s)\n", strings[i]);
}
}
@@ -2232,20 +2270,35 @@ static void TestResourceLevelAliasing(void) {
log_err("Couldn't get testGetStringByIndexAliasing resource\n");
}
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = ures_getStringByIndex(tb, i, &resultLen, &status);
+ result = tres_getString(tb, i, NULL, &resultLen, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
log_err("Didn't get correct string while accesing alias by index in an array (%s)\n", strings[i]);
}
}
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
result = ures_getNextString(tb, &resultLen, &key, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
log_err("Didn't get correct string while iterating over aliases in an array (%s)\n", strings[i]);
}
}
}
+ tb = ures_getByKey(aliasB, "testAliasToTree", tb, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key \"testAliasToTree\" failed. Error: %s\n", u_errorName(status));
+ }
+ if (strcmp(ures_getKey(tb), "collations") != 0) {
+ log_err("ures_getKey(aliasB) unexpectedly returned %s instead of \"collations\"\n", ures_getKey(tb));
+ }
cleanup:
ures_close(aliasB);
ures_close(tb);
@@ -2261,8 +2314,13 @@ static void TestDirectAccess(void) {
char buffer[100];
char *s;
+ /*const char* testdatapath=loadTestData(&status);
+ if(U_FAILURE(status)){
+ log_err("Could not load testdata.dat %s \n",myErrorName(status));
+ return;
+ }*/
- t = ures_findResource("en/zoneStrings/3/2", t, &status);
+ t = ures_findResource("/testdata/te/zoneStrings/3/2", t, &status);
if(U_FAILURE(status)) {
log_err("Couldn't access indexed resource, error %s\n", u_errorName(status));
status = U_ZERO_ERROR;
@@ -2272,7 +2330,7 @@ static void TestDirectAccess(void) {
log_err("Got a strange key, expected NULL, got %s\n", key);
}
}
- t = ures_findResource("en/zoneStrings/3", t, &status);
+ t = ures_findResource("en/calendar/gregorian/DateTimePatterns/3", t, &status);
if(U_FAILURE(status)) {
log_err("Couldn't access indexed resource, error %s\n", u_errorName(status));
status = U_ZERO_ERROR;
@@ -2316,7 +2374,7 @@ static void TestDirectAccess(void) {
}
}
- t = ures_findResource("root/calendar/islamic-civil/DateTimePatterns", t, &status);
+ t = ures_findResource("root/calendar/islamic-civil/DateTime", t, &status);
if(U_SUCCESS(status)) {
log_err("This resource does not exist. How did it get here?\n");
}
@@ -2333,7 +2391,7 @@ static void TestDirectAccess(void) {
t2 = ures_open(NULL, "he", &status);
t2 = ures_getByKeyWithFallback(t2, "calendar", t2, &status);
t2 = ures_getByKeyWithFallback(t2, "islamic-civil", t2, &status);
- t2 = ures_getByKeyWithFallback(t2, "DateTimePatterns", t2, &status);
+ t2 = ures_getByKeyWithFallback(t2, "DateTime", t2, &status);
if(U_SUCCESS(status)) {
log_err("This resource does not exist. How did it get here?\n");
}
@@ -2354,7 +2412,7 @@ static void TestDirectAccess(void) {
t2 = ures_open(NULL, "root", &status);
t2 = ures_getByKeyWithFallback(t2, "calendar", t2, &status);
t2 = ures_getByKeyWithFallback(t2, "islamic-civil", t2, &status);
- t2 = ures_getByKeyWithFallback(t2, "DateTimePatterns", t2, &status);
+ t2 = ures_getByKeyWithFallback(t2, "DateTime", t2, &status);
if(U_SUCCESS(status)) {
log_err("This resource does not exist. How did it get here?\n");
}
@@ -2458,10 +2516,10 @@ static void TestGetFunctionalEquivalentOf(const char *path, const char *resName,
log_verbose("got: %c %s\n", expectAvail?'t':'f',equivLocale);
if((gotAvail != expectAvail) || strcmp(equivLocale, expectLocale)) {
- log_err("FAIL: got avail=%c, loc=%s but expected #%d: %c\t%s\t-> loc=%s\n",
- gotAvail?'t':'f', equivLocale,
- i/3,
- expectAvail?'t':'f', inLocale, expectLocale);
+ log_err("FAIL: got avail=%c, loc=%s but expected #%d: %c\t%s\t-> loc=%s\n",
+ gotAvail?'t':'f', equivLocale,
+ i/3,
+ expectAvail?'t':'f', inLocale, expectLocale);
}
}
@@ -2508,8 +2566,8 @@ static void TestGetFunctionalEquivalent(void) {
static const char *calCases[] = {
/* avail locale equiv */
- "t", "en_US", "en@calendar=gregorian",
- "f", "ja_JP_TOKYO", "ja@calendar=gregorian",
+ "t", "en_US_POSIX", "en_US@calendar=gregorian",
+ "f", "ja_JP_TOKYO", "ja_JP@calendar=gregorian",
"f", "ja_JP_TOKYO@calendar=japanese", "ja@calendar=japanese",
"t", "sr@calendar=gregorian", "sr@calendar=gregorian",
"t", "en", "en@calendar=gregorian",
@@ -2572,7 +2630,7 @@ static void TestXPath(void) {
return;
}
- result = ures_getString(alias, &len, &status);
+ result = tres_getString(alias, -1, NULL, &len, &status);
if(U_FAILURE(status) || result == NULL || u_strcmp(result, expResult)) {
log_err("Couldn't get correct string value (%s)\n", myErrorName(status));
}
@@ -2584,7 +2642,7 @@ static void TestXPath(void) {
return;
}
- result = ures_getString(alias, &len, &status);
+ result = tres_getString(alias, -1, NULL, &len, &status);
if(U_FAILURE(status) || result == NULL || u_strcmp(result, expResult)) {
log_err("Couldn't get correct string value (%s)\n", myErrorName(status));
}
@@ -2596,7 +2654,7 @@ static void TestXPath(void) {
return;
}
- result = ures_getString(alias, &len, &status);
+ result = tres_getString(alias, -1, NULL, &len, &status);
if(U_FAILURE(status) || result == NULL || u_strcmp(result, expResult)) {
log_err("Couldn't get correct string value (%s)\n", myErrorName(status));
}
@@ -2636,7 +2694,7 @@ static void TestCLDRStyleAliases(void) {
resource[2]=0;
/* instead of sprintf(resource, "a%i", i); */
a = ures_getByKeyWithFallback(alias, resource, a, &status);
- result = ures_getString(a, &len, &status);
+ result = tres_getString(a, -1, NULL, &len, &status);
u_charsToUChars(expects[i], expected, strlen(expects[i])+1);
if(U_FAILURE(status) || !result || u_strcmp(result, expected)) {
log_err("CLDR style aliases failed resource with name \"%s\" resource, exp %s, got %S (%s)\n", resource, expects[i], result, myErrorName(status));
@@ -2685,3 +2743,187 @@ static void TestFallbackCodes(void) {
ures_close(r);
ures_close(res);
}
+
+/* This test will crash if this doesn't work. Results don't need testing. */
+static void TestStackReuse(void) {
+ UResourceBundle table;
+ UErrorCode errorCode = U_ZERO_ERROR;
+ UResourceBundle *rb = ures_open(NULL, "en_US", &errorCode);
+
+ if(U_FAILURE(errorCode)) {
+ log_err("Could not load en_US locale. status=%s\n",myErrorName(errorCode));
+ return;
+ }
+ ures_initStackObject(&table);
+ ures_getByKeyWithFallback(rb, "Types", &table, &errorCode);
+ ures_getByKeyWithFallback(&table, "collation", &table, &errorCode);
+ ures_close(rb);
+ ures_close(&table);
+}
+
+/* Test ures_getUTF8StringXYZ() --------------------------------------------- */
+
+/*
+ * Replace most ures_getStringXYZ() with this function which wraps the
+ * desired call and also calls the UTF-8 variant and checks that it works.
+ */
+extern const UChar *
+tres_getString(const UResourceBundle *resB,
+ int32_t index, const char *key,
+ int32_t *length,
+ UErrorCode *status) {
+ char buffer8[16];
+ char *p8;
+ const UChar *s16;
+ const char *s8;
+ UChar32 c16, c8;
+ int32_t length16, length8, i16, i8;
+ UBool forceCopy;
+
+ if(length == NULL) {
+ length = &length16;
+ }
+ if(index >= 0) {
+ s16 = ures_getStringByIndex(resB, index, length, status);
+ } else if(key != NULL) {
+ s16 = ures_getStringByKey(resB, key, length, status);
+ } else {
+ s16 = ures_getString(resB, length, status);
+ }
+ if(U_FAILURE(*status)) {
+ return s16;
+ }
+ length16 = *length;
+
+ /* try the UTF-8 variant of ures_getStringXYZ() */
+ for(forceCopy = FALSE; forceCopy <= TRUE; ++forceCopy) {
+ p8 = buffer8;
+ length8 = (int32_t)sizeof(buffer8);
+ if(index >= 0) {
+ s8 = ures_getUTF8StringByIndex(resB, index, p8, &length8, forceCopy, status);
+ } else if(key != NULL) {
+ s8 = ures_getUTF8StringByKey(resB, key, p8, &length8, forceCopy, status);
+ } else {
+ s8 = ures_getUTF8String(resB, p8, &length8, forceCopy, status);
+ }
+ if(*status == U_INVALID_CHAR_FOUND) {
+ /* the UTF-16 string contains an unpaired surrogate, can't test UTF-8 variant */
+ return s16;
+ }
+ if(*status == U_BUFFER_OVERFLOW_ERROR) {
+ *status = U_ZERO_ERROR;
+ p8 = (char *)malloc(++length8);
+ if(p8 == NULL) {
+ return s16;
+ }
+ if(index >= 0) {
+ s8 = ures_getUTF8StringByIndex(resB, index, p8, &length8, forceCopy, status);
+ } else if(key != NULL) {
+ s8 = ures_getUTF8StringByKey(resB, key, p8, &length8, forceCopy, status);
+ } else {
+ s8 = ures_getUTF8String(resB, p8, &length8, forceCopy, status);
+ }
+ }
+ if(U_FAILURE(*status)) {
+ /* something unexpected happened */
+ if(p8 != buffer8) {
+ free(p8);
+ }
+ return s16;
+ }
+
+ if(forceCopy && s8 != p8) {
+ log_err("ures_getUTF8String(%p, %ld, '%s') did not write the string to dest\n",
+ resB, (long)index, key);
+ }
+
+ /* verify NUL-termination */
+ if((p8 != buffer8 || length8 < sizeof(buffer8)) && s8[length8] != 0) {
+ log_err("ures_getUTF8String(%p, %ld, '%s') did not NUL-terminate\n",
+ resB, (long)index, key);
+ }
+ /* verify correct string */
+ i16 = i8 = 0;
+ while(i16 < length16 && i8 < length8) {
+ U16_NEXT(s16, i16, length16, c16);
+ U8_NEXT(s8, i8, length8, c8);
+ if(c16 != c8) {
+ log_err("ures_getUTF8String(%p, %ld, '%s') got a bad string, c16=U+%04lx!=U+%04lx=c8 before i16=%ld\n",
+ resB, (long)index, key, (long)c16, (long)c8, (long)i16);
+ }
+ }
+ /* verify correct length */
+ if(i16 < length16) {
+ log_err("ures_getUTF8String(%p, %ld, '%s') UTF-8 string too short, length8=%ld, length16=%ld\n",
+ resB, (long)index, key, (long)length8, (long)length16);
+ }
+ if(i8 < length8) {
+ log_err("ures_getUTF8String(%p, %ld, '%s') UTF-8 string too long, length8=%ld, length16=%ld\n",
+ resB, (long)index, key, (long)length8, (long)length16);
+ }
+
+ /* clean up */
+ if(p8 != buffer8) {
+ free(p8);
+ }
+ }
+ return s16;
+}
+
+/*
+ * API tests for ures_getUTF8String().
+ * Most cases are handled by tres_getString(), which leaves argument checking
+ * to be tested here.
+ * Since the variants share most of their implementation, we only need to test
+ * one of them.
+ * We also need not test for checking arguments which will be checked by the
+ * UTF-16 ures_getStringXYZ() that are called internally.
+ */
+static void
+TestGetUTF8String() {
+ UResourceBundle *res;
+ const char *testdatapath;
+ char buffer8[16];
+ const char *s8;
+ int32_t length8;
+ UErrorCode status;
+
+ status = U_ZERO_ERROR;
+ testdatapath = loadTestData(&status);
+ if(U_FAILURE(status)) {
+ log_err("Could not load testdata.dat - %s\n", u_errorName(status));
+ return;
+ }
+
+ res = ures_open(testdatapath, "", &status);
+ if(U_FAILURE(status)) {
+ log_err("Unable to ures_open(testdata, \"\") - %s\n", u_errorName(status));
+ return;
+ }
+
+ /* one good call */
+ status = U_ZERO_ERROR;
+ length8 = (int32_t)sizeof(buffer8);
+ s8 = ures_getUTF8StringByKey(res, "string_only_in_Root", buffer8, &length8, FALSE, &status);
+ if(status != U_ZERO_ERROR) {
+ log_err("ures_getUTF8StringByKey(testdata/root string) malfunctioned - %s\n", u_errorName(status));
+ }
+
+ /* negative capacity */
+ status = U_ZERO_ERROR;
+ length8 = -1;
+ s8 = ures_getUTF8StringByKey(res, "string_only_in_Root", buffer8, &length8, FALSE, &status);
+ if(status != U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("ures_getUTF8StringByKey(capacity<0) malfunctioned - %s\n", u_errorName(status));
+ }
+
+ /* capacity>0 but dest=NULL */
+ status = U_ZERO_ERROR;
+ length8 = (int32_t)sizeof(buffer8);
+ s8 = ures_getUTF8StringByKey(res, "string_only_in_Root", NULL, &length8, FALSE, &status);
+ if(status != U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("ures_getUTF8StringByKey(dest=NULL capacity>0) malfunctioned - %s\n", u_errorName(status));
+ }
+
+ ures_close(res);
+}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/creststn.h b/Build/source/libs/icu-xetex/test/cintltst/creststn.h
index 9b3ac947cc2..f6becdb979c 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/creststn.h
+++ b/Build/source/libs/icu-xetex/test/cintltst/creststn.h
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/***************************************************************************
@@ -18,8 +18,17 @@
/* C TEST FOR NEW RESOURCEBUNDLE API*/
#include "cintltst.h"
-
-
+/*
+ * Test wrapper for ures_getStringXYZ(), for testing other variants of
+ * these functions as well.
+ * If index>=0, calls ures_getStringByIndex().
+ * If key!=NULL, calls ures_getStringByKey().
+ */
+extern const UChar *
+tres_getString(const UResourceBundle *resB,
+ int32_t index, const char *key,
+ int32_t *length,
+ UErrorCode *status);
void addNEWResourceBundleTest(TestNode**);
@@ -62,6 +71,8 @@ static void TestJB3763(void);
static void TestXPath(void);
+static void TestStackReuse(void);
+
/**
* extensive subtests called by TestResourceBundles
**/
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cstrcase.c b/Build/source/libs/icu-xetex/test/cintltst/cstrcase.c
index 0c98763f940..cdbb85350f1 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cstrcase.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cstrcase.c
@@ -1,7 +1,7 @@
/*
*******************************************************************************
*
-* Copyright (C) 2002-2005, International Business Machines
+* Copyright (C) 2002-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@@ -25,12 +25,11 @@
#include "unicode/ucasemap.h"
#include "cmemory.h"
#include "cintltst.h"
-#include "cucdtst.h"
/* test string case mapping functions --------------------------------------- */
-U_CFUNC void
-TestCaseLower() {
+static void
+TestCaseLower(void) {
static const UChar
beforeLower[]= { 0x61, 0x42, 0x49, 0x3a3, 0xdf, 0x3a3, 0x2f, 0xd93f, 0xdfff },
@@ -127,8 +126,8 @@ buffer[length]==0 ? "yes" : "no",
}
}
-U_CFUNC void
-TestCaseUpper() {
+static void
+TestCaseUpper(void) {
static const UChar
beforeUpper[]= { 0x61, 0x42, 0x69, 0x3c2, 0xdf, 0x3c3, 0x2f, 0xfb03, 0xd93f, 0xdfff },
@@ -223,8 +222,8 @@ TestCaseUpper() {
#if !UCONFIG_NO_BREAK_ITERATION
-U_CFUNC void
-TestCaseTitle() {
+static void
+TestCaseTitle(void) {
static const UChar
beforeTitle[]= { 0x61, 0x42, 0x20, 0x69, 0x3c2, 0x20, 0xdf, 0x3c3, 0x2f, 0xfb03, 0xd93f, 0xdfff },
@@ -331,8 +330,8 @@ TestCaseTitle() {
/* test case folding and case-insensitive string compare -------------------- */
-U_CFUNC void
-TestCaseFolding() {
+static void
+TestCaseFolding(void) {
/*
* CaseFolding.txt says about i and its cousins:
* 0049; C; 0069; # LATIN CAPITAL LETTER I
@@ -557,8 +556,8 @@ TestCaseFolding() {
}
}
-U_CFUNC void
-TestCaseCompare() {
+static void
+TestCaseCompare(void) {
static const UChar
mixed[]= { 0x61, 0x42, 0x131, 0x3a3, 0xdf, 0xfb03, 0xd93f, 0xdfff, 0 },
@@ -653,8 +652,8 @@ TestCaseCompare() {
* test cases for actual case mappings using UCaseMap see
* intltest utility/UnicodeStringTest/StringCaseTest/TestCasing
*/
-U_CFUNC void
-TestUCaseMap() {
+static void
+TestUCaseMap(void) {
static const char
aBc[] ={ 0x61, 0x42, 0x63, 0 },
abc[] ={ 0x61, 0x62, 0x63, 0 },
@@ -779,3 +778,17 @@ TestUCaseMap() {
ucasemap_close(csm);
}
+
+void addCaseTest(TestNode** root);
+
+void addCaseTest(TestNode** root) {
+ /* cstrcase.c functions, declared in cucdtst.h */
+ addTest(root, &TestCaseLower, "tsutil/cstrcase/TestCaseLower");
+ addTest(root, &TestCaseUpper, "tsutil/cstrcase/TestCaseUpper");
+#if !UCONFIG_NO_BREAK_ITERATION
+ addTest(root, &TestCaseTitle, "tsutil/cstrcase/TestCaseTitle");
+#endif
+ addTest(root, &TestCaseFolding, "tsutil/cstrcase/TestCaseFolding");
+ addTest(root, &TestCaseCompare, "tsutil/cstrcase/TestCaseCompare");
+ addTest(root, &TestUCaseMap, "tsutil/cstrcase/TestUCaseMap");
+}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cucdapi.c b/Build/source/libs/icu-xetex/test/cintltst/cucdapi.c
index 01a94bb6148..4a919c40e94 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cucdapi.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cucdapi.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@@ -11,6 +11,8 @@
#include "cintltst.h"
#include "cucdapi.h"
+#define ARRAY_SIZE(array) (int32_t)(sizeof array / sizeof array[0])
+
void TestUScriptCodeAPI(){
int i =0;
int numErrors =0;
@@ -194,7 +196,7 @@ void TestUScriptCodeAPI(){
0x0001D1AA, /* USCRIPT_INHERITED*/
0x00020000, /* USCRIPT_HAN*/
0x00000D02, /* USCRIPT_MALAYALAM*/
- 0x00000D00, /* USCRIPT_COMMON */
+ 0x00000D00, /* USCRIPT_UNKNOWN (new Zzzz value in Unicode 5.0) */
0x00000000, /* USCRIPT_COMMON*/
0x0001D169, /* USCRIPT_INHERITED*/
0x0001D182, /* USCRIPT_INHERITED*/
@@ -221,7 +223,7 @@ void TestUScriptCodeAPI(){
USCRIPT_INHERITED,
USCRIPT_HAN ,
USCRIPT_MALAYALAM,
- USCRIPT_COMMON,
+ USCRIPT_UNKNOWN,
USCRIPT_COMMON,
USCRIPT_INHERITED ,
USCRIPT_INHERITED ,
@@ -283,10 +285,59 @@ void TestUScriptCodeAPI(){
for(i=0; (UScriptCode)i< USCRIPT_CODE_LIMIT; i++){
const char* name = uscript_getName((UScriptCode)i);
if(name==NULL || strcmp(name,"")==0){
- log_err("uscript_getName failed for code : %i\n",i);
+ log_err("uscript_getName failed for code %i: name is NULL or \"\"\n",i);
}
}
}
-
+ {
+ /*
+ * These script codes were originally added to ICU pre-3.6, so that ICU would
+ * have all ISO 15924 script codes. ICU was then based on Unicode 4.1.
+ * These script codes were added with only short names because we don't
+ * want to invent long names ourselves.
+ * Unicode 5 and later encode some of these scripts and give them long names.
+ * Whenever this happens, the long script names here need to be updated.
+ */
+ static const char* expectedLong[] = {
+ "Balinese", "Batk", "Blis", "Brah", "Cham", "Cirt", "Cyrs", "Egyd", "Egyh", "Egyp",
+ "Geok", "Hans", "Hant", "Hmng", "Hung", "Inds", "Java", "Kali", "Latf", "Latg",
+ "Lepc", "Lina", "Mand", "Maya", "Mero", "Nko", "Orkh", "Perm", "Phags_Pa", "Phoenician",
+ "Plrd", "Roro", "Sara", "Syre", "Syrj", "Syrn", "Teng", "Vaii", "Visp", "Cuneiform",
+ "Zxxx", "Unknown",
+ };
+ static const char* expectedShort[] = {
+ "Bali", "Batk", "Blis", "Brah", "Cham", "Cirt", "Cyrs", "Egyd", "Egyh", "Egyp",
+ "Geok", "Hans", "Hant", "Hmng", "Hung", "Inds", "Java", "Kali", "Latf", "Latg",
+ "Lepc", "Lina", "Mand", "Maya", "Mero", "Nkoo", "Orkh", "Perm", "Phag", "Phnx",
+ "Plrd", "Roro", "Sara", "Syre", "Syrj", "Syrn", "Teng", "Vaii", "Visp", "Xsux",
+ "Zxxx", "Zzzz",
+ };
+ int32_t j = 0;
+ for(i=USCRIPT_BALINESE; (UScriptCode)i<USCRIPT_CODE_LIMIT; i++, j++){
+ const char* name = uscript_getName((UScriptCode)i);
+ if(name==NULL || strcmp(name,expectedLong[j])!=0){
+ log_err("uscript_getName failed for code %i: %s!=%s\n", i, name, expectedLong[j]);
+ }
+ name = uscript_getShortName((UScriptCode)i);
+ if(name==NULL || strcmp(name,expectedShort[j])!=0){
+ log_err("uscript_getShortName failed for code %i: %s!=%s\n", i, name, expectedShort[j]);
+ }
+ }
+ for(i=0; i<ARRAY_SIZE(expectedLong); i++){
+ UScriptCode fillIn[5] = {USCRIPT_INVALID_CODE};
+ UErrorCode status = U_ZERO_ERROR;
+ int32_t len = 0;
+ len = uscript_getCode(expectedShort[i], fillIn, ARRAY_SIZE(fillIn), &status);
+ if(U_FAILURE(status)){
+ log_err("uscript_getCode failed for script name %s. Error: %s\n",expectedShort[i], u_errorName(status));
+ }
+ if(len>1){
+ log_err("uscript_getCode did not return expected number of codes for script %s. EXPECTED: 1 GOT: %i\n", expectedShort[i], len);
+ }
+ if(fillIn[0]!= (UScriptCode)(USCRIPT_BALINESE+i)){
+ log_err("uscript_getCode did not return expected code for script %s. EXPECTED: %i GOT: %i\n", expectedShort[i], (USCRIPT_BALINESE+i), fillIn[0] );
+ }
+ }
+ }
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c b/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c
index 67ab67a76d3..0aa15affa92 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -211,7 +211,8 @@ Checks LetterLike Symbols which were previously a source of confusion
*/
for (i=0x2100;i<0x2138;i++)
{
- if(i!=0x2126 && i!=0x212a && i!=0x212b)
+ /* Unicode 5.0 adds lowercase U+214E (TURNED SMALL F) to U+2132 (TURNED CAPITAL F) */
+ if(i!=0x2126 && i!=0x212a && i!=0x212b && i!=0x2132)
{
if (i != (int)u_tolower(i)) /* itself */
log_err("Failed case conversion with itself: U+%04x\n", i);
@@ -324,57 +325,77 @@ Checks LetterLike Symbols which were previously a source of confusion
}
}
-/* compare two sets, which is not easy with the current (ICU 2.4) C API... */
-
+/* compare two sets and verify that their difference or intersection is empty */
static UBool
showADiffB(const USet *a, const USet *b,
const char *a_name, const char *b_name,
UBool expect, UBool diffIsError) {
+ USet *aa;
int32_t i, start, end, length;
- UBool equal;
UErrorCode errorCode;
+ /*
+ * expect:
+ * TRUE -> a-b should be empty, that is, b should contain all of a
+ * FALSE -> a&b should be empty, that is, a should contain none of b (and vice versa)
+ */
+ if(expect ? uset_containsAll(b, a) : uset_containsNone(a, b)) {
+ return TRUE;
+ }
+
+ /* clone a to aa because a is const */
+ aa=uset_open(1, 0);
+ if(aa==NULL) {
+ /* unusual problem - out of memory? */
+ return FALSE;
+ }
+ uset_addAll(aa, a);
+
+ /* compute the set in question */
+ if(expect) {
+ /* a-b */
+ uset_removeAll(aa, b);
+ } else {
+ /* a&b */
+ uset_retainAll(aa, b);
+ }
+
+ /* aa is not empty because of the initial tests above; show its contents */
errorCode=U_ZERO_ERROR;
- equal=TRUE;
i=0;
for(;;) {
- length=uset_getItem(a, i, &start, &end, NULL, 0, &errorCode);
+ length=uset_getItem(aa, i, &start, &end, NULL, 0, &errorCode);
if(errorCode==U_INDEX_OUTOFBOUNDS_ERROR) {
- return equal; /* done */
+ break; /* done */
}
if(U_FAILURE(errorCode)) {
- log_err("error comparing %s with %s at item %d: %s\n",
+ log_err("error comparing %s with %s at difference item %d: %s\n",
a_name, b_name, i, u_errorName(errorCode));
- return FALSE;
+ break;
}
if(length!=0) {
- return equal; /* done with code points, got a string or -1 */
+ break; /* done with code points, got a string or -1 */
}
- if(expect!=uset_containsRange(b, start, end)) {
- equal=FALSE;
- while(start<=end) {
- if(expect!=uset_contains(b, start)) {
- if(diffIsError) {
- if(expect) {
- log_err("error: %s contains U+%04x but %s does not\n", a_name, start, b_name);
- } else {
- log_err("error: %s and %s both contain U+%04x but should not intersect\n", a_name, b_name, start);
- }
- } else {
- if(expect) {
- log_verbose("info: %s contains U+%04x but %s does not\n", a_name, start, b_name);
- } else {
- log_verbose("info: %s and %s both contain U+%04x but should not intersect\n", a_name, b_name, start);
- }
- }
- }
- ++start;
+ if(diffIsError) {
+ if(expect) {
+ log_err("error: %s contains U+%04x..U+%04x but %s does not\n", a_name, start, end, b_name);
+ } else {
+ log_err("error: %s and %s both contain U+%04x..U+%04x but should not intersect\n", a_name, b_name, start, end);
+ }
+ } else {
+ if(expect) {
+ log_verbose("info: %s contains U+%04x..U+%04x but %s does not\n", a_name, start, end, b_name);
+ } else {
+ log_verbose("info: %s and %s both contain U+%04x..U+%04x but should not intersect\n", a_name, b_name, start, end);
}
}
++i;
}
+
+ uset_close(aa);
+ return FALSE;
}
static UBool
@@ -395,8 +416,12 @@ static UBool
compareUSets(const USet *a, const USet *b,
const char *a_name, const char *b_name,
UBool diffIsError) {
+ /*
+ * Use an arithmetic & not a logical && so that both branches
+ * are always taken and all differences are shown.
+ */
return
- showAMinusB(a, b, a_name, b_name, diffIsError) &&
+ showAMinusB(a, b, a_name, b_name, diffIsError) &
showAMinusB(b, a, b_name, a_name, diffIsError);
}
@@ -1810,18 +1835,18 @@ TestMirroring() {
errorCode=U_ZERO_ERROR;
set=uset_openPattern(mirroredPattern, 17, &errorCode);
- if (U_FAILURE(errorCode)) {
- log_data_err("uset_openPattern(mirroredPattern, 17, &errorCode) failed!");
- } else {
- for(i=0; 0==uset_getItem(set, i, &start, &end, NULL, 0, &errorCode); ++i) {
- do {
- c2=u_charMirror(start);
- c3=u_charMirror(c2);
- if(c3!=start) {
- log_err("u_charMirror() does not roundtrip: U+%04lx->U+%04lx->U+%04lx\n", (long)start, (long)c2, (long)c3);
- }
- } while(++start<=end);
- }
+ if (U_FAILURE(errorCode)) {
+ log_data_err("uset_openPattern(mirroredPattern, 17, &errorCode) failed!");
+ } else {
+ for(i=0; 0==uset_getItem(set, i, &start, &end, NULL, 0, &errorCode); ++i) {
+ do {
+ c2=u_charMirror(start);
+ c3=u_charMirror(c2);
+ if(c3!=start) {
+ log_err("u_charMirror() does not roundtrip: U+%04lx->U+%04lx->U+%04lx\n", (long)start, (long)c2, (long)c3);
+ }
+ } while(++start<=end);
+ }
}
uset_close(set);
@@ -2229,7 +2254,8 @@ TestAdditionalProperties() {
{ 0x0590, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0x05cf, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0x05ed, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
- { 0x07f2, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
+ { 0x07f2, UCHAR_BIDI_CLASS, U_DIR_NON_SPACING_MARK }, /* Nko, new in Unicode 5.0 */
+ { 0x07fe, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT }, /* unassigned R */
{ 0x08ba, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0xfb37, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0xfb42, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
@@ -2447,21 +2473,60 @@ TestAdditionalProperties() {
) {
log_err("error: u_getIntPropertyMinValue() wrong\n");
}
-
- if( u_getIntPropertyMaxValue(UCHAR_DASH)!=1 ||
- u_getIntPropertyMaxValue(UCHAR_ID_CONTINUE)!=1 ||
- u_getIntPropertyMaxValue(UCHAR_BINARY_LIMIT-1)!=1 ||
- u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS)!=(int32_t)U_CHAR_DIRECTION_COUNT-1 ||
- u_getIntPropertyMaxValue(UCHAR_BLOCK)!=(int32_t)UBLOCK_COUNT-1 ||
- u_getIntPropertyMaxValue(UCHAR_LINE_BREAK)!=(int32_t)U_LB_COUNT-1 ||
- u_getIntPropertyMaxValue(UCHAR_SCRIPT)!=(int32_t)USCRIPT_CODE_LIMIT-1 ||
- u_getIntPropertyMaxValue(0x2345)!=-1 /*JB#2410*/ ||
- u_getIntPropertyMaxValue(UCHAR_DECOMPOSITION_TYPE) != (int32_t) (U_DT_COUNT - 1) ||
- u_getIntPropertyMaxValue(UCHAR_JOINING_GROUP) != (int32_t) (U_JG_COUNT -1) ||
- u_getIntPropertyMaxValue(UCHAR_JOINING_TYPE) != (int32_t) (U_JT_COUNT -1) ||
- u_getIntPropertyMaxValue(UCHAR_EAST_ASIAN_WIDTH) != (int32_t) (U_EA_COUNT -1)
- ) {
- log_err("error: u_getIntPropertyMaxValue() wrong\n");
+ if( u_getIntPropertyMaxValue(UCHAR_DASH)!=1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_DASH) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_ID_CONTINUE)!=1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_ID_CONTINUE) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_BINARY_LIMIT-1)!=1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_BINARY_LIMIT-1) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS)!=(int32_t)U_CHAR_DIRECTION_COUNT-1 ) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_BLOCK)!=(int32_t)UBLOCK_COUNT-1 ) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_BLOCK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_LINE_BREAK)!=(int32_t)U_LB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_LINE_BREAK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_SCRIPT)!=(int32_t)USCRIPT_CODE_LIMIT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_SCRIPT) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_NUMERIC_TYPE)!=(int32_t)U_NT_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_NUMERIC_TYPE) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_GENERAL_CATEGORY)!=(int32_t)U_CHAR_CATEGORY_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_GENERAL_CATEGORY) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_HANGUL_SYLLABLE_TYPE)!=(int32_t)U_HST_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_HANGUL_SYLLABLE_TYPE) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_GRAPHEME_CLUSTER_BREAK)!=(int32_t)U_GCB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_GRAPHEME_CLUSTER_BREAK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_SENTENCE_BREAK)!=(int32_t)U_SB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_SENTENCE_BREAK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_WORD_BREAK)!=(int32_t)U_WB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_WORD_BREAK) wrong\n");
+ }
+ /*JB#2410*/
+ if( u_getIntPropertyMaxValue(0x2345)!=-1) {
+ log_err("error: u_getIntPropertyMaxValue(0x2345) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_DECOMPOSITION_TYPE) != (int32_t) (U_DT_COUNT - 1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_DECOMPOSITION_TYPE) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_JOINING_GROUP) != (int32_t) (U_JG_COUNT -1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_JOINING_GROUP) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_JOINING_TYPE) != (int32_t) (U_JT_COUNT -1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_JOINING_TYPE) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_EAST_ASIAN_WIDTH) != (int32_t) (U_EA_COUNT -1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_EAST_ASIAN_WIDTH) wrong\n");
}
/* test u_hasBinaryProperty() and u_getIntPropertyValue() */
@@ -2722,7 +2787,7 @@ TestPropertyValues(void) {
max);
}
- /* Script should return 0 for an invalid code point. */
+ /* Script should return USCRIPT_INVALID_CODE for an invalid code point. */
for (i=0; i<2; ++i) {
int32_t script;
const char* desc;
@@ -2742,7 +2807,7 @@ TestPropertyValues(void) {
}
/* We don't explicitly test ec. It should be U_FAILURE but it
isn't documented as such. */
- if (script != 0) {
+ if (script != (int32_t)USCRIPT_INVALID_CODE) {
log_err("FAIL: %s = %d, exp. 0\n",
desc, script);
}
@@ -2784,12 +2849,28 @@ TestConsistency() {
U_STRING_DECL(formatPattern, "[:Cf:]", 6);
U_STRING_DECL(alphaPattern, "[:Alphabetic:]", 14);
+ U_STRING_DECL(mathBlocksPattern,
+ "[[:block=Mathematical Operators:][:block=Miscellaneous Mathematical Symbols-A:][:block=Miscellaneous Mathematical Symbols-B:][:block=Supplemental Mathematical Operators:][:block=Mathematical Alphanumeric Symbols:]]",
+ 1+32+46+46+45+43+1+1); /* +1 for NUL */
+ U_STRING_DECL(mathPattern, "[:Math:]", 8);
+ U_STRING_DECL(unassignedPattern, "[:Cn:]", 6);
+ U_STRING_DECL(unknownPattern, "[:sc=Unknown:]", 14);
+ U_STRING_DECL(reservedPattern, "[[:Cn:][:Co:][:Cs:]]", 20);
+
U_STRING_INIT(hyphenPattern, "[:Hyphen:]", 10);
U_STRING_INIT(dashPattern, "[:Dash:]", 8);
U_STRING_INIT(lowerPattern, "[:Lowercase:]", 13);
U_STRING_INIT(formatPattern, "[:Cf:]", 6);
U_STRING_INIT(alphaPattern, "[:Alphabetic:]", 14);
+ U_STRING_INIT(mathBlocksPattern,
+ "[[:block=Mathematical Operators:][:block=Miscellaneous Mathematical Symbols-A:][:block=Miscellaneous Mathematical Symbols-B:][:block=Supplemental Mathematical Operators:][:block=Mathematical Alphanumeric Symbols:]]",
+ 1+32+46+46+45+43+1+1); /* +1 for NUL */
+ U_STRING_INIT(mathPattern, "[:Math:]", 8);
+ U_STRING_INIT(unassignedPattern, "[:Cn:]", 6);
+ U_STRING_INIT(unknownPattern, "[:sc=Unknown:]", 14);
+ U_STRING_INIT(reservedPattern, "[[:Cn:][:Co:][:Cs:]]", 20);
+
/*
* It used to be that UCD.html and its precursors said
* "Those dashes used to mark connections between pieces of words,
@@ -2909,6 +2990,39 @@ TestConsistency() {
uset_close(set2);
#endif
+
+ /* verify that all assigned characters in Math blocks are exactly Math characters */
+ errorCode=U_ZERO_ERROR;
+ set1=uset_openPattern(mathBlocksPattern, -1, &errorCode);
+ set2=uset_openPattern(mathPattern, 8, &errorCode);
+ set3=uset_openPattern(unassignedPattern, 6, &errorCode);
+ if(U_SUCCESS(errorCode)) {
+ uset_retainAll(set2, set1); /* [math blocks]&[:Math:] */
+ uset_complement(set3); /* assigned characters */
+ uset_retainAll(set1, set3); /* [math blocks]&[assigned] */
+ compareUSets(set1, set2,
+ "[assigned Math block chars]", "[math blocks]&[:Math:]",
+ TRUE);
+ } else {
+ log_err("error opening [math blocks] or [:Math:] or [:Cn:] - %s\n", u_errorName(errorCode));
+ }
+ uset_close(set1);
+ uset_close(set2);
+ uset_close(set3);
+
+ /* new in Unicode 5.0: exactly all unassigned+PUA+surrogate code points have script=Unknown */
+ errorCode=U_ZERO_ERROR;
+ set1=uset_openPattern(unknownPattern, 14, &errorCode);
+ set2=uset_openPattern(reservedPattern, 20, &errorCode);
+ if(U_SUCCESS(errorCode)) {
+ compareUSets(set1, set2,
+ "[:sc=Unknown:]", "[[:Cn:][:Co:][:Cs:]]",
+ TRUE);
+ } else {
+ log_err("error opening [:sc=Unknown:] or [[:Cn:][:Co:][:Cs:]] - %s\n", u_errorName(errorCode));
+ }
+ uset_close(set1);
+ uset_close(set2);
}
/*
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cucdtst.h b/Build/source/libs/icu-xetex/test/cintltst/cucdtst.h
deleted file mode 100644
index ef3a68c53bc..00000000000
--- a/Build/source/libs/icu-xetex/test/cintltst/cucdtst.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/********************************************************************
- * COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
- * others. All Rights Reserved.
- ********************************************************************/
-/********************************************************************************
-*
-* File CUCDTST.H
-*
-* Modification History:
-* Name Description
-* Madhu Katragadda Converted to C, added tests for string functions
-*********************************************************************************
-*/
-/* C API TEST For Unicode */
-
-#ifndef _CUCDTST
-#define _CUCDTST
-
-/* cstrcase.c */
-U_CFUNC void TestCaseLower(void);
-U_CFUNC void TestCaseUpper(void);
-U_CFUNC void TestCaseTitle(void);
-U_CFUNC void TestCaseFolding(void);
-U_CFUNC void TestCaseCompare(void);
-U_CFUNC void TestUCaseMap(void);
-
-#endif
diff --git a/Build/source/libs/icu-xetex/test/cintltst/currtest.c b/Build/source/libs/icu-xetex/test/cintltst/currtest.c
index dd67ca2aa0d..93bbee0afa1 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/currtest.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/currtest.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2005-2005, International Business Machines Corporation and
+ * Copyright (c) 2005-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
@@ -119,7 +119,7 @@ static int32_t checkItemCount(uint32_t currencyType) {
originalCount = uenum_count(en, &status);
for (count=0;;count++) {
const char *str = uenum_next(en, &len, &status);
- if (U_FAILURE(status) || len != expectedLen || strlen(str) != expectedLen) {
+ if (str == NULL || len != expectedLen || strlen(str) != expectedLen) {
break;
}
}
@@ -128,6 +128,9 @@ static int32_t checkItemCount(uint32_t currencyType) {
log_err("Error: uenum_count returned the wrong value (type = 0x%X). Got: %d Expected %d\n",
currencyType, count, originalCount);
}
+ if (U_FAILURE(status)) {
+ log_err("Error: uenum_next got an error: %s\n", u_errorName(status));
+ }
uenum_close(en);
return count;
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/custrtrn.c b/Build/source/libs/icu-xetex/test/cintltst/custrtrn.c
index e08632abe8d..0335a005575 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/custrtrn.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/custrtrn.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2001-2005, International Business Machines Corporation and
+ * Copyright (c) 2001-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -22,6 +22,8 @@
#include "unicode/ures.h"
#include "ustr_imp.h"
#include "cintltst.h"
+#include "cmemory.h"
+#include "cstring.h"
#include "cwchar.h"
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
@@ -30,6 +32,7 @@ void addUCharTransformTest(TestNode** root);
static void Test_UChar_UTF32_API(void);
static void Test_UChar_UTF8_API(void);
+static void Test_FromUTF8Lenient(void);
static void Test_UChar_WCHART_API(void);
static void Test_widestrs(void);
static void Test_WCHART_LongString(void);
@@ -39,6 +42,7 @@ addUCharTransformTest(TestNode** root)
{
addTest(root, &Test_UChar_UTF32_API, "custrtrn/Test_UChar_UTF32_API");
addTest(root, &Test_UChar_UTF8_API, "custrtrn/Test_UChar_UTF8_API");
+ addTest(root, &Test_FromUTF8Lenient, "custrtrn/Test_FromUTF8Lenient");
addTest(root, &Test_UChar_WCHART_API, "custrtrn/Test_UChar_WCHART_API");
addTest(root, &Test_widestrs, "custrtrn/Test_widestrs");
addTest(root, &Test_WCHART_LongString, "custrtrn/Test_WCHART_LongString");
@@ -270,16 +274,21 @@ static void Test_UChar_UTF8_API(void){
int32_t u8DestLen =0;
UBool failed = FALSE;
int i= 0;
+ int32_t numSubstitutions;
+
{
/* preflight */
+ u8Temp[0] = 0x12;
u_strToUTF8(u8Target,u8TargetLength, &u8DestLen, uSrc, uSrcLen,&err);
- if(err == U_BUFFER_OVERFLOW_ERROR){
+ if(err == U_BUFFER_OVERFLOW_ERROR && u8Temp[0] == 0x12){
err = U_ZERO_ERROR;
u8Target = (char*) malloc (sizeof(uint8_t) * (u8DestLen+1));
u8TargetLength = u8DestLen;
-
+
+ u8Target[u8TargetLength] = (char)0xfe;
+ u8DestLen = -1;
u_strToUTF8(u8Target,u8TargetLength, &u8DestLen, uSrc, uSrcLen,&err);
- if(U_FAILURE(err)){
+ if(U_FAILURE(err) || u8DestLen != u8TargetLength || u8Target[u8TargetLength] != (char)0xfe){
log_err("u_strToUTF8 failed after preflight. Error: %s\n", u_errorName(err));
return;
}
@@ -308,16 +317,19 @@ static void Test_UChar_UTF8_API(void){
u8SrcLen = u8DestLen;
/* preflight */
+ uTemp[0] = 0x1234;
u_strFromUTF8(uTarget,uTargetLength,&uDestLen,u8Src,u8SrcLen,&err);
- if(err == U_BUFFER_OVERFLOW_ERROR){
+ if(err == U_BUFFER_OVERFLOW_ERROR && uTemp[0] == 0x1234){
err = U_ZERO_ERROR;
uTarget = (UChar*) malloc( sizeof(UChar) * (uDestLen+1));
uTargetLength = uDestLen;
+ uTarget[uTargetLength] = 0xfff0;
+ uDestLen = -1;
u_strFromUTF8(uTarget,uTargetLength,&uDestLen,u8Src,u8SrcLen,&err);
}
else {
- log_err("Should have gotten U_BUFFER_OVERFLOW_ERROR");
+ log_err("error: u_strFromUTF8(preflight) should have gotten U_BUFFER_OVERFLOW_ERROR\n");
}
/*for(i=0; i< uDestLen; i++){
printf("0x%04X, ",uTarget[i]);
@@ -325,7 +337,10 @@ static void Test_UChar_UTF8_API(void){
printf("\n");
}
}*/
-
+
+ if(U_FAILURE(err) || uDestLen != uTargetLength || uTarget[uTargetLength] != 0xfff0) {
+ failed = TRUE;
+ }
for(i=0; i< uSrcLen; i++){
if(uTarget[i] != src16[i]){
log_verbose("u_strFromUTF8() failed expected: \\u%04X got: \\u%04X at index: %i \n", src16[i] ,uTarget[i],i);
@@ -333,7 +348,7 @@ static void Test_UChar_UTF8_API(void){
}
}
if(failed){
- log_err("u_strToUTF8() failed \n");
+ log_err("error: u_strFromUTF8(after preflighting) failed\n");
}
free(u8Target);
@@ -414,10 +429,14 @@ static void Test_UChar_UTF8_API(void){
{
static const UChar
withLead16[]={ 0x1800, 0xd89a, 0x0061 },
- withTrail16[]={ 0x1800, 0xdcba, 0x0061, 0 };
+ withTrail16[]={ 0x1800, 0xdcba, 0x0061, 0 },
+ withTrail16SubFFFD[]={ 0x1800, 0xfffd, 0x0061, 0 }, /* sub==U+FFFD */
+ withTrail16Sub50005[]={ 0x1800, 0xd900, 0xdc05, 0x0061, 0 }; /* sub==U+50005 */
static const uint8_t
withLead8[]={ 0xe1, 0xa0, 0x80, 0xed, 0xa2, 0x9a, 0x61 },
- withTrail8[]={ 0xe1, 0xa0, 0x80, 0xed, 0xb2, 0xba, 0x61 };
+ withTrail8[]={ 0xe1, 0xa0, 0x80, 0xed, 0xb2, 0xba, 0x61, 0 },
+ withTrail8Sub1A[]={ 0xe1, 0xa0, 0x80, 0x1a, 0x61, 0 }, /* sub==U+001A */
+ withTrail8SubFFFD[]={ 0xe1, 0xa0, 0x80, 0xef, 0xbf, 0xbd, 0x61, 0 }; /* sub==U+FFFD */
UChar out16[10];
char out8[10];
@@ -429,8 +448,384 @@ static void Test_UChar_UTF8_API(void){
) {
log_err("error: u_strTo/FromUTF8(string with single surrogate) fails to report error\n");
}
+
+ /* test error handling with substitution characters */
+
+ /* from UTF-8 with length */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out16[0]=0x55aa;
+ uDestLen=0;
+ u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+ (const char *)withTrail8, uprv_strlen((const char *)withTrail8),
+ 0x50005, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || uDestLen!=u_strlen(withTrail16Sub50005) ||
+ 0!=u_memcmp(withTrail16Sub50005, out16, uDestLen+1) ||
+ numSubstitutions!=1) {
+ log_err("error: u_strFromUTF8WithSub(length) failed\n");
+ }
+
+ /* from UTF-8 with NUL termination */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out16[0]=0x55aa;
+ uDestLen=0;
+ u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+ (const char *)withTrail8, -1,
+ 0xfffd, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || uDestLen!=u_strlen(withTrail16SubFFFD) ||
+ 0!=u_memcmp(withTrail16SubFFFD, out16, uDestLen+1) ||
+ numSubstitutions!=1) {
+ log_err("error: u_strFromUTF8WithSub(NUL termination) failed\n");
+ }
+
+ /* preflight from UTF-8 with NUL termination */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out16[0]=0x55aa;
+ uDestLen=0;
+ u_strFromUTF8WithSub(out16, 1, &uDestLen,
+ (const char *)withTrail8, -1,
+ 0x50005, &numSubstitutions,
+ &err);
+ if(err!=U_BUFFER_OVERFLOW_ERROR || uDestLen!=u_strlen(withTrail16Sub50005) || numSubstitutions!=1) {
+ log_err("error: u_strFromUTF8WithSub(preflight/NUL termination) failed\n");
+ }
+
+ /* to UTF-8 with length */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out8[0]=(char)0xf5;
+ u8DestLen=0;
+ u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+ withTrail16, u_strlen(withTrail16),
+ 0xfffd, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || u8DestLen!=uprv_strlen((const char *)withTrail8SubFFFD) ||
+ 0!=uprv_memcmp((const char *)withTrail8SubFFFD, out8, u8DestLen+1) ||
+ numSubstitutions!=1) {
+ log_err("error: u_strToUTF8WithSub(length) failed\n");
+ }
+
+ /* to UTF-8 with NUL termination */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out8[0]=(char)0xf5;
+ u8DestLen=0;
+ u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+ withTrail16, -1,
+ 0x1a, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || u8DestLen!=uprv_strlen((const char *)withTrail8Sub1A) ||
+ 0!=uprv_memcmp((const char *)withTrail8Sub1A, out8, u8DestLen+1) ||
+ numSubstitutions!=1) {
+ log_err("error: u_strToUTF8WithSub(NUL termination) failed\n");
+ }
+
+ /* preflight to UTF-8 with NUL termination */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out8[0]=(char)0xf5;
+ u8DestLen=0;
+ u_strToUTF8WithSub(out8, 1, &u8DestLen,
+ withTrail16, -1,
+ 0xfffd, &numSubstitutions,
+ &err);
+ if(err!=U_BUFFER_OVERFLOW_ERROR || u8DestLen!=uprv_strlen((const char *)withTrail8SubFFFD) ||
+ numSubstitutions!=1) {
+ log_err("error: u_strToUTF8WithSub(preflight/NUL termination) failed\n");
+ }
+
+ /* test that numSubstitutions==0 if there are no substitutions */
+
+ /* from UTF-8 with length (just first 3 bytes which are valid) */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out16[0]=0x55aa;
+ uDestLen=0;
+ u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+ (const char *)withTrail8, 3,
+ 0x50005, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || uDestLen!=1 ||
+ 0!=u_memcmp(withTrail16Sub50005, out16, uDestLen) ||
+ numSubstitutions!=0) {
+ log_err("error: u_strFromUTF8WithSub(no subs) failed\n");
+ }
+
+ /* to UTF-8 with length (just first UChar which is valid) */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out8[0]=(char)0xf5;
+ u8DestLen=0;
+ u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+ withTrail16, 1,
+ 0xfffd, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || u8DestLen!=3 ||
+ 0!=uprv_memcmp((const char *)withTrail8SubFFFD, out8, u8DestLen) ||
+ numSubstitutions!=0) {
+ log_err("error: u_strToUTF8WithSub(no subs) failed\n");
+ }
+
+ /* test that numSubstitutions==0 if subchar==U_SENTINEL (no subchar) */
+
+ /* from UTF-8 with length (just first 3 bytes which are valid) */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out16[0]=0x55aa;
+ uDestLen=0;
+ u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+ (const char *)withTrail8, 3,
+ U_SENTINEL, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || uDestLen!=1 ||
+ 0!=u_memcmp(withTrail16Sub50005, out16, uDestLen) ||
+ numSubstitutions!=0) {
+ log_err("error: u_strFromUTF8WithSub(no subchar) failed\n");
+ }
+
+ /* to UTF-8 with length (just first UChar which is valid) */
+ err=U_ZERO_ERROR;
+ numSubstitutions=-1;
+ out8[0]=(char)0xf5;
+ u8DestLen=0;
+ u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+ withTrail16, 1,
+ U_SENTINEL, &numSubstitutions,
+ &err);
+ if(U_FAILURE(err) || u8DestLen!=3 ||
+ 0!=uprv_memcmp((const char *)withTrail8SubFFFD, out8, u8DestLen) ||
+ numSubstitutions!=0) {
+ log_err("error: u_strToUTF8WithSub(no subchar) failed\n");
+ }
}
}
+
+/* compare if two strings are equal, but match 0xfffd in the second string with anything in the first */
+static UBool
+equalAnyFFFD(const UChar *s, const UChar *t, int32_t length) {
+ UChar c1, c2;
+
+ while(length>0) {
+ c1=*s++;
+ c2=*t++;
+ if(c1!=c2 && c2!=0xfffd) {
+ return FALSE;
+ }
+ --length;
+ }
+ return TRUE;
+}
+
+/* test u_strFromUTF8Lenient() */
+static void
+Test_FromUTF8Lenient(void) {
+ /*
+ * Multiple input strings, each NUL-terminated.
+ * Terminate with a string starting with 0xff.
+ */
+ static const uint8_t bytes[]={
+ /* well-formed UTF-8 */
+ 0x61, 0xc3, 0x9f, 0xe0, 0xa0, 0x80, 0xf0, 0xa0, 0x80, 0x80,
+ 0x62, 0xc3, 0xa0, 0xe0, 0xa0, 0x81, 0xf0, 0xa0, 0x80, 0x81, 0,
+
+ /* various malformed sequences */
+ 0xc3, 0xc3, 0x9f, 0xc3, 0xa0, 0xe0, 0x80, 0x8a, 0xf0, 0x41, 0x42, 0x43, 0,
+
+ /* truncated input */
+ 0xc3, 0,
+ 0xe0, 0,
+ 0xe0, 0xa0, 0,
+ 0xf0, 0,
+ 0xf0, 0x90, 0,
+ 0xf0, 0x90, 0x80, 0,
+
+ /* empty string */
+ 0,
+
+ /* finish */
+ 0xff, 0
+ };
+
+ /* Multiple output strings, each NUL-terminated. 0xfffd matches anything. */
+ static const UChar uchars[]={
+ 0x61, 0xdf, 0x800, 0xd840, 0xdc00,
+ 0x62, 0xe0, 0x801, 0xd840, 0xdc01, 0,
+
+ 0xfffd, 0x9f, 0xe0, 0xa, 0xfffd, 0xfffd, 0,
+
+ 0xfffd, 0,
+ 0xfffd, 0,
+ 0xfffd, 0,
+ 0xfffd, 0,
+ 0xfffd, 0,
+ 0xfffd, 0,
+
+ 0,
+
+ 0
+ };
+
+ UChar dest[64];
+ const char *pb;
+ const UChar *pu, *pDest;
+ int32_t srcLength, destLength0, destLength;
+ int number;
+ UErrorCode errorCode;
+
+ /* verify checking for some illegal arguments */
+ dest[0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, 1, &destLength, NULL, -1, &errorCode);
+ if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=0x1234) {
+ log_err("u_strFromUTF8Lenient(src=NULL) failed\n");
+ }
+
+ dest[0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(NULL, 1, &destLength, (const char *)bytes, -1, &errorCode);
+ if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("u_strFromUTF8Lenient(dest=NULL[1]) failed\n");
+ }
+
+ dest[0]=0x1234;
+ destLength=-1;
+ errorCode=U_MEMORY_ALLOCATION_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, 1, &destLength, (const char *)bytes, -1, &errorCode);
+ if(errorCode!=U_MEMORY_ALLOCATION_ERROR || dest[0]!=0x1234) {
+ log_err("u_strFromUTF8Lenient(U_MEMORY_ALLOCATION_ERROR) failed\n");
+ }
+
+ dest[0]=0x1234;
+ destLength=-1;
+ errorCode=U_MEMORY_ALLOCATION_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, 1, &destLength, (const char *)bytes, -1, NULL);
+ if(dest[0]!=0x1234) {
+ log_err("u_strFromUTF8Lenient(pErrorCode=NULL) failed\n");
+ }
+
+ /* test normal behavior */
+ number=0; /* string number for log_err() */
+
+ for(pb=(const char *)bytes, pu=uchars;
+ *pb!=(char)0xff;
+ pb+=srcLength+1, pu+=destLength0+1, ++number
+ ) {
+ srcLength=uprv_strlen(pb);
+ destLength0=u_strlen(pu);
+
+ /* preflighting with NUL-termination */
+ dest[0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(NULL, 0, &destLength, pb, -1, &errorCode);
+ if (errorCode!= (destLength0==0 ? U_STRING_NOT_TERMINATED_WARNING : U_BUFFER_OVERFLOW_ERROR) ||
+ pDest!=NULL || dest[0]!=0x1234 || destLength!=destLength0
+ ) {
+ log_err("u_strFromUTF8Lenient(%d preflighting with NUL-termination) failed\n", number);
+ }
+
+ /* preflighting/some capacity with NUL-termination */
+ if(srcLength>0) {
+ dest[destLength0-1]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, destLength0-1, &destLength, pb, -1, &errorCode);
+ if (errorCode!=U_BUFFER_OVERFLOW_ERROR ||
+ dest[destLength0-1]!=0x1234 || destLength!=destLength0
+ ) {
+ log_err("u_strFromUTF8Lenient(%d preflighting/some capacity with NUL-termination) failed\n", number);
+ }
+ }
+
+ /* conversion with NUL-termination, much capacity */
+ dest[0]=dest[destLength0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, LENGTHOF(dest), &destLength, pb, -1, &errorCode);
+ if (errorCode!=U_ZERO_ERROR ||
+ pDest!=dest || dest[destLength0]!=0 ||
+ destLength!=destLength0 || !equalAnyFFFD(dest, pu, destLength)
+ ) {
+ log_err("u_strFromUTF8Lenient(%d conversion with NUL-termination, much capacity) failed\n", number);
+ }
+
+ /* conversion with NUL-termination, exact capacity */
+ dest[0]=dest[destLength0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, destLength0, &destLength, pb, -1, &errorCode);
+ if (errorCode!=U_STRING_NOT_TERMINATED_WARNING ||
+ pDest!=dest || dest[destLength0]!=0x1234 ||
+ destLength!=destLength0 || !equalAnyFFFD(dest, pu, destLength)
+ ) {
+ log_err("u_strFromUTF8Lenient(%d conversion with NUL-termination, exact capacity) failed\n", number);
+ }
+
+ /* preflighting with length */
+ dest[0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(NULL, 0, &destLength, pb, srcLength, &errorCode);
+ if (errorCode!= (destLength0==0 ? U_STRING_NOT_TERMINATED_WARNING : U_BUFFER_OVERFLOW_ERROR) ||
+ pDest!=NULL || dest[0]!=0x1234 || destLength!=srcLength
+ ) {
+ log_err("u_strFromUTF8Lenient(%d preflighting with length) failed\n", number);
+ }
+
+ /* preflighting/some capacity with length */
+ if(srcLength>0) {
+ dest[srcLength-1]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, srcLength-1, &destLength, pb, srcLength, &errorCode);
+ if (errorCode!=U_BUFFER_OVERFLOW_ERROR ||
+ dest[srcLength-1]!=0x1234 || destLength!=srcLength
+ ) {
+ log_err("u_strFromUTF8Lenient(%d preflighting/some capacity with length) failed\n", number);
+ }
+ }
+
+ /* conversion with length, much capacity */
+ dest[0]=dest[destLength0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, LENGTHOF(dest), &destLength, pb, srcLength, &errorCode);
+ if (errorCode!=U_ZERO_ERROR ||
+ pDest!=dest || dest[destLength0]!=0 ||
+ destLength!=destLength0 || !equalAnyFFFD(dest, pu, destLength)
+ ) {
+ log_err("u_strFromUTF8Lenient(%d conversion with length, much capacity) failed\n", number);
+ }
+
+ /* conversion with length, srcLength capacity */
+ dest[0]=dest[srcLength]=dest[destLength0]=0x1234;
+ destLength=-1;
+ errorCode=U_ZERO_ERROR;
+ pDest=u_strFromUTF8Lenient(dest, srcLength, &destLength, pb, srcLength, &errorCode);
+ if(srcLength==destLength0) {
+ if (errorCode!=U_STRING_NOT_TERMINATED_WARNING ||
+ pDest!=dest || dest[destLength0]!=0x1234 ||
+ destLength!=destLength0 || !equalAnyFFFD(dest, pu, destLength)
+ ) {
+ log_err("u_strFromUTF8Lenient(%d conversion with length, srcLength capacity/not terminated) failed\n", number);
+ }
+ } else {
+ if (errorCode!=U_ZERO_ERROR ||
+ pDest!=dest || dest[destLength0]!=0 ||
+ destLength!=destLength0 || !equalAnyFFFD(dest, pu, destLength)
+ ) {
+ log_err("u_strFromUTF8Lenient(%d conversion with length, srcLength capacity/terminated) failed\n", number);
+ }
+ }
+ }
+}
+
static const uint16_t src16j[] = {
0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x000D, 0x000A,
0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x000D, 0x000A,
@@ -671,7 +1066,7 @@ static void Test_UChar_WCHART_API(void){
}
}
#else
- log_info("Not testing u_str*WCS because (!UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION) and wchar is neither utf16 nor utf32");
+ log_info("Not testing u_str*WCS because (!UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION) and wchar is neither utf16 nor utf32");
#endif
}
@@ -713,7 +1108,7 @@ static void Test_widestrs()
log_err("u_strFromWCS: wcs = %S, wl = %d,rts = %s, rtl = %d!\n", wcs, wl, u_austrcpy(astr, rts), rtl);
}
#else
- log_info("Not testing u_str*WCS because (!UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION) and wchar is neither utf16 nor utf32");
+ log_info("Not testing u_str*WCS because (!UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION) and wchar is neither utf16 nor utf32");
#endif
}
@@ -777,7 +1172,7 @@ Test_WCHART_LongString(){
/* close the bundle */
ures_close(theBundle);
#else
- log_info("Not testing u_str*WCS because (!UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION) and wchar is neither utf16 nor utf32");
+ log_info("Not testing u_str*WCS because (!UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION) and wchar is neither utf16 nor utf32");
#endif
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/custrtst.c b/Build/source/libs/icu-xetex/test/cintltst/custrtst.c
index 3e7ac9eb9d3..76cae0be6d7 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/custrtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/custrtst.c
@@ -1,7 +1,7 @@
/*
******************************************************************************
*
-* Copyright (C) 2002-2005, International Business Machines
+* Copyright (C) 2002-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@@ -16,15 +16,11 @@
* Tests of ustring.h Unicode string API functions.
*/
-#include "unicode/utypes.h"
#include "unicode/ustring.h"
-#include "unicode/uloc.h"
#include "unicode/ucnv.h"
#include "unicode/uiter.h"
#include "cintltst.h"
-#include "cucdtst.h"
#include <string.h>
-#include <stdlib.h>
#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
@@ -42,6 +38,7 @@ static void TestUnescape(void);
static void TestCountChar32(void);
static void TestUCharIterator(void);
static void TestUNormIterator(void);
+static void TestBadUNormIterator(void);
void addUStringTest(TestNode** root);
@@ -55,16 +52,7 @@ void addUStringTest(TestNode** root)
addTest(root, &TestCountChar32, "tsutil/custrtst/TestCountChar32");
addTest(root, &TestUCharIterator, "tsutil/custrtst/TestUCharIterator");
addTest(root, &TestUNormIterator, "tsutil/custrtst/TestUNormIterator");
-
- /* cstrcase.c functions, declared in cucdtst.h */
- addTest(root, &TestCaseLower, "tsutil/custrtst/TestCaseLower");
- addTest(root, &TestCaseUpper, "tsutil/custrtst/TestCaseUpper");
-#if !UCONFIG_NO_BREAK_ITERATION
- addTest(root, &TestCaseTitle, "tsutil/custrtst/TestCaseTitle");
-#endif
- addTest(root, &TestCaseFolding, "tsutil/custrtst/TestCaseFolding");
- addTest(root, &TestCaseCompare, "tsutil/custrtst/TestCaseCompare");
- addTest(root, &TestUCaseMap, "tsutil/custrtst/TestUCaseMap");
+ addTest(root, &TestBadUNormIterator, "tsutil/custrtst/TestBadUNormIterator");
}
/* test data for TestStringFunctions ---------------------------------------- */
@@ -1534,6 +1522,11 @@ TestUNormIterator() {
/* test nothing */
}
+static void
+TestBadUNormIterator(void) {
+ /* test nothing, as well */
+}
+
#else
#include "unicode/unorm.h"
@@ -1795,4 +1788,30 @@ TestUNormIterator() {
testUNormIteratorWithText(surrogateText, length, length, "UCharIterSurrEnd", "UNormIterSurrEnd1");
}
+static void
+TestBadUNormIterator(void) {
+#if !UCONFIG_NO_NORMALIZATION
+ UErrorCode status = U_ILLEGAL_ESCAPE_SEQUENCE;
+ UNormIterator *uni;
+
+ unorm_setIter(NULL, NULL, UNORM_NONE, &status);
+ if (status != U_ILLEGAL_ESCAPE_SEQUENCE) {
+ log_err("unorm_setIter changed the error code to: %s\n", u_errorName(status));
+ }
+ status = U_ZERO_ERROR;
+ unorm_setIter(NULL, NULL, UNORM_NONE, &status);
+ if (status != U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("unorm_setIter didn't react correctly to bad arguments: %s\n", u_errorName(status));
+ }
+ status = U_ZERO_ERROR;
+ uni=unorm_openIter(NULL, 0, &status);
+ if(U_FAILURE(status)) {
+ log_err("unorm_openIter() fails: %s\n", u_errorName(status));
+ return;
+ }
+ unorm_setIter(uni, NULL, UNORM_NONE, &status);
+ unorm_closeIter(uni);
+#endif
+}
+
#endif
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cutiltst.c b/Build/source/libs/icu-xetex/test/cintltst/cutiltst.c
index c19b23de923..2bb339c6d96 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cutiltst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cutiltst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -18,6 +18,7 @@ void addLocaleTest(TestNode**);
void addCLDRTest(TestNode**);
void addUnicodeTest(TestNode**);
void addUStringTest(TestNode**);
+void addCaseTest(TestNode**);
void addResourceBundleTest(TestNode**);
void addNEWResourceBundleTest(TestNode**);
void addHashtableTest(TestNode** root);
@@ -37,6 +38,7 @@ void addUtility(TestNode** root)
addCLDRTest(root);
addUnicodeTest(root);
addUStringTest(root);
+ addCaseTest(root);
addResourceBundleTest(root);
addNEWResourceBundleTest(root);
addHashtableTest(root);
diff --git a/Build/source/libs/icu-xetex/test/cintltst/eurocreg.c b/Build/source/libs/icu-xetex/test/cintltst/eurocreg.c
index 99b5bd89a4d..a070374b802 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/eurocreg.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/eurocreg.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1999-2005, International Business Machines Corporation and
+ * Copyright (c) 1999-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
@@ -11,6 +11,7 @@
void TestEuroRegression(void);
void addTestEuroRegression(TestNode** root);
+#if !UCONFIG_NO_LEGACY_CONVERSION
void addTestEuroRegression(TestNode** root)
{
addTest(root, &TestEuroRegression, "tsconv/eurocreg/TestEuroRegression");
@@ -179,3 +180,9 @@ UBool isEuroAware(UConverter* myConv)
}
}
+#else
+void addTestEuroRegression(TestNode** root)
+{
+ /* test nothing... */
+}
+#endif
diff --git a/Build/source/libs/icu-xetex/test/cintltst/hpmufn.c b/Build/source/libs/icu-xetex/test/cintltst/hpmufn.c
index a67578f99e3..ef7d202395d 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/hpmufn.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/hpmufn.c
@@ -137,6 +137,20 @@ static void TestHeapFunctions() {
utrace_getFunctions(&traceContext, &traceEntryFunc, &traceExitFunc, &traceDataFunc);
traceLevel = utrace_getLevel();
+ /* Verify that ICU can be cleaned up and reinitialized successfully.
+ * Failure here usually means that some ICU service didn't clean up successfully,
+ * probably because some earlier test accidently left something open. */
+ u_cleanup();
+ utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
+ utrace_setLevel(traceLevel);
+ status = U_ZERO_ERROR;
+ u_setDataDirectory(icuDataDir);
+ u_init(&status);
+ TEST_STATUS(status, U_ZERO_ERROR);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
/* Can not set memory functions if ICU is already initialized */
u_setMemoryFunctions(&gContext, myMemAlloc, myMemRealloc, myMemFree, &status);
TEST_STATUS(status, U_INVALID_STATE_ERROR);
@@ -287,6 +301,20 @@ static void TestMutexFunctions() {
utrace_getFunctions(&traceContext, &traceEntryFunc, &traceExitFunc, &traceDataFunc);
traceLevel = utrace_getLevel();
+ /* Verify that ICU can be cleaned up and reinitialized successfully.
+ * Failure here usually means that some ICU service didn't clean up successfully,
+ * probably because some earlier test accidently left something open. */
+ u_cleanup();
+ utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
+ utrace_setLevel(traceLevel);
+ status = U_ZERO_ERROR;
+ u_setDataDirectory(icuDataDir);
+ u_init(&status);
+ TEST_STATUS(status, U_ZERO_ERROR);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
/* Can not set mutex functions if ICU is already initialized */
u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, myMutexLock, myMutexUnlock, &status);
TEST_STATUS(status, U_INVALID_STATE_ERROR);
@@ -410,14 +438,31 @@ static void TestIncDecFunctions() {
const void *traceContext;
int32_t traceLevel;
+ /* Save ICU's data dir and tracing functions so that they can be resored
+ after cleanup and reinit. */
+ dataDir = safeGetICUDataDirectory();
+ utrace_getFunctions(&traceContext, &traceEntryFunc, &traceExitFunc, &traceDataFunc);
+ traceLevel = utrace_getLevel();
+
+ /* Verify that ICU can be cleaned up and reinitialized successfully.
+ * Failure here usually means that some ICU service didn't clean up successfully,
+ * probably because some earlier test accidently left something open. */
+ u_cleanup();
+ utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
+ utrace_setLevel(traceLevel);
+ status = U_ZERO_ERROR;
+ u_setDataDirectory(dataDir);
+ u_init(&status);
+ TEST_STATUS(status, U_ZERO_ERROR);
+ if (U_FAILURE(status)) {
+ return;
+ }
+
/* Can not set mutex functions if ICU is already initialized */
u_setAtomicIncDecFunctions(&gIncDecContext, myIncFunc, myDecFunc, &status);
TEST_STATUS(status, U_INVALID_STATE_ERROR);
- /* Un-initialize ICU */
- dataDir = safeGetICUDataDirectory();
- utrace_getFunctions(&traceContext, &traceEntryFunc, &traceExitFunc, &traceDataFunc);
- traceLevel = utrace_getLevel();
+ /* Clean up ICU */
u_cleanup();
utrace_setFunctions(traceContext, traceEntryFunc, traceExitFunc, traceDataFunc);
utrace_setLevel(traceLevel);
diff --git a/Build/source/libs/icu-xetex/test/cintltst/nccbtst.c b/Build/source/libs/icu-xetex/test/cintltst/nccbtst.c
index 64d0922e3a3..d82d37b9e6d 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/nccbtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/nccbtst.c
@@ -1,15 +1,16 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
+********************************************************************************
* File NCCBTST.C
*
* Modification History:
* Name Description
* Madhu Katragadda 7/21/1999 Testing error callback routines
-**************************************************************************************
+********************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
@@ -23,6 +24,7 @@
#include "unicode/utypes.h"
#include "unicode/ustring.h"
#include "nccbtst.h"
+#include "unicode/ucnv_cb.h"
#define NEW_MAX_BUFFER 999
#define nct_min(x,y) ((x<y) ? x : y)
@@ -78,6 +80,8 @@ static void setNuConvTestName(const char *codepage, const char *direction)
}
+static void TestCallBackFailure(void);
+
void addTestConvertErrorCallBack(TestNode** root);
void addTestConvertErrorCallBack(TestNode** root)
@@ -86,8 +90,13 @@ void addTestConvertErrorCallBack(TestNode** root)
addTest(root, &TestStopCallBack, "tsconv/nccbtst/TestStopCallBack");
addTest(root, &TestSubCallBack, "tsconv/nccbtst/TestSubCallBack");
addTest(root, &TestSubWithValueCallBack, "tsconv/nccbtst/TestSubWithValueCallBack");
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestLegalAndOtherCallBack, "tsconv/nccbtst/TestLegalAndOtherCallBack");
addTest(root, &TestSingleByteCallBack, "tsconv/nccbtst/TestSingleByteCallBack");
+#endif
+
+ addTest(root, &TestCallBackFailure, "tsconv/nccbtst/TestCallBackFailure");
}
static void TestSkipCallBack()
@@ -112,12 +121,13 @@ static void TestSubCallBack()
TestSub(1,NEW_MAX_BUFFER);
TestSub(1,1);
TestSub(NEW_MAX_BUFFER, 1);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
TestEBCDIC_STATEFUL_Sub(1, 1);
TestEBCDIC_STATEFUL_Sub(1, NEW_MAX_BUFFER);
TestEBCDIC_STATEFUL_Sub(NEW_MAX_BUFFER, 1);
TestEBCDIC_STATEFUL_Sub(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
-
-
+#endif
}
static void TestSubWithValueCallBack()
@@ -128,6 +138,7 @@ static void TestSubWithValueCallBack()
TestSubWithValue(NEW_MAX_BUFFER, 1);
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestLegalAndOtherCallBack()
{
TestLegalAndOthers(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
@@ -143,6 +154,7 @@ static void TestSingleByteCallBack()
TestSingleByte(1,1);
TestSingleByte(NEW_MAX_BUFFER, 1);
}
+#endif
static void TestSkip(int32_t inputsize, int32_t outputsize)
{
@@ -161,6 +173,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
/*From Unicode*/
log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_SKIP \n");
+#if !UCONFIG_NO_LEGACY_CONVERSION
{
static const UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 };
static const UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 };
@@ -193,6 +206,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("u->ibm-930 with skip with untaken fallbacks did not match.\n");
}
}
+#endif
{
static const UChar usasciiFromU[] = { 0x61, 0x80, 0x4e00, 0x31, 0xd800, 0xdfff, 0x39 };
@@ -213,6 +227,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("u->US-ASCII with skip did not match.\n");
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
/* SBCS NLTC codepage 367 for US-ASCII */
if(!testConvertFromUnicode(usasciiFromU, sizeof(usasciiFromU)/U_SIZEOF_UCHAR,
usasciiFromUBytes, sizeof(usasciiFromUBytes),
@@ -222,6 +237,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
) {
log_err("u->ibm-367 with skip did not match.\n");
}
+#endif
/* ISO-Latin-1 */
if(!testConvertFromUnicode(latin1FromU, sizeof(latin1FromU)/U_SIZEOF_UCHAR,
@@ -233,6 +249,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("u->LATIN_1 with skip did not match.\n");
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
/* windows-1252 */
if(!testConvertFromUnicode(latin1FromU, sizeof(latin1FromU)/U_SIZEOF_UCHAR,
latin1FromUBytes, sizeof(latin1FromUBytes),
@@ -365,6 +382,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
};
+#endif
static const UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, };
@@ -379,6 +397,8 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
2,
};
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
/* ISCII */
static const UChar iscii_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, };
static const uint8_t to_iscii[]={
@@ -456,7 +476,8 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
if(!testConvertFromUnicodeWithContext(hz_inputText1, sizeof(hz_inputText1)/sizeof(hz_inputText1[0]),
to_hz1, sizeof(to_hz1), "hz",
UCNV_FROM_U_CALLBACK_SKIP, from_hzOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
- log_err("u-> hz with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
+ log_err("u-> hz with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
+#endif
/*SCSU*/
if(!testConvertFromUnicode(SCSU_inputText, sizeof(SCSU_inputText)/sizeof(SCSU_inputText[0]),
@@ -464,6 +485,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_SKIP, from_SCSUOffs, NULL, 0 ))
log_err("u-> SCSU with skip did not match.\n");
+#if !UCONFIG_NO_LEGACY_CONVERSION
/*ISCII*/
if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
to_iscii, sizeof(to_iscii), "ISCII,version=0",
@@ -474,7 +496,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
to_iscii1, sizeof(to_iscii1), "ISCII,version=0",
UCNV_FROM_U_CALLBACK_SKIP, from_isciiOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
log_err("u-> iscii with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
-
+#endif
}
log_verbose("Testing fromUnicode for BOCU-1 with UCNV_TO_U_CALLBACK_SKIP\n");
@@ -625,6 +647,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
/*to Unicode*/
log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_SKIP \n");
+#if !UCONFIG_NO_LEGACY_CONVERSION
{
static const UChar IBM_949skiptoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xD700 };
@@ -656,6 +679,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
UCNV_TO_U_CALLBACK_SKIP, fromIBM930Offs, NULL, 0,"i",U_ILLEGAL_CHAR_FOUND ))
log_err("ibm-930->u with skip did not match.\n");
}
+#endif
{
static const uint8_t usasciiToUBytes[] = { 0x61, 0x80, 0x31 };
@@ -676,6 +700,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("US-ASCII->u with skip did not match.\n");
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
/* SBCS NLTC codepage 367 for US-ASCII */
if(!testConvertToUnicode(usasciiToUBytes, sizeof(usasciiToUBytes),
usasciiToU, sizeof(usasciiToU)/U_SIZEOF_UCHAR,
@@ -685,6 +710,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
) {
log_err("ibm-367->u with skip did not match.\n");
}
+#endif
/* ISO-Latin-1 */
if(!testConvertToUnicode(latin1ToUBytes, sizeof(latin1ToUBytes),
@@ -696,6 +722,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("LATIN_1->u with skip did not match.\n");
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
/* windows-1252 */
if(!testConvertToUnicode(latin1ToUBytes, sizeof(latin1ToUBytes),
latin1ToU, sizeof(latin1ToU)/U_SIZEOF_UCHAR,
@@ -705,8 +732,10 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
) {
log_err("windows-1252->u with skip did not match.\n");
}
+#endif
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
{
static const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={
0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44
@@ -869,6 +898,8 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("LMBCS->u with skip did not match.\n");
}
+#endif
+
log_verbose("Testing to Unicode for UTF-8 with UCNV_TO_U_CALLBACK_SKIP \n");
{
const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
@@ -1068,7 +1099,10 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
gInBufferSize = inputsize;
gOutBufferSize = outputsize;
+
/*From Unicode*/
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expstopIBM_949, sizeof(expstopIBM_949), "ibm-949",
UCNV_FROM_U_CALLBACK_STOP, toIBM949Offsstop, NULL, 0 ))
@@ -1200,6 +1234,8 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
}
+#endif
+
log_verbose("Testing fromUnicode for SCSU with UCNV_FROM_U_CALLBACK_STOP \n");
{
static const UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, };
@@ -1218,7 +1254,10 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
log_err("u-> SCSU with skip did not match.\n");
}
+
/*to Unicode*/
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertToUnicode(expstopIBM_949, sizeof(expstopIBM_949),
IBM_949stoptoUnicode, sizeof(IBM_949stoptoUnicode)/sizeof(IBM_949stoptoUnicode[0]),"ibm-949",
UCNV_TO_U_CALLBACK_STOP, fromIBM949Offs, NULL, 0 ))
@@ -1275,6 +1314,8 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
UCNV_TO_U_CALLBACK_STOP, from_euc_twOffs, NULL, 0 ))
log_err("euc-tw->u with stop did not match.\n");
}
+#endif
+
log_verbose("Testing toUnicode for UTF-8 with UCNV_TO_U_CALLBACK_STOP \n");
{
static const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
@@ -1331,6 +1372,8 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
gOutBufferSize = outputsize;
/*from unicode*/
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expsubIBM_949, sizeof(expsubIBM_949), "ibm-949",
UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM949Offssub, NULL, 0 ))
@@ -1384,6 +1427,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 ))
log_err("u-> euc-tw with substitute did not match.\n");
}
+#endif
log_verbose("Testing fromUnicode for SCSU with UCNV_FROM_U_CALLBACK_SUBSTITUTE \n");
{
@@ -1493,6 +1537,8 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
}
/*to unicode*/
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertToUnicode(expsubIBM_949, sizeof(expsubIBM_949),
IBM_949subtoUnicode, sizeof(IBM_949subtoUnicode)/sizeof(IBM_949subtoUnicode[0]),"ibm-949",
UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM949Offs, NULL, 0 ))
@@ -1557,10 +1603,9 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ,"i", U_ILLEGAL_CHAR_FOUND))
log_err("euc-jp->u with substitute did not match.\n");
-
-
-
}
+#endif
+
log_verbose("Testing toUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
{
const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
@@ -1585,6 +1630,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
log_err("scsu->u with stop did not match.\n");;
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing ibm-930 subchar/subchar1\n");
{
static const UChar u1[]={ 0x6d63, 0x6d64, 0x6d65, 0x6d66, 0xdf };
@@ -1623,6 +1669,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
log_err("gb18030->u with substitute did not match.\n");
}
}
+#endif
log_verbose("Testing UTF-7 toUnicode with substitute callbacks\n");
{
@@ -1750,6 +1797,8 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
gOutBufferSize = outputsize;
/*from Unicode*/
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expsubwvalIBM_949, sizeof(expsubwvalIBM_949), "ibm-949",
UCNV_FROM_U_CALLBACK_ESCAPE, toIBM949Offs, NULL, 0 ))
@@ -2187,11 +2236,12 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0 ))
log_err("u-> iscii with subst with value did not match.\n");
}
-
+#endif
log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_ESCAPE \n");
/*to Unicode*/
{
+#if !UCONFIG_NO_LEGACY_CONVERSION
static const uint8_t sampleTxtToU[]= { 0x00, 0x9f, 0xaf,
0x81, 0xad, /*unassigned*/
0x89, 0xd3 };
@@ -2302,7 +2352,7 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
0x42,};
static const int32_t from_isciiOffs [] ={0,1,2,2,2,2,3,4,5,5,5,5,6 };
-
+#endif
/*UTF8*/
static const uint8_t sampleTxtUTF8[]={
@@ -2341,7 +2391,8 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
9
};
-
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertToUnicode(sampleTxtToU, sizeof(sampleTxtToU),
IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943",
UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs, NULL, 0 ))
@@ -2424,6 +2475,8 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
isciitoUnicode, sizeof(isciitoUnicode)/sizeof(isciitoUnicode[0]),"ISCII,version=0",
UCNV_TO_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0))
log_err("ISCII ->u with substitute with value did not match.\n");
+#endif
+
if(!testConvertToUnicode(sampleTxtUTF8, sizeof(sampleTxtUTF8),
UTF8ToUnicode, sizeof(UTF8ToUnicode)/sizeof(UTF8ToUnicode[0]),"UTF-8",
UCNV_TO_U_CALLBACK_ESCAPE, fromUTF8, NULL, 0))
@@ -2435,6 +2488,7 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
}
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestLegalAndOthers(int32_t inputsize, int32_t outputsize)
{
static const UChar legalText[] = { 0x0000, 0xAC00, 0xAC01, 0xD700 };
@@ -2522,8 +2576,7 @@ static void TestEBCDIC_STATEFUL_Sub(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930_subvaried, mySubChar, 1 ))
log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst(setSubChar=0x3f) did not match.\n");
}
-
-
+#endif
UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
const char *codepage, UConverterFromUCallback callback , const int32_t *expectOffsets,
@@ -2533,28 +2586,28 @@ UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t
UErrorCode status = U_ZERO_ERROR;
UConverter *conv = 0;
- uint8_t junkout[NEW_MAX_BUFFER]; /* FIX */
+ char junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
const UChar *src;
- uint8_t *end;
- uint8_t *targ;
+ char *end;
+ char *targ;
int32_t *offs;
int i;
int32_t realBufferSize;
- uint8_t *realBufferEnd;
+ char *realBufferEnd;
const UChar *realSourceEnd;
const UChar *sourceLimit;
UBool checkOffsets = TRUE;
UBool doFlush;
char junk[9999];
char offset_str[9999];
- uint8_t *p;
+ char *p;
UConverterFromUCallback oldAction = NULL;
const void* oldContext = NULL;
for(i=0;i<NEW_MAX_BUFFER;i++)
- junkout[i] = 0xF0;
+ junkout[i] = (char)0xF0;
for(i=0;i<NEW_MAX_BUFFER;i++)
junokout[i] = 0xFF;
setNuConvTestName(codepage, "FROM");
@@ -2684,7 +2737,7 @@ UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t
{
log_err("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
log_verbose("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
- printSeqErr(junkout, (int32_t)(targ-junkout));
+ printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
printSeqErr(expect, expectLen);
return FALSE;
}
@@ -2695,7 +2748,7 @@ UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t
if(memcmp(junokout,expectOffsets,(targ-junkout) * sizeof(int32_t) )){
log_err("did not get the expected offsets while %s \n", gNuConvTestName);
log_err("Got Output : ");
- printSeqErr(junkout, (int32_t)(targ-junkout));
+ printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
log_err("Got Offsets: ");
for(p=junkout;p<targ;p++)
log_err("%d,", junokout[p-junkout]);
@@ -2719,7 +2772,7 @@ UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t
log_err("source: ");
printUSeqErr(source, sourceLen);
log_err("Got: ");
- printSeqErr(junkout, expectLen);
+ printSeqErr((const uint8_t *)junkout, expectLen);
log_err("Expected: ");
printSeqErr(expect, expectLen);
return FALSE;
@@ -2734,9 +2787,9 @@ UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *e
UConverter *conv = 0;
UChar junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
- const uint8_t *src;
- const uint8_t *realSourceEnd;
- const uint8_t *srcLimit;
+ const char *src;
+ const char *realSourceEnd;
+ const char *srcLimit;
UChar *targ;
UChar *end;
int32_t *offs;
@@ -2771,7 +2824,7 @@ UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *e
log_verbose("Converter opened..\n");
- src = source;
+ src = (const char *)source;
targ = junkout;
offs = junokout;
@@ -2831,8 +2884,8 @@ UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *e
char errChars[50]; /* should be sufficient */
int8_t errLen = 50;
UErrorCode err = U_ZERO_ERROR;
- const uint8_t* limit= NULL;
- const uint8_t* start= NULL;
+ const char* limit= NULL;
+ const char* start= NULL;
ucnv_getInvalidChars(conv,errChars, &errLen, &err);
if(U_FAILURE(err)){
log_err("ucnv_getInvalidChars failed with error : %s\n",u_errorName(err));
@@ -2841,7 +2894,7 @@ UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *e
limit = src;
/* length of in invalid chars should be equal to returned length*/
start = src - errLen;
- if(uprv_strncmp(errChars,(char*)start,errLen)!=0){
+ if(uprv_strncmp(errChars,start,errLen)!=0){
log_err("ucnv_getInvalidChars did not return the correct invalid chars for encoding %s \n", ucnv_getName(conv,&err));
}
}
@@ -2898,7 +2951,7 @@ UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *e
log_err("0x%04x,", junkout[i]);
log_err("\n");
log_err("From source: ");
- for(i=0; i<(src-source); i++)
+ for(i=0; i<(src-(const char *)source); i++)
log_err(" 0x%02x,", (unsigned char)source[i]);
log_err("\n");
}
@@ -2930,28 +2983,28 @@ UBool testConvertFromUnicodeWithContext(const UChar *source, int sourceLen, con
UErrorCode status = U_ZERO_ERROR;
UConverter *conv = 0;
- uint8_t junkout[NEW_MAX_BUFFER]; /* FIX */
+ char junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
const UChar *src;
- uint8_t *end;
- uint8_t *targ;
+ char *end;
+ char *targ;
int32_t *offs;
int i;
int32_t realBufferSize;
- uint8_t *realBufferEnd;
+ char *realBufferEnd;
const UChar *realSourceEnd;
const UChar *sourceLimit;
UBool checkOffsets = TRUE;
UBool doFlush;
char junk[9999];
char offset_str[9999];
- uint8_t *p;
+ char *p;
UConverterFromUCallback oldAction = NULL;
const void* oldContext = NULL;
for(i=0;i<NEW_MAX_BUFFER;i++)
- junkout[i] = 0xF0;
+ junkout[i] = (char)0xF0;
for(i=0;i<NEW_MAX_BUFFER;i++)
junokout[i] = 0xFF;
setNuConvTestName(codepage, "FROM");
@@ -3061,7 +3114,7 @@ UBool testConvertFromUnicodeWithContext(const UChar *source, int sourceLen, con
{
log_err("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
log_verbose("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
- printSeqErr(junkout, (int32_t)(targ-junkout));
+ printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
printSeqErr(expect, expectLen);
return FALSE;
}
@@ -3072,7 +3125,7 @@ UBool testConvertFromUnicodeWithContext(const UChar *source, int sourceLen, con
if(memcmp(junokout,expectOffsets,(targ-junkout) * sizeof(int32_t) )){
log_err("did not get the expected offsets while %s \n", gNuConvTestName);
log_err("Got Output : ");
- printSeqErr(junkout, (int32_t)(targ-junkout));
+ printSeqErr((const uint8_t *)junkout, (int32_t)(targ-junkout));
log_err("Got Offsets: ");
for(p=junkout;p<targ;p++)
log_err("%d,", junokout[p-junkout]);
@@ -3096,7 +3149,7 @@ UBool testConvertFromUnicodeWithContext(const UChar *source, int sourceLen, con
log_err("source: ");
printUSeqErr(source, sourceLen);
log_err("Got: ");
- printSeqErr(junkout, expectLen);
+ printSeqErr((const uint8_t *)junkout, expectLen);
log_err("Expected: ");
printSeqErr(expect, expectLen);
return FALSE;
@@ -3110,9 +3163,9 @@ UBool testConvertToUnicodeWithContext( const uint8_t *source, int sourcelen, con
UConverter *conv = 0;
UChar junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
- const uint8_t *src;
- const uint8_t *realSourceEnd;
- const uint8_t *srcLimit;
+ const char *src;
+ const char *realSourceEnd;
+ const char *srcLimit;
UChar *targ;
UChar *end;
int32_t *offs;
@@ -3147,7 +3200,7 @@ UBool testConvertToUnicodeWithContext( const uint8_t *source, int sourcelen, con
log_verbose("Converter opened..\n");
- src = source;
+ src = (const char *)source;
targ = junkout;
offs = junokout;
@@ -3255,7 +3308,7 @@ UBool testConvertToUnicodeWithContext( const uint8_t *source, int sourcelen, con
log_err("0x%04x,", junkout[i]);
log_err("\n");
log_err("From source: ");
- for(i=0; i<(src-source); i++)
+ for(i=0; i<(src-(const char *)source); i++)
log_err(" 0x%02x,", (unsigned char)source[i]);
log_err("\n");
}
@@ -3278,3 +3331,24 @@ UBool testConvertToUnicodeWithContext( const uint8_t *source, int sourcelen, con
return FALSE;
}
}
+
+static void TestCallBackFailure(void) {
+ UErrorCode status = U_USELESS_COLLATOR_ERROR;
+ ucnv_cbFromUWriteBytes(NULL, NULL, -1, -1, &status);
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("Error: ucnv_cbFromUWriteBytes did not react correctly to a bad UErrorCode\n");
+ }
+ ucnv_cbFromUWriteUChars(NULL, NULL, NULL, -1, &status);
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("Error: ucnv_cbFromUWriteUChars did not react correctly to a bad UErrorCode\n");
+ }
+ ucnv_cbFromUWriteSub(NULL, -1, &status);
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("Error: ucnv_cbFromUWriteSub did not react correctly to a bad UErrorCode\n");
+ }
+ ucnv_cbToUWriteUChars(NULL, NULL, -1, -1, &status);
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("Error: ucnv_cbToUWriteUChars did not react correctly to a bad UErrorCode\n");
+ }
+}
+
diff --git a/Build/source/libs/icu-xetex/test/cintltst/ncnvfbts.c b/Build/source/libs/icu-xetex/test/cintltst/ncnvfbts.c
index c05aa97744d..1a0f2b77ace 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/ncnvfbts.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/ncnvfbts.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
***************************************************************************/
/*******************************************************************************
@@ -23,6 +23,7 @@
#include "cmemory.h"
#include "cstring.h"
+#if !UCONFIG_NO_LEGACY_CONVERSION
#define NEW_MAX_BUFFER 999
@@ -130,25 +131,25 @@ static UBool testConvertFromUnicode(const UChar *source, int sourceLen, const u
UErrorCode status = U_ZERO_ERROR;
UConverter *conv = 0;
- uint8_t junkout[NEW_MAX_BUFFER]; /* FIX */
+ char junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
const UChar *src;
- uint8_t *end;
- uint8_t *targ;
+ char *end;
+ char *targ;
int32_t *offs;
int i;
int32_t realBufferSize;
- uint8_t *realBufferEnd;
+ char *realBufferEnd;
const UChar *realSourceEnd;
const UChar *sourceLimit;
UBool checkOffsets = TRUE;
UBool doFlush;
UBool action=FALSE;
- uint8_t *p;
+ char *p;
for(i=0;i<NEW_MAX_BUFFER;i++)
- junkout[i] = 0xF0;
+ junkout[i] = (char)0xF0;
for(i=0;i<NEW_MAX_BUFFER;i++)
junokout[i] = 0xFF;
setNuConvTestName(codepage, "FROM");
@@ -293,9 +294,9 @@ static UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const U
UConverter *conv = 0;
UChar junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
- const uint8_t *src;
- const uint8_t *realSourceEnd;
- const uint8_t *srcLimit;
+ const char *src;
+ const char *realSourceEnd;
+ const char *srcLimit;
UChar *targ;
UChar *end;
int32_t *offs;
@@ -329,7 +330,7 @@ static UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const U
log_verbose("Converter opened..\n");
- src = source;
+ src = (const char *)source;
targ = junkout;
offs = junokout;
@@ -424,7 +425,7 @@ static UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const U
for(i=0; i<(targ-junkout); i++)
log_err("0x%04X,", junkout[i]);
log_err("");
- for(i=0; i<(src-source); i++)
+ for(i=0; i<(src-(const char *)source); i++)
log_err("0x%04X,", (unsigned char)source[i]);
}
}
@@ -745,3 +746,10 @@ static void TestConvertFallBackWithBufferSizes(int32_t outsize, int32_t insize )
}
}
+#else
+void addTestConverterFallBack(TestNode** root)
+{
+ /* test nothing... */
+
+}
+#endif
diff --git a/Build/source/libs/icu-xetex/test/cintltst/ncnvtst.c b/Build/source/libs/icu-xetex/test/cintltst/ncnvtst.c
index 8df78de283f..1b26b145aef 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/ncnvtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/ncnvtst.c
@@ -1,16 +1,16 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
-/********************************************************************************
+/*******************************************************************************
*
* File CCONVTST.C
*
* Modification History:
* Name Description
* Madhu Katragadda 7/7/2000 Converter Tests for extended code coverage
-*********************************************************************************
+********************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
@@ -61,8 +61,12 @@ static void setNuConvTestName(const char *codepage, const char *direction)
static void TestSurrogateBehaviour(void);
static void TestErrorBehaviour(void);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestToUnicodeErrorBehaviour(void);
static void TestGetNextErrorBehaviour(void);
+#endif
+
static void TestRegressionUTF8(void);
static void TestRegressionUTF32(void);
static void TestAvailableConverters(void);
@@ -115,8 +119,12 @@ void addExtraTests(TestNode** root)
{
addTest(root, &TestSurrogateBehaviour, "tsconv/ncnvtst/TestSurrogateBehaviour");
addTest(root, &TestErrorBehaviour, "tsconv/ncnvtst/TestErrorBehaviour");
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestToUnicodeErrorBehaviour, "tsconv/ncnvtst/ToUnicodeErrorBehaviour");
addTest(root, &TestGetNextErrorBehaviour, "tsconv/ncnvtst/TestGetNextErrorBehaviour");
+#endif
+
addTest(root, &TestAvailableConverters, "tsconv/ncnvtst/TestAvailableConverters");
addTest(root, &TestFlushInternalBuffer, "tsconv/ncnvtst/TestFlushInternalBuffer");
addTest(root, &TestResetBehaviour, "tsconv/ncnvtst/TestResetBehaviour");
@@ -132,10 +140,13 @@ static void TestSurrogateBehaviour(){
{
UChar sampleText[] = {0x0031, 0xd801, 0xdc01, 0x0032};
const uint8_t expected[] = {0x31, 0x1a, 0x32};
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
/*SBCS*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "ibm-920", 0 , TRUE, U_ZERO_ERROR))
log_err("u-> ibm-920 [UCNV_SBCS] not match.\n");
+#endif
/*LATIN_1*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
@@ -143,6 +154,8 @@ static void TestSurrogateBehaviour(){
log_err("u-> LATIN_1 not match.\n");
}
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing for DBCS and MBCS\n");
{
UChar sampleText[] = {0x00a1, 0xd801, 0xdc01, 0x00a4};
@@ -164,6 +177,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "ibm-1363", offsets, TRUE, U_ZERO_ERROR))
log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
}
+
log_verbose("Testing for ISO-2022-jp\n");
{
UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -182,6 +196,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "iso-2022-jp", offsets , TRUE, U_ZERO_ERROR))
log_err("u-> not match.\n");
}
+
log_verbose("Testing for ISO-2022-cn\n");
{
static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -211,6 +226,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "iso-2022-cn", offsets , TRUE, U_ZERO_ERROR))
log_err("u-> not match.\n");
}
+
log_verbose("Testing for ISO-2022-kr\n");
{
static const UChar sampleText[] = { 0x4e00,0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -240,6 +256,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "iso-2022-kr", offsets , TRUE, U_ZERO_ERROR))
log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
}
+
log_verbose("Testing for HZ\n");
{
static const UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -262,11 +279,13 @@ static void TestSurrogateBehaviour(){
/*hz*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "HZ", 0 , TRUE, U_ZERO_ERROR))
- log_err("u-> not match.\n");
+ log_err("u-> HZ not match.\n");
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "HZ", offsets , TRUE, U_ZERO_ERROR))
- log_err("u-> not match.\n");
+ log_err("u-> HZ not match.\n");
}
+#endif
+
/*UTF-8*/
log_verbose("Testing for UTF8\n");
{
@@ -295,21 +314,18 @@ static void TestSurrogateBehaviour(){
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", 0, TRUE, U_ZERO_ERROR ))
- log_err("UTF8 -> did not match.\n");
+ log_err("UTF8 -> u did not match.\n");
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", 0, FALSE, U_ZERO_ERROR ))
- log_err("UTF8 -> did not match.\n");
+ log_err("UTF8 -> u did not match.\n");
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", fromOffsets, TRUE, U_ZERO_ERROR ))
- log_err("UTF8 -> did not match.\n");
+ log_err("UTF8 ->u did not match.\n");
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", fromOffsets, FALSE, U_ZERO_ERROR ))
- log_err("UTF8 -> did not match.\n");
+ log_err("UTF8 -> u did not match.\n");
}
-
-
-
}
/*test various error behaviours*/
@@ -322,6 +338,7 @@ static void TestErrorBehaviour(){
static const uint8_t expected[] = { 0x31, 0x1a};
static const uint8_t expected2[] = { 0x31, 0x1a, 0x32};
+#if !UCONFIG_NO_LEGACY_CONVERSION
/*SBCS*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "ibm-920", 0, TRUE, U_ZERO_ERROR))
@@ -332,7 +349,7 @@ static void TestErrorBehaviour(){
if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
expected2, sizeof(expected2), "ibm-920", 0, TRUE, U_ZERO_ERROR))
log_err("u-> ibm-920 [UCNV_SBCS] did not match\n");
-
+#endif
/*LATIN_1*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
@@ -347,7 +364,7 @@ static void TestErrorBehaviour(){
log_err("u-> LATIN_1 did not match\n");
}
-
+#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing for DBCS and MBCS\n");
{
static const UChar sampleText[] = { 0x00a1, 0xd801};
@@ -368,10 +385,6 @@ static void TestErrorBehaviour(){
static const uint8_t expected4MBCS[] = { 0x61, 0x8f, 0xa2, 0xc3, 0xf4, 0xfe};
static const int32_t offsets4MBCS[] = { 0x00, 0x01, 0x01, 0x01, 0x02, 0x02 };
-
-
-
-
/*DBCS*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedSUB, sizeof(expectedSUB), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
@@ -427,6 +440,7 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "euc-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> euc-jp [UCNV_MBCS] \n");
}
+
/*iso-2022-jp*/
log_verbose("Testing for iso-2022-jp\n");
{
@@ -466,6 +480,7 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "iso-2022-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
}
+
/*iso-2022-cn*/
log_verbose("Testing for iso-2022-cn\n");
{
@@ -516,6 +531,7 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "iso-2022-cn", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
}
+
/*iso-2022-kr*/
log_verbose("Testing for iso-2022-kr\n");
{
@@ -607,10 +623,10 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "HZ", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> HZ [UCNV_MBCS] \n");
}
-
-
+#endif
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
/*test different convertToUnicode error behaviours*/
static void TestToUnicodeErrorBehaviour()
{
@@ -662,6 +678,7 @@ static void TestGetNextErrorBehaviour(){
}
ucnv_close(cnv);
}
+#endif
#define MAX_UTF16_LEN 2
#define MAX_UTF8_LEN 4
@@ -697,8 +714,42 @@ static void TestRegressionUTF8(){
log_err("UTF8->Unicode did not match.\n");
}
}
+
free(standardForm);
free(utf8);
+
+ {
+ static const char src8[] = { (char)0xCC, (char)0x81, (char)0xCC, (char)0x80 };
+ static const UChar expected[] = { 0x0301, 0x0300 };
+ UConverter *conv8;
+ UErrorCode err = U_ZERO_ERROR;
+ UChar pivotBuffer[100];
+ const UChar* const pivEnd = pivotBuffer + 100;
+ const char* srcBeg;
+ const char* srcEnd;
+ UChar* pivBeg;
+
+ conv8 = ucnv_open("UTF-8", &err);
+
+ srcBeg = src8;
+ pivBeg = pivotBuffer;
+ srcEnd = src8 + 3;
+ ucnv_toUnicode(conv8, &pivBeg, pivEnd, &srcBeg, srcEnd, 0, FALSE, &err);
+ if (srcBeg != srcEnd) {
+ log_err("Did not consume whole buffer on first call.\n");
+ }
+
+ srcEnd = src8 + 4;
+ ucnv_toUnicode(conv8, &pivBeg, pivEnd, &srcBeg, srcEnd, 0, TRUE, &err);
+ if (srcBeg != srcEnd) {
+ log_err("Did not consume whole buffer on second call.\n");
+ }
+
+ if (U_FAILURE(err) || (int32_t)(pivBeg - pivotBuffer) != 2 || u_strncmp(pivotBuffer, expected, 2) != 0) {
+ log_err("Did not get expected results for UTF-8.\n");
+ }
+ ucnv_close(conv8);
+ }
}
#define MAX_UTF32_LEN 1
@@ -735,6 +786,106 @@ static void TestRegressionUTF32(){
}
free(standardForm);
free(utf32);
+
+ {
+ /* Check for lone surrogate error handling. */
+ static const UChar sampleBadStartSurrogate[] = { 0x0031, 0xD800, 0x0032 };
+ static const UChar sampleBadEndSurrogate[] = { 0x0031, 0xDC00, 0x0032 };
+ static const uint8_t expectedUTF32BE[] = {
+ 0x00, 0x00, 0x00, 0x31,
+ 0x00, 0x00, 0xff, 0xfd,
+ 0x00, 0x00, 0x00, 0x32
+ };
+ static const uint8_t expectedUTF32LE[] = {
+ 0x31, 0x00, 0x00, 0x00,
+ 0xfd, 0xff, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x00
+ };
+ static const int32_t offsetsUTF32[] = {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x01, 0x01, 0x01,
+ 0x02, 0x02, 0x02, 0x02
+ };
+
+ if(!convertFromU(sampleBadStartSurrogate, sizeof(sampleBadStartSurrogate)/sizeof(sampleBadStartSurrogate[0]),
+ expectedUTF32BE, sizeof(expectedUTF32BE), "UTF-32BE", offsetsUTF32, TRUE, U_ZERO_ERROR))
+ log_err("u->UTF-32BE\n");
+ if(!convertFromU(sampleBadEndSurrogate, sizeof(sampleBadEndSurrogate)/sizeof(sampleBadEndSurrogate[0]),
+ expectedUTF32BE, sizeof(expectedUTF32BE), "UTF-32BE", offsetsUTF32, TRUE, U_ZERO_ERROR))
+ log_err("u->UTF-32BE\n");
+
+ if(!convertFromU(sampleBadStartSurrogate, sizeof(sampleBadStartSurrogate)/sizeof(sampleBadStartSurrogate[0]),
+ expectedUTF32LE, sizeof(expectedUTF32LE), "UTF-32LE", offsetsUTF32, TRUE, U_ZERO_ERROR))
+ log_err("u->UTF-32LE\n");
+ if(!convertFromU(sampleBadEndSurrogate, sizeof(sampleBadEndSurrogate)/sizeof(sampleBadEndSurrogate[0]),
+ expectedUTF32LE, sizeof(expectedUTF32LE), "UTF-32LE", offsetsUTF32, TRUE, U_ZERO_ERROR))
+ log_err("u->UTF-32LE\n");
+ }
+
+ {
+ static const char srcBE[] = { 0, 0, 0, 0x31, 0, 0, 0, 0x30 };
+ static const UChar expected[] = { 0x0031, 0x0030 };
+ UConverter *convBE;
+ UErrorCode err = U_ZERO_ERROR;
+ UChar pivotBuffer[100];
+ const UChar* const pivEnd = pivotBuffer + 100;
+ const char* srcBeg;
+ const char* srcEnd;
+ UChar* pivBeg;
+
+ convBE = ucnv_open("UTF-32BE", &err);
+
+ srcBeg = srcBE;
+ pivBeg = pivotBuffer;
+ srcEnd = srcBE + 5;
+ ucnv_toUnicode(convBE, &pivBeg, pivEnd, &srcBeg, srcEnd, 0, FALSE, &err);
+ if (srcBeg != srcEnd) {
+ log_err("Did not consume whole buffer on first call.\n");
+ }
+
+ srcEnd = srcBE + 8;
+ ucnv_toUnicode(convBE, &pivBeg, pivEnd, &srcBeg, srcEnd, 0, TRUE, &err);
+ if (srcBeg != srcEnd) {
+ log_err("Did not consume whole buffer on second call.\n");
+ }
+
+ if (U_FAILURE(err) || (int32_t)(pivBeg - pivotBuffer) != 2 || u_strncmp(pivotBuffer, expected, 2) != 0) {
+ log_err("Did not get expected results for UTF-32BE.\n");
+ }
+ ucnv_close(convBE);
+ }
+ {
+ static const char srcLE[] = { 0x31, 0, 0, 0, 0x30, 0, 0, 0 };
+ static const UChar expected[] = { 0x0031, 0x0030 };
+ UConverter *convLE;
+ UErrorCode err = U_ZERO_ERROR;
+ UChar pivotBuffer[100];
+ const UChar* const pivEnd = pivotBuffer + 100;
+ const char* srcBeg;
+ const char* srcEnd;
+ UChar* pivBeg;
+
+ convLE = ucnv_open("UTF-32LE", &err);
+
+ srcBeg = srcLE;
+ pivBeg = pivotBuffer;
+ srcEnd = srcLE + 5;
+ ucnv_toUnicode(convLE, &pivBeg, pivEnd, &srcBeg, srcEnd, 0, FALSE, &err);
+ if (srcBeg != srcEnd) {
+ log_err("Did not consume whole buffer on first call.\n");
+ }
+
+ srcEnd = srcLE + 8;
+ ucnv_toUnicode(convLE, &pivBeg, pivEnd, &srcBeg, srcEnd, 0, TRUE, &err);
+ if (srcBeg != srcEnd) {
+ log_err("Did not consume whole buffer on second call.\n");
+ }
+
+ if (U_FAILURE(err) || (int32_t)(pivBeg - pivotBuffer) != 2 || u_strncmp(pivotBuffer, expected, 2) != 0) {
+ log_err("Did not get expected results for UTF-32LE.\n");
+ }
+ ucnv_close(convLE);
+ }
}
/*Walk through the available converters*/
@@ -784,6 +935,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
log_err("u-> UTF8 did not match.\n");
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_ESCAPE \n");
{
UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 };
@@ -799,6 +951,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
(UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, offset,FALSE))
log_err("u-> ibm-943 with subst with value did not match.\n");
}
+#endif
log_verbose("Testing fromUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
{
@@ -812,7 +965,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
log_err("utf8->u with substitute did not match.\n");;
}
-
+#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_ESCAPE \n");
/*to Unicode*/
{
@@ -830,7 +983,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
log_err("ibm-943->u with substitute with value did not match.\n");
}
-
+#endif
}
static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
@@ -838,13 +991,13 @@ static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *e
{
int32_t i=0;
- uint8_t *p=0;
+ char *p=0;
const UChar *src;
- uint8_t buffer[MAX_LENGTH];
+ char buffer[MAX_LENGTH];
int32_t offsetBuffer[MAX_LENGTH];
int32_t *offs=0;
- uint8_t *targ;
- uint8_t *targetLimit;
+ char *targ;
+ char *targetLimit;
UChar *sourceLimit=0;
UErrorCode status = U_ZERO_ERROR;
UConverter *conv = 0;
@@ -857,7 +1010,7 @@ static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *e
log_verbose("Converter %s opened..\n", ucnv_getName(conv, &status));
for(i=0; i<MAX_LENGTH; i++){
- buffer[i]=0xF0;
+ buffer[i]=(char)0xF0;
offsetBuffer[i]=0xFF;
}
@@ -929,7 +1082,7 @@ static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expe
UConverter *conv = 0;
int32_t i=0;
UChar *p=0;
- const uint8_t* src;
+ const char* src;
UChar buffer[MAX_LENGTH];
int32_t offsetBuffer[MAX_LENGTH];
int32_t *offs=0;
@@ -954,7 +1107,7 @@ static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expe
offsetBuffer[i]=-1;
}
- src=source;
+ src=(const char *)source;
sourceLimit=(uint8_t*)(src+(sourceLen));
targ=buffer;
targetLimit=targ+MAX_LENGTH;
@@ -998,7 +1151,7 @@ static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expe
for(i=0; i<(targ-buffer); i++)
log_info("0x%04X,", buffer[i]);
log_info("\nFrom Input:");
- for(i=0; i<(src-source); i++)
+ for(i=0; i<(src-(const char *)source); i++)
log_info("0x%02X,", (unsigned char)source[i]);
log_info("\n");
}
@@ -1024,16 +1177,16 @@ static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_
{
UErrorCode status = U_ZERO_ERROR;
UConverter *conv = 0;
- uint8_t junkout[MAX_LENGTH]; /* FIX */
+ char junkout[MAX_LENGTH]; /* FIX */
int32_t junokout[MAX_LENGTH]; /* FIX */
- uint8_t *p;
+ char *p;
const UChar *src;
- uint8_t *end;
- uint8_t *targ;
+ char *end;
+ char *targ;
int32_t *offs;
int i;
int32_t realBufferSize;
- uint8_t *realBufferEnd;
+ char *realBufferEnd;
const UChar *realSourceEnd;
const UChar *sourceLimit;
UBool checkOffsets = TRUE;
@@ -1043,7 +1196,7 @@ static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_
const void* oldContext = NULL;
for(i=0;i<MAX_LENGTH;i++)
- junkout[i] = 0xF0;
+ junkout[i] = (char)0xF0;
for(i=0;i<MAX_LENGTH;i++)
junokout[i] = 0xFF;
@@ -1081,7 +1234,7 @@ static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_
checkOffsets = FALSE;
do
- {
+ {
end = nct_min(targ + gOutBufferSize, realBufferEnd);
sourceLimit = nct_min(src + gInBufferSize, realSourceEnd);
@@ -1124,7 +1277,7 @@ static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_
{
char junk[999];
char offset_str[999];
- uint8_t *ptr;
+ char *ptr;
junk[0] = 0;
offset_str[0] = 0;
@@ -1198,9 +1351,9 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *
UConverter *conv = 0;
UChar junkout[MAX_LENGTH]; /* FIX */
int32_t junokout[MAX_LENGTH]; /* FIX */
- const uint8_t *src;
- const uint8_t *realSourceEnd;
- const uint8_t *srcLimit;
+ const char *src;
+ const char *realSourceEnd;
+ const char *srcLimit;
UChar *p;
UChar *targ;
UChar *end;
@@ -1240,7 +1393,7 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *
}
/*-------------------------------------*/
- src = source;
+ src = (const char *)source;
targ = junkout;
offs = junokout;
@@ -1338,7 +1491,7 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *
for(i=0; i<(targ-junkout); i++)
log_err("%X,", junkout[i]);
log_err("");
- for(i=0; i<(src-source); i++)
+ for(i=0; i<(src-(const char *)source); i++)
log_err("%X,", (unsigned char)source[i]);
}
}
@@ -1362,6 +1515,7 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *
static void TestResetBehaviour(void){
+#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing Reset for DBCS and MBCS\n");
{
static const UChar sampleText[] = {0x00a1, 0xd801, 0xdc01, 0x00a4};
@@ -1399,6 +1553,7 @@ static void TestResetBehaviour(void){
log_err("ibm-1363 -> did not match.\n");
}
+
log_verbose("Testing Reset for ISO-2022-jp\n");
{
static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -1429,6 +1584,7 @@ static void TestResetBehaviour(void){
log_err("iso-2022-jp -> did not match.\n");
}
+
log_verbose("Testing Reset for ISO-2022-cn\n");
{
static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -1472,6 +1628,7 @@ static void TestResetBehaviour(void){
offsets1, TRUE))
log_err("iso-2022-cn -> did not match.\n");
}
+
log_verbose("Testing Reset for ISO-2022-kr\n");
{
UChar sampleText[] = { 0x4e00,0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -1519,6 +1676,7 @@ static void TestResetBehaviour(void){
offsets1, TRUE))
log_err("iso-2022-kr -> did not match.\n");
}
+
log_verbose("Testing Reset for HZ\n");
{
static const UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@@ -1562,6 +1720,8 @@ static void TestResetBehaviour(void){
offsets1, TRUE))
log_err("hz -> did not match.\n");
}
+#endif
+
/*UTF-8*/
log_verbose("Testing for UTF8\n");
{
@@ -1692,13 +1852,17 @@ TestTruncated() {
{ "UTF-32", { 0, 0, 0x4e }, 3 },
{ "UTF-32", { 0xff }, 1 },
{ "UTF-32", { 0, 0, 0xfe, 0xff, 0 }, 5 },
-
{ "SCSU", { 0x0e, 0x4e }, 2 }, /* SQU 0x4e */
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
{ "BOCU-1", { 0xd5 }, 1 },
{ "Shift-JIS", { 0xe0 }, 1 },
{ "ibm-939", { 0x0e, 0x41 }, 2 } /* SO 0x41 */
+#else
+ { "BOCU-1", { 0xd5 }, 1 ,}
+#endif
};
int32_t i;
@@ -1732,11 +1896,14 @@ TestUnicodeSet() {
"SCSU",
"BOCU-1",
"CESU-8",
+#if !UCONFIG_NO_LEGACY_CONVERSION
"gb18030",
+#endif
"IMAP-mailbox-name"
};
static const char *const lmbcsNames[]={
+#if !UCONFIG_NO_LEGACY_CONVERSION
"LMBCS-1",
"LMBCS-2",
"LMBCS-3",
@@ -1749,16 +1916,23 @@ TestUnicodeSet() {
"LMBCS-17",
"LMBCS-18",
"LMBCS-19"
+#endif
};
static const NameRange nameRanges[]={
{ "US-ASCII", 0, 0x7f, -1, -1, 0x80, 0x10ffff },
+#if !UCONFIG_NO_LEGACY_CONVERSION
{ "ibm-367", 0, 0x7f, -1, -1, 0x80, 0x10ffff },
+#endif
{ "ISO-8859-1", 0, 0x7f, -1, -1, 0x100, 0x10ffff },
+#if !UCONFIG_NO_LEGACY_CONVERSION
{ "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff },
{ "windows-1251", 0, 0x7f, 0x410, 0x44f, 0x3000, 0xd7ff },
{ "HZ", 0x410, 0x44f, 0x4e00, 0x4eff, 0xac00, 0xd7ff },
{ "shift-jis", 0x3041, 0x3093, 0x30a1, 0x30f3, 0x900, 0x1cff }
+#else
+ { "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff }
+#endif
};
/* open an empty set */
diff --git a/Build/source/libs/icu-xetex/test/cintltst/nfsprep.c b/Build/source/libs/icu-xetex/test/cintltst/nfsprep.c
index fc7e2482daa..fc046820893 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/nfsprep.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/nfsprep.c
@@ -1,7 +1,7 @@
/*
*******************************************************************************
*
- * Copyright (C) 2003, International Business Machines
+ * Copyright (C) 2003-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@@ -132,46 +132,6 @@ CLEANUP:
return u_terminateChars(dest, destCapacity, reqLength, status);
}
-static void
-syntaxError( const UChar* rules,
- int32_t pos,
- int32_t rulesLen,
- UParseError* parseError){
- int32_t start, stop;
- if(parseError == NULL){
- return;
- }
- if(pos == rulesLen && rulesLen >0){
- pos--;
- }
- parseError->offset = pos;
- parseError->line = 0 ; /* we are not using line numbers */
-
- /* for pre-context */
- start = (pos <=U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1));
- stop = pos;
-
- u_memcpy(parseError->preContext,rules+start,stop-start);
- /* null terminate the buffer */
- parseError->preContext[stop-start] = 0;
-
- /* for post-context */
- start = pos;
- if(start<rulesLen) {
- U16_FWD_1(rules, start, rulesLen);
- }
-
- stop = ((pos+U_PARSE_CONTEXT_LEN)<= rulesLen )? (pos+(U_PARSE_CONTEXT_LEN)) :
- rulesLen;
- if(start < stop){
- u_memcpy(parseError->postContext,rules+start,stop-start);
- /* null terminate the buffer */
- parseError->postContext[stop-start]= 0;
- }
-
-}
-
-
/* sorted array for binary search*/
static const char* special_prefixes[]={
"\x0041\x004e\x004f\x004e\x0059\x004d\x004f\x0055\x0053",
diff --git a/Build/source/libs/icu-xetex/test/cintltst/nucnvtst.c b/Build/source/libs/icu-xetex/test/cintltst/nucnvtst.c
index 101d66d4930..baecb4586d9 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/nucnvtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/nucnvtst.c
@@ -1,16 +1,16 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
-/********************************************************************************
+/*******************************************************************************
*
* File CCONVTST.C
*
* Modification History:
* Name Description
* Steven R. Loomis 7/8/1999 Adding input buffer test
-*********************************************************************************
+********************************************************************************
*/
#include <stdio.h>
#include "cstring.h"
@@ -44,12 +44,16 @@ static void TestUTF32(void);
static void TestUTF32BE(void);
static void TestUTF32LE(void);
static void TestLATIN1(void);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestSBCS(void);
static void TestDBCS(void);
static void TestMBCS(void);
+
#ifdef U_ENABLE_GENERIC_ISO_2022
static void TestISO_2022(void);
#endif
+
static void TestISO_2022_JP(void);
static void TestISO_2022_JP_1(void);
static void TestISO_2022_JP_2(void);
@@ -59,7 +63,11 @@ static void TestISO_2022_CN(void);
static void TestISO_2022_CN_EXT(void);
static void TestJIS(void);
static void TestHZ(void);
+#endif
+
static void TestSCSU(void);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestEBCDIC_STATEFUL(void);
static void TestGB18030(void);
static void TestLMBCS(void);
@@ -67,16 +75,19 @@ static void TestJitterbug255(void);
static void TestEBCDICUS4XML(void);
static void TestJitterbug915(void);
static void TestISCII(void);
+
+static void TestCoverageMBCS(void);
+static void TestJitterbug2346(void);
+static void TestJitterbug2411(void);
+#endif
+
+static void TestRoundTrippingAllUTF(void);
static void TestConv(const uint16_t in[],
int len,
const char* conv,
const char* lang,
char byteArr[],
int byteArrLen);
-static void TestRoundTrippingAllUTF(void);
-static void TestCoverageMBCS(void);
-static void TestJitterbug2346(void);
-static void TestJitterbug2411(void);
void addTestNewConvert(TestNode** root);
/* open a converter, using test data if it begins with '@' */
@@ -229,15 +240,22 @@ void addTestNewConvert(TestNode** root)
addTest(root, &TestUTF32, "tsconv/nucnvtst/TestUTF32");
addTest(root, &TestUTF32BE, "tsconv/nucnvtst/TestUTF32BE");
addTest(root, &TestUTF32LE, "tsconv/nucnvtst/TestUTF32LE");
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestLMBCS, "tsconv/nucnvtst/TestLMBCS");
+#endif
addTest(root, &TestLATIN1, "tsconv/nucnvtst/TestLATIN1");
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestSBCS, "tsconv/nucnvtst/TestSBCS");
addTest(root, &TestDBCS, "tsconv/nucnvtst/TestDBCS");
addTest(root, &TestMBCS, "tsconv/nucnvtst/TestMBCS");
+
#ifdef U_ENABLE_GENERIC_ISO_2022
addTest(root, &TestISO_2022, "tsconv/nucnvtst/TestISO_2022");
#endif
+
addTest(root, &TestISO_2022_JP, "tsconv/nucnvtst/TestISO_2022_JP");
addTest(root, &TestJIS, "tsconv/nucnvtst/TestJIS");
addTest(root, &TestISO_2022_JP_1, "tsconv/nucnvtst/TestISO_2022_JP_1");
@@ -248,20 +266,35 @@ void addTestNewConvert(TestNode** root)
addTest(root, &TestISO_2022_CN_EXT, "tsconv/nucnvtst/TestISO_2022_CN_EXT");
addTest(root, &TestJitterbug915, "tsconv/nucnvtst/TestJitterbug915");
addTest(root, &TestHZ, "tsconv/nucnvtst/TestHZ");
+#endif
+
addTest(root, &TestSCSU, "tsconv/nucnvtst/TestSCSU");
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestEBCDIC_STATEFUL, "tsconv/nucnvtst/TestEBCDIC_STATEFUL");
addTest(root, &TestGB18030, "tsconv/nucnvtst/TestGB18030");
addTest(root, &TestJitterbug255, "tsconv/nucnvtst/TestJitterbug255");
addTest(root, &TestEBCDICUS4XML, "tsconv/nucnvtst/TestEBCDICUS4XML");
addTest(root, &TestISCII, "tsconv/nucnvtst/TestISCII");
+
#if !UCONFIG_NO_COLLATION
addTest(root, &TestJitterbug981, "tsconv/nucnvtst/TestJitterbug981");
#endif
+
addTest(root, &TestJitterbug1293, "tsconv/nucnvtst/TestJitterbug1293");
+#endif
+
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestCoverageMBCS, "tsconv/nucnvtst/TestCoverageMBCS");
+#endif
+
addTest(root, &TestRoundTrippingAllUTF, "tsconv/nucnvtst/TestRoundTrippingAllUTF");
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestJitterbug2346, "tsconv/nucnvtst/TestJitterbug2346");
addTest(root, &TestJitterbug2411, "tsconv/nucnvtst/TestJitterbug2411");
+#endif
}
@@ -294,23 +327,23 @@ static ETestConvertResult testConvertFromU( const UChar *source, int sourceLen,
{
UErrorCode status = U_ZERO_ERROR;
UConverter *conv = 0;
- uint8_t junkout[NEW_MAX_BUFFER]; /* FIX */
+ char junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
- uint8_t *p;
+ char *p;
const UChar *src;
- uint8_t *end;
- uint8_t *targ;
+ char *end;
+ char *targ;
int32_t *offs;
int i;
int32_t realBufferSize;
- uint8_t *realBufferEnd;
+ char *realBufferEnd;
const UChar *realSourceEnd;
const UChar *sourceLimit;
UBool checkOffsets = TRUE;
UBool doFlush;
for(i=0;i<NEW_MAX_BUFFER;i++)
- junkout[i] = 0xF0;
+ junkout[i] = (char)0xF0;
for(i=0;i<NEW_MAX_BUFFER;i++)
junokout[i] = 0xFF;
@@ -359,8 +392,8 @@ static ETestConvertResult testConvertFromU( const UChar *source, int sourceLen,
status = U_ZERO_ERROR;
ucnv_fromUnicode (conv,
- (char **)&targ,
- (const char*)end,
+ &targ,
+ end,
&src,
sourceLimit,
checkOffsets ? offs : NULL,
@@ -380,7 +413,7 @@ static ETestConvertResult testConvertFromU( const UChar *source, int sourceLen,
{
char junk[9999];
char offset_str[9999];
- uint8_t *ptr;
+ char *ptr;
junk[0] = 0;
offset_str[0] = 0;
@@ -453,9 +486,9 @@ static ETestConvertResult testConvertToU( const uint8_t *source, int sourcelen,
UConverter *conv = 0;
UChar junkout[NEW_MAX_BUFFER]; /* FIX */
int32_t junokout[NEW_MAX_BUFFER]; /* FIX */
- const uint8_t *src;
- const uint8_t *realSourceEnd;
- const uint8_t *srcLimit;
+ const char *src;
+ const char *realSourceEnd;
+ const char *srcLimit;
UChar *p;
UChar *targ;
UChar *end;
@@ -489,7 +522,7 @@ static ETestConvertResult testConvertToU( const uint8_t *source, int sourcelen,
}
log_verbose("Converter opened..\n");
- src = source;
+ src = (const char *)source;
targ = junkout;
offs = junokout;
@@ -519,8 +552,8 @@ static ETestConvertResult testConvertToU( const uint8_t *source, int sourcelen,
ucnv_toUnicode (conv,
&targ,
end,
- (const char **)&src,
- (const char *)srcLimit,
+ &src,
+ srcLimit,
checkOffsets ? offs : NULL,
(UBool)(srcLimit == realSourceEnd), /* flush if we're at the end of hte source data */
&status);
@@ -585,7 +618,7 @@ static ETestConvertResult testConvertToU( const uint8_t *source, int sourcelen,
}
log_err("\n");
log_err("input: ");
- for(i=0; i<(src-source); i++) {
+ for(i=0; i<(src-(const char *)source); i++) {
log_err("%X,", (unsigned char)source[i]);
}
log_err("\n");
@@ -775,11 +808,13 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
}
-#ifdef U_ENABLE_GENERIC_ISO_2022
+
+#if !UCONFIG_NO_LEGACY_CONVERSION && defined(U_ENABLE_GENERIC_ISO_2022)
/*ISO-2022*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedISO2022, sizeof(expectedISO2022), "ISO_2022", toISO2022Offs,FALSE );
#endif
+
/*UTF16 LE*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedUTF16LE, sizeof(expectedUTF16LE), "utf-16le", toUTF16LEOffs,FALSE );
@@ -792,9 +827,12 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*UTF32 BE*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedUTF32BE, sizeof(expectedUTF32BE), "utf-32be", toUTF32BEOffs,FALSE );
+
/*LATIN_1*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedLATIN1, sizeof(expectedLATIN1), "LATIN_1", toLATIN1Offs,FALSE );
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
/*EBCDIC_STATEFUL*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedIBM930, sizeof(expectedIBM930), "ibm-930", toIBM930Offs,FALSE );
@@ -815,6 +853,7 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*SBCS*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedISO88593, sizeof(expectedISO88593), "iso-8859-3", toISO88593Offs,FALSE );
+#endif
/****/
@@ -822,11 +861,12 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*UTF-8*/
testConvertToU(expectedUTF8, sizeof(expectedUTF8),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf8", fmUTF8Offs,FALSE);
-#ifdef U_ENABLE_GENERIC_ISO_2022
+#if !UCONFIG_NO_LEGACY_CONVERSION && defined(U_ENABLE_GENERIC_ISO_2022)
/*ISO-2022*/
testConvertToU(expectedISO2022, sizeof(expectedISO2022),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "ISO_2022", fmISO2022Offs,FALSE);
#endif
+
/*UTF16 LE*/
testConvertToU(expectedUTF16LE, sizeof(expectedUTF16LE),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf-16le", fmUTF16LEOffs,FALSE);
@@ -839,17 +879,21 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*UTF32 BE*/
testConvertToU(expectedUTF32BE, sizeof(expectedUTF32BE),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf-32be", fmUTF32BEOffs,FALSE);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
/*EBCDIC_STATEFUL*/
testConvertToU(expectedIBM930, sizeof(expectedIBM930),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "ibm-930", fmIBM930Offs,FALSE);
/*MBCS*/
testConvertToU(expectedIBM943, sizeof(expectedIBM943),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "ibm-943", fmIBM943Offs,FALSE);
+#endif
/* Try it again to make sure it still works */
testConvertToU(expectedUTF16LE, sizeof(expectedUTF16LE),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf-16le", fmUTF16LEOffs,FALSE);
+#if !UCONFIG_NO_LEGACY_CONVERSION
testConvertToU(expectedMaltese913, sizeof(expectedMaltese913),
malteseUChars, sizeof(malteseUChars)/sizeof(malteseUChars[0]), "latin3", NULL,FALSE);
@@ -861,6 +905,7 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
expectedLMBCS, sizeof(expectedLMBCS), "LMBCS-1", toLMBCSOffs,FALSE );
testConvertToU(expectedLMBCS, sizeof(expectedLMBCS),
LMBCSUChars, sizeof(LMBCSUChars)/sizeof(LMBCSUChars[0]), "LMBCS-1", fmLMBCSOffs,FALSE);
+#endif
/* UTF-7 examples are mostly from http://www.imc.org/rfc2152 */
{
@@ -1274,6 +1319,7 @@ static void TestConverterType(const char *convName, UConverterType convType) {
static void TestConverterTypesAndStarters()
{
+#if !UCONFIG_NO_LEGACY_CONVERSION
UConverter* myConverter;
UErrorCode err = U_ZERO_ERROR;
UBool mystarters[256];
@@ -1334,19 +1380,33 @@ static void TestConverterTypesAndStarters()
TestConverterType("ibm-930", UCNV_EBCDIC_STATEFUL);
TestConverterType("ibm-878", UCNV_SBCS);
+#endif
+
TestConverterType("iso-8859-1", UCNV_LATIN_1);
+
TestConverterType("ibm-1208", UCNV_UTF8);
+
TestConverterType("utf-8", UCNV_UTF8);
TestConverterType("UTF-16BE", UCNV_UTF16_BigEndian);
TestConverterType("UTF-16LE", UCNV_UTF16_LittleEndian);
TestConverterType("UTF-32BE", UCNV_UTF32_BigEndian);
TestConverterType("UTF-32LE", UCNV_UTF32_LittleEndian);
-#ifdef U_ENABLE_GENERIC_ISO_2022
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
+
+#if defined(U_ENABLE_GENERIC_ISO_2022)
TestConverterType("iso-2022", UCNV_ISO_2022);
#endif
+
TestConverterType("hz", UCNV_HZ);
+#endif
+
TestConverterType("scsu", UCNV_SCSU);
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
TestConverterType("x-iscii-de", UCNV_ISCII);
+#endif
+
TestConverterType("ascii", UCNV_US_ASCII);
TestConverterType("utf-7", UCNV_UTF7);
TestConverterType("IMAP-mailbox-name", UCNV_IMAP_MAILBOX);
@@ -1428,6 +1488,7 @@ static void TestAmbiguous()
}
}
+#if !UCONFIG_NO_LEGACY_CONVERSION
sjis_cnv = ucnv_open("ibm-943", &status);
if (U_FAILURE(status))
{
@@ -1480,6 +1541,7 @@ static void TestAmbiguous()
}
ucnv_close(sjis_cnv);
ucnv_close(ascii_cnv);
+#endif
}
static void
@@ -2947,8 +3009,8 @@ TestHZ() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 5);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -2967,7 +3029,7 @@ TestHZ() {
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
@@ -2977,9 +3039,9 @@ TestHZ() {
test++;
}
TestGetNextUChar2022(cnv, cBuf, cTarget, in, "HZ encoding");
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestToAndFromUChars(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestToAndFromUChars(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
TestJitterbug930("csISO2022JP");
ucnv_close(cnv);
free(offsets);
@@ -3166,8 +3228,8 @@ TestISO_2022_JP() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 5);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -3187,7 +3249,7 @@ TestISO_2022_JP() {
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
@@ -3197,10 +3259,10 @@ TestISO_2022_JP() {
test++;
}
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
TestGetNextUChar2022(cnv, cBuf, cTarget, in, "ISO-2022-JP encoding");
- TestToAndFromUChars(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestToAndFromUChars(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
TestJitterbug930("csISO2022JP");
ucnv_close(cnv);
free(uBuf);
@@ -3232,7 +3294,7 @@ static void TestConv(const uint16_t in[],int len, const char* conv, const char*
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar));
cBuf =(char*)malloc(uBufSize * sizeof(char));
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
uSourceLimit=uSource+len;
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize;
@@ -3254,7 +3316,7 @@ static void TestConv(const uint16_t in[],int len, const char* conv, const char*
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("for codepage %s : Expected : \\u%04X \t Got: \\u%04X\n",conv,*uSource,(int)*test) ;
@@ -3262,12 +3324,12 @@ static void TestConv(const uint16_t in[],int len, const char* conv, const char*
uSource++;
test++;
}
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[len],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[len],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)&in[len],cnv);
+ TestSmallSourceBuffer(in,(const UChar*)&in[len],cnv);
TestGetNextUChar2022(cnv, cBuf, cTarget, in, conv);
if(byteArr && byteArrLen!=0){
TestGetNextUChar2022(cnv, byteArr, (byteArr+byteArrLen), in, lang);
- TestToAndFromUChars(&in[0],(const UChar*)&in[len],cnv);
+ TestToAndFromUChars(in,(const UChar*)&in[len],cnv);
{
cSource = byteArr;
cSourceLimit = cSource+byteArrLen;
@@ -3279,7 +3341,7 @@ static void TestConv(const uint16_t in[],int len, const char* conv, const char*
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("Expected : \\u%04X \t Got: \\u%04X\n",*uSource,(int)*test) ;
@@ -3607,6 +3669,8 @@ TestSCSU() {
TestConv(russianUTF16,(sizeof(russianUTF16)/2), "SCSU","russian",(char *)russianSCSU,sizeof(russianSCSU));
TestConv(monkeyIn,(sizeof(monkeyIn)/2),"SCSU","monkey",NULL,0);
}
+
+#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestJitterbug2346(){
char source[] = { 0x1b,0x24,0x42,0x3d,0x45,0x1b,0x28,0x4a,0x0d,0x0a,
0x1b,0x24,0x42,0x3d,0x45,0x1b,0x28,0x4a,0x0d,0x0a};
@@ -3654,6 +3718,7 @@ static void TestJitterbug2346(){
}
+
static void
TestISO_2022_JP_1() {
/* test input */
@@ -3694,8 +3759,8 @@ TestISO_2022_JP_1() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 5);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -3713,7 +3778,7 @@ TestISO_2022_JP_1() {
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
@@ -3730,8 +3795,8 @@ TestISO_2022_JP_1() {
static const uint8_t source2[]={0x0e,0x24,0x053};
TestNextUCharError(cnv, (const char*)source2, (const char*)source2+sizeof(source2), U_ZERO_ERROR, "an invalid character [ISO-2022-JP-1]");
}
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
ucnv_close(cnv);
free(uBuf);
free(cBuf);
@@ -3784,8 +3849,8 @@ TestISO_2022_JP_2() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 5);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -3804,7 +3869,7 @@ TestISO_2022_JP_2() {
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
@@ -3813,9 +3878,9 @@ TestISO_2022_JP_2() {
uSource++;
test++;
}
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestToAndFromUChars(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestToAndFromUChars(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
/*Test for the condition where there is an invalid character*/
ucnv_reset(cnv);
{
@@ -3861,8 +3926,8 @@ TestISO_2022_KR() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 5);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -3881,7 +3946,7 @@ TestISO_2022_KR() {
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("Expected : \\u%04X \t Got: \\u%04X\n",*uSource,*test) ;
@@ -3890,9 +3955,9 @@ TestISO_2022_KR() {
test++;
}
TestGetNextUChar2022(cnv, cBuf, cTarget, in, "ISO-2022-KR encoding");
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestToAndFromUChars(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestToAndFromUChars(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
TestJitterbug930("csISO2022KR");
/*Test for the condition where there is an invalid character*/
ucnv_reset(cnv);
@@ -3940,8 +4005,8 @@ TestISO_2022_KR_1() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 5);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -3960,7 +4025,7 @@ TestISO_2022_KR_1() {
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("Expected : \\u%04X \t Got: \\u%04X\n",*uSource,*test) ;
@@ -3970,10 +4035,10 @@ TestISO_2022_KR_1() {
}
ucnv_reset(cnv);
TestGetNextUChar2022(cnv, cBuf, cTarget, in, "ISO-2022-KR encoding");
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
ucnv_reset(cnv);
- TestToAndFromUChars(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestToAndFromUChars(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
/*Test for the condition where there is an invalid character*/
ucnv_reset(cnv);
{
@@ -4242,8 +4307,8 @@ TestISO_2022_CN_EXT() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 10);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -4262,7 +4327,7 @@ TestISO_2022_CN_EXT() {
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("Expected : \\u%04X \t Got: \\u%04X\n",*uSource,(int)*test) ;
@@ -4273,8 +4338,8 @@ TestISO_2022_CN_EXT() {
uSource++;
test++;
}
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
/*Test for the condition where there is an invalid character*/
ucnv_reset(cnv);
{
@@ -4340,8 +4405,8 @@ TestISO_2022_CN() {
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 10);
- uSource = (const UChar*)&in[0];
- uSourceLimit=(const UChar*)&in[sizeof(in)/2];
+ uSource = (const UChar*)in;
+ uSourceLimit=(const UChar*)in + (sizeof(in)/sizeof(in[0]));
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
@@ -4360,7 +4425,7 @@ TestISO_2022_CN() {
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
- uSource = (const UChar*)&in[0];
+ uSource = (const UChar*)in;
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("Expected : \\u%04X \t Got: \\u%04X\n",*uSource,(int)*test) ;
@@ -4372,9 +4437,9 @@ TestISO_2022_CN() {
test++;
}
TestGetNextUChar2022(cnv, cBuf, cTarget, in, "ISO-2022-CN encoding");
- TestSmallTargetBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestSmallSourceBuffer(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
- TestToAndFromUChars(&in[0],(const UChar*)&in[sizeof(in)/2],cnv);
+ TestSmallTargetBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestSmallSourceBuffer(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
+ TestToAndFromUChars(in,(const UChar*)in + (sizeof(in)/sizeof(in[0])),cnv);
TestJitterbug930("csISO2022CN");
/*Test for the condition where there is an invalid character*/
ucnv_reset(cnv);
@@ -4669,8 +4734,8 @@ TestLMBCS() {
{
UErrorCode errorCode=U_ZERO_ERROR;
- const uint8_t * pSource = pszLMBCS;
- const uint8_t * sourceLimit = pszLMBCS + sizeof(pszLMBCS);
+ const char * pSource = (const char *)pszLMBCS;
+ const char * sourceLimit = (const char *)pszLMBCS + sizeof(pszLMBCS);
UChar Out [sizeof(pszUnicode) + 1];
UChar * pOut = Out;
@@ -4696,8 +4761,8 @@ TestLMBCS() {
ucnv_toUnicode (cnv,
&pOut,
OutLimit,
- (const char **)&pSource,
- (const char *)sourceLimit,
+ &pSource,
+ sourceLimit,
off,
TRUE,
&errorCode);
@@ -4759,12 +4824,12 @@ TestLMBCS() {
const UChar * pUniOut = uniString;
UChar * pUniIn = uniString;
uint8_t lmbcsString [4];
- const uint8_t * pLMBCSOut = lmbcsString;
- uint8_t * pLMBCSIn = lmbcsString;
+ const char * pLMBCSOut = (const char *)lmbcsString;
+ char * pLMBCSIn = (char *)lmbcsString;
/* 0192 (hook) converts to both group 3 & group 1. input locale should differentiate */
ucnv_fromUnicode (cnv16he,
- (char **)&pLMBCSIn, (const char *)(pLMBCSIn + sizeof(lmbcsString)/sizeof(lmbcsString[0])),
+ &pLMBCSIn, (pLMBCSIn + sizeof(lmbcsString)/sizeof(lmbcsString[0])),
&pUniOut, pUniOut + sizeof(uniString)/sizeof(uniString[0]),
NULL, 1, &errorCode);
@@ -4773,10 +4838,10 @@ TestLMBCS() {
log_err("LMBCS-16,locale=he gives unexpected translation\n");
}
- pLMBCSIn=lmbcsString;
+ pLMBCSIn= (char *)lmbcsString;
pUniOut = uniString;
ucnv_fromUnicode (cnv01us,
- (char **)&pLMBCSIn, (const char *)(lmbcsString + sizeof(lmbcsString)/sizeof(lmbcsString[0])),
+ &pLMBCSIn, (const char *)(lmbcsString + sizeof(lmbcsString)/sizeof(lmbcsString[0])),
&pUniOut, pUniOut + sizeof(uniString)/sizeof(uniString[0]),
NULL, 1, &errorCode);
@@ -4787,45 +4852,45 @@ TestLMBCS() {
/* single byte char from mbcs char set */
lmbcsString[0] = 0xAE; /* 1/2 width katakana letter small Yo */
- pLMBCSOut = lmbcsString;
+ pLMBCSOut = (const char *)lmbcsString;
pUniIn = uniString;
ucnv_toUnicode (cnv16jp,
&pUniIn, pUniIn + 1,
- (const char **)&pLMBCSOut, (const char *)(pLMBCSOut + 1),
+ &pLMBCSOut, (pLMBCSOut + 1),
NULL, 1, &errorCode);
- if (U_FAILURE(errorCode) || pLMBCSOut != lmbcsString+1 || pUniIn != uniString+1 || uniString[0] != 0xFF6E)
+ if (U_FAILURE(errorCode) || pLMBCSOut != (const char *)lmbcsString+1 || pUniIn != uniString+1 || uniString[0] != 0xFF6E)
{
log_err("Unexpected results from LMBCS-16 single byte char\n");
}
/* convert to group 1: should be 3 bytes */
- pLMBCSIn = lmbcsString;
+ pLMBCSIn = (char *)lmbcsString;
pUniOut = uniString;
ucnv_fromUnicode (cnv01us,
- (char **)&pLMBCSIn, (const char *)(pLMBCSIn + 3),
+ &pLMBCSIn, (const char *)(pLMBCSIn + 3),
&pUniOut, pUniOut + 1,
NULL, 1, &errorCode);
- if (U_FAILURE(errorCode) || pLMBCSIn != lmbcsString+3 || pUniOut != uniString+1
+ if (U_FAILURE(errorCode) || pLMBCSIn != (const char *)lmbcsString+3 || pUniOut != uniString+1
|| lmbcsString[0] != 0x10 || lmbcsString[1] != 0x10 || lmbcsString[2] != 0xAE)
{
log_err("Unexpected results to LMBCS-1 single byte mbcs char\n");
}
- pLMBCSOut = lmbcsString;
+ pLMBCSOut = (const char *)lmbcsString;
pUniIn = uniString;
ucnv_toUnicode (cnv01us,
&pUniIn, pUniIn + 1,
- (const char **)&pLMBCSOut, (const char *)(pLMBCSOut + 3),
+ &pLMBCSOut, (const char *)(pLMBCSOut + 3),
NULL, 1, &errorCode);
- if (U_FAILURE(errorCode) || pLMBCSOut != lmbcsString+3 || pUniIn != uniString+1 || uniString[0] != 0xFF6E)
+ if (U_FAILURE(errorCode) || pLMBCSOut != (const char *)lmbcsString+3 || pUniIn != uniString+1 || uniString[0] != 0xFF6E)
{
log_err("Unexpected results from LMBCS-1 single byte mbcs char\n");
}
- pLMBCSIn = lmbcsString;
+ pLMBCSIn = (char *)lmbcsString;
pUniOut = uniString;
ucnv_fromUnicode (cnv16jp,
- (char **)&pLMBCSIn, (const char *)(pLMBCSIn + 1),
+ &pLMBCSIn, (const char *)(pLMBCSIn + 1),
&pUniOut, pUniOut + 1,
NULL, 1, &errorCode);
- if (U_FAILURE(errorCode) || pLMBCSIn != lmbcsString+1 || pUniOut != uniString+1 || lmbcsString[0] != 0xAE)
+ if (U_FAILURE(errorCode) || pLMBCSIn != (const char *)lmbcsString+1 || pUniOut != uniString+1 || lmbcsString[0] != 0xAE)
{
log_err("Unexpected results to LMBCS-16 single byte mbcs char\n");
}
@@ -4838,8 +4903,8 @@ TestLMBCS() {
UErrorCode errorCode=U_ZERO_ERROR;
- const uint8_t * pSource = pszLMBCS;
- const uint8_t * sourceLimit = pszLMBCS + sizeof(pszLMBCS);
+ const char * pSource = (const char *)pszLMBCS;
+ const char * sourceLimit = (const char *)pszLMBCS + sizeof(pszLMBCS);
int codepointCount = 0;
UChar Out [sizeof(pszUnicode) + 1];
@@ -4859,15 +4924,15 @@ TestLMBCS() {
ucnv_toUnicode (cnv,
&pOut,
OutLimit,
- (const char **)&pSource,
- (const char *)(pSource+1), /* claim that this is a 1- byte buffer */
+ &pSource,
+ (pSource+1), /* claim that this is a 1- byte buffer */
NULL,
FALSE, /* FALSE means there might be more chars in the next buffer */
&errorCode);
if (U_SUCCESS (errorCode))
{
- if ((pSource - (const uint8_t *)pszLMBCS) == offsets [codepointCount+1])
+ if ((pSource - (const char *)pszLMBCS) == offsets [codepointCount+1])
{
/* we are on to the next code point: check value */
@@ -4887,8 +4952,8 @@ TestLMBCS() {
}
{
/* limits & surrogate error testing */
- uint8_t LIn [sizeof(pszLMBCS)];
- const uint8_t * pLIn = LIn;
+ char LIn [sizeof(pszLMBCS)];
+ const char * pLIn = LIn;
char LOut [sizeof(pszLMBCS)];
char * pLOut = LOut;
@@ -4958,9 +5023,9 @@ TestLMBCS() {
errorCode = U_ZERO_ERROR;
- pLIn = pszLMBCS;
- ucnv_toUnicode(cnv, &pUOut,pUOut+4,(const char **)&pLIn,(const char *)(pLIn+sizeof(pszLMBCS)),off,FALSE, &errorCode);
- if (errorCode != U_BUFFER_OVERFLOW_ERROR || pUOut != UOut + 4 || pLIn != (const uint8_t *)pszLMBCS+offsets[4])
+ pLIn = (const char *)pszLMBCS;
+ ucnv_toUnicode(cnv, &pUOut,pUOut+4,&pLIn,(pLIn+sizeof(pszLMBCS)),off,FALSE, &errorCode);
+ if (errorCode != U_BUFFER_OVERFLOW_ERROR || pUOut != UOut + 4 || pLIn != (const char *)pszLMBCS+offsets[4])
{
log_err("Unexpected results on out of target room to ucnv_toUnicode\n");
}
@@ -4968,11 +5033,11 @@ TestLMBCS() {
/* unpaired or chopped LMBCS surrogates */
/* OK high surrogate, Low surrogate is chopped */
- LIn [0] = 0x14;
- LIn [1] = 0xD8;
- LIn [2] = 0x01;
- LIn [3] = 0x14;
- LIn [4] = 0xDC;
+ LIn [0] = (char)0x14;
+ LIn [1] = (char)0xD8;
+ LIn [2] = (char)0x01;
+ LIn [3] = (char)0x14;
+ LIn [4] = (char)0xDC;
pLIn = LIn;
errorCode = U_ZERO_ERROR;
pUOut = UOut;
@@ -4985,9 +5050,9 @@ TestLMBCS() {
}
/* chopped at surrogate boundary */
- LIn [0] = 0x14;
- LIn [1] = 0xD8;
- LIn [2] = 0x01;
+ LIn [0] = (char)0x14;
+ LIn [1] = (char)0xD8;
+ LIn [2] = (char)0x01;
pLIn = LIn;
errorCode = U_ZERO_ERROR;
pUOut = UOut;
@@ -4999,12 +5064,12 @@ TestLMBCS() {
}
/* unpaired surrogate plus valid Unichar */
- LIn [0] = 0x14;
- LIn [1] = 0xD8;
- LIn [2] = 0x01;
- LIn [3] = 0x14;
- LIn [4] = 0xC9;
- LIn [5] = 0xD0;
+ LIn [0] = (char)0x14;
+ LIn [1] = (char)0xD8;
+ LIn [2] = (char)0x01;
+ LIn [3] = (char)0x14;
+ LIn [4] = (char)0xC9;
+ LIn [5] = (char)0xD0;
pLIn = LIn;
errorCode = U_ZERO_ERROR;
pUOut = UOut;
@@ -5016,11 +5081,11 @@ TestLMBCS() {
}
/* unpaired surrogate plus chopped Unichar */
- LIn [0] = 0x14;
- LIn [1] = 0xD8;
- LIn [2] = 0x01;
- LIn [3] = 0x14;
- LIn [4] = 0xC9;
+ LIn [0] = (char)0x14;
+ LIn [1] = (char)0xD8;
+ LIn [2] = (char)0x01;
+ LIn [3] = (char)0x14;
+ LIn [4] = (char)0xC9;
pLIn = LIn;
errorCode = U_ZERO_ERROR;
@@ -5033,11 +5098,11 @@ TestLMBCS() {
}
/* unpaired surrogate plus valid non-Unichar */
- LIn [0] = 0x14;
- LIn [1] = 0xD8;
- LIn [2] = 0x01;
- LIn [3] = 0x0F;
- LIn [4] = 0x3B;
+ LIn [0] = (char)0x14;
+ LIn [1] = (char)0xD8;
+ LIn [2] = (char)0x01;
+ LIn [3] = (char)0x0F;
+ LIn [4] = (char)0x3B;
pLIn = LIn;
errorCode = U_ZERO_ERROR;
@@ -5050,10 +5115,10 @@ TestLMBCS() {
}
/* unpaired surrogate plus chopped non-Unichar */
- LIn [0] = 0x14;
- LIn [1] = 0xD8;
- LIn [2] = 0x01;
- LIn [3] = 0x0F;
+ LIn [0] = (char)0x14;
+ LIn [1] = (char)0xD8;
+ LIn [2] = (char)0x01;
+ LIn [3] = (char)0x0F;
pLIn = LIn;
errorCode = U_ZERO_ERROR;
@@ -5074,8 +5139,8 @@ TestLMBCS() {
static void TestJitterbug255()
{
static const uint8_t testBytes[] = { 0x95, 0xcf, 0x8a, 0xb7, 0x0d, 0x0a, 0x00 };
- const uint8_t *testBuffer = testBytes;
- const uint8_t *testEnd = testBytes + sizeof(testBytes);
+ const char *testBuffer = (const char *)testBytes;
+ const char *testEnd = (const char *)testBytes + sizeof(testBytes);
UErrorCode status = U_ZERO_ERROR;
UChar32 result;
UConverter *cnv = 0;
@@ -5087,7 +5152,7 @@ static void TestJitterbug255()
}
while (testBuffer != testEnd)
{
- result = ucnv_getNextUChar (cnv, (const char **)&testBuffer, (const char *)testEnd , &status);
+ result = ucnv_getNextUChar (cnv, &testBuffer, testEnd , &status);
if (U_FAILURE(status))
{
log_err("Failed to convert the next UChar for SJIS.\n");
@@ -5133,6 +5198,7 @@ static void TestEBCDICUS4XML()
}
ucnv_close(cnv);
}
+#endif /* #if !UCONFIG_NO_LEGACY_COLLATION */
#if !UCONFIG_NO_COLLATION
diff --git a/Build/source/libs/icu-xetex/test/cintltst/putiltst.c b/Build/source/libs/icu-xetex/test/cintltst/putiltst.c
index 2a075243f56..e6cff642b23 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/putiltst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/putiltst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1998-2004, International Business Machines Corporation and
+ * Copyright (c) 1998-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
@@ -90,13 +90,6 @@ static void TestPUtilAPI(void){
log_verbose("Testing the API uprv_pow10()\n");
doAssert(uprv_pow10(4), 10000, "uprv_pow10(4) failed.");
- log_verbose("Testing the API uprv_log10()\n");
- doAssert(uprv_log10(3456), 3, "uprv_log10(3456) failed.");
-#ifdef OS390
- doAssert(uprv_log10(1.0e55), 55, "uprv_log10(1.0e55) failed.");
-#else
- doAssert(uprv_log10(1.0e300), 300, "uprv_log10(1.0e300) failed.");
-#endif
log_verbose("Testing the API uprv_isNegativeInfinity()\n");
isTrue=uprv_isNegativeInfinity(uprv_getInfinity() * -1);
if(isTrue != TRUE){
diff --git a/Build/source/libs/icu-xetex/test/cintltst/reapits.c b/Build/source/libs/icu-xetex/test/cintltst/reapits.c
index 4e3cfb7c330..d2999ed54cc 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/reapits.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/reapits.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2004, International Business Machines Corporation and
+ * Copyright (c) 2004-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -40,9 +40,11 @@ log_err("Test Failure at file %s, line %d\n", __FILE__, __LINE__);}}
UBool success; \
if (nulTerm) { \
u_austrncpy(buf_inside_macro, (actual), len+1); \
+ buf_inside_macro[len+2] = 0; \
success = (strcmp((expected), buf_inside_macro) == 0); \
} else { \
u_austrncpy(buf_inside_macro, (actual), len); \
+ buf_inside_macro[len+1] = 0; \
success = (strncmp((expected), buf_inside_macro, len) == 0); \
} \
if (success == FALSE) { \
@@ -57,13 +59,14 @@ log_err("Test Failure at file %s, line %d\n", __FILE__, __LINE__);}}
static void TestRegexCAPI(void);
+static void TestBug4315(void);
void addURegexTest(TestNode** root);
void addURegexTest(TestNode** root)
{
addTest(root, &TestRegexCAPI, "regex/TestRegexCAPI");
-/* addTest(root, &TestBreakIteratorSafeClone, "tstxtbd/cbiapts/TestBreakIteratorSafeClone"); */
+ addTest(root, &TestBug4315, "regex/TestBug4315");
}
@@ -95,6 +98,17 @@ static void TestRegexCAPI(void) {
TEST_ASSERT(status == U_REGEX_INVALID_FLAG);
uregex_close(re);
+ /* openC with an invalid parameter */
+ status = U_ZERO_ERROR;
+ re = uregex_openC(NULL,
+ UREGEX_CASE_INSENSITIVE | UREGEX_COMMENTS | UREGEX_DOTALL | UREGEX_MULTILINE | UREGEX_UWORD, 0, &status);
+ TEST_ASSERT(status == U_ILLEGAL_ARGUMENT_ERROR && re == NULL);
+
+ /* openC with an invalid parameter */
+ status = U_USELESS_COLLATOR_ERROR;
+ re = uregex_openC(NULL,
+ UREGEX_CASE_INSENSITIVE | UREGEX_COMMENTS | UREGEX_DOTALL | UREGEX_MULTILINE | UREGEX_UWORD, 0, &status);
+ TEST_ASSERT(status == U_USELESS_COLLATOR_ERROR && re == NULL);
/* openC open from a C string */
{
@@ -969,4 +983,55 @@ static void TestRegexCAPI(void) {
}
+static void TestBug4315(void) {
+ UErrorCode theICUError = U_ZERO_ERROR;
+ URegularExpression *theRegEx;
+ UChar *textBuff;
+ const char *thePattern;
+ UChar theString[100];
+ UChar *destFields[24];
+ int32_t neededLength1;
+ int32_t neededLength2;
+
+ int32_t wordCount = 0;
+ int32_t destFieldsSize = 24;
+
+ thePattern = "ck ";
+ u_uastrcpy(theString, "The quick brown fox jumped over the slow black turtle.");
+
+ /* open a regex */
+ theRegEx = uregex_openC(thePattern, 0, NULL, &theICUError);
+ TEST_ASSERT_SUCCESS(theICUError);
+
+ /* set the input string */
+ uregex_setText(theRegEx, theString, u_strlen(theString), &theICUError);
+ TEST_ASSERT_SUCCESS(theICUError);
+
+ /* split */
+ /*explicitly pass NULL and 0 to force the overflow error -> this is where the
+ * error occurs! */
+ wordCount = uregex_split(theRegEx, NULL, 0, &neededLength1, destFields,
+ destFieldsSize, &theICUError);
+
+ TEST_ASSERT(theICUError == U_BUFFER_OVERFLOW_ERROR);
+ TEST_ASSERT(wordCount==3);
+
+ if(theICUError == U_BUFFER_OVERFLOW_ERROR)
+ {
+ theICUError = U_ZERO_ERROR;
+ textBuff = (UChar *) malloc(sizeof(UChar) * (neededLength1 + 1));
+ wordCount = uregex_split(theRegEx, textBuff, neededLength1+1, &neededLength2,
+ destFields, destFieldsSize, &theICUError);
+ TEST_ASSERT(wordCount==3);
+ TEST_ASSERT_SUCCESS(theICUError);
+ TEST_ASSERT(neededLength1 == neededLength2);
+ TEST_ASSERT_STRING("The qui", destFields[0], TRUE);
+ TEST_ASSERT_STRING("brown fox jumped over the slow bla", destFields[1], TRUE);
+ TEST_ASSERT_STRING("turtle.", destFields[2], TRUE);
+ TEST_ASSERT(destFields[3] == NULL);
+ free(textBuff);
+ }
+ uregex_close(theRegEx);
+}
+
#endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */
diff --git a/Build/source/libs/icu-xetex/test/cintltst/spreptst.c b/Build/source/libs/icu-xetex/test/cintltst/spreptst.c
index 9d82c03b763..b68bc47cf69 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/spreptst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/spreptst.c
@@ -1,7 +1,7 @@
/*
*******************************************************************************
*
- * Copyright (C) 2003, International Business Machines
+ * Copyright (C) 2003-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@@ -37,6 +37,8 @@ static void Test_nfs4_mixed_prep_data(void);
static void Test_nfs4_cs_prep(void);
static void Test_nfs4_cis_prep(void);
static void Test_nfs4_mixed_prep(void);
+static void TestBEAMWarning(void);
+static void TestCoverage(void);
void
addUStringPrepTest(TestNode** root)
@@ -47,6 +49,8 @@ addUStringPrepTest(TestNode** root)
addTest(root, &Test_nfs4_cs_prep, "spreptst/Test_nfs4_cs_prep");
addTest(root, &Test_nfs4_cis_prep, "spreptst/Test_nfs4_cis_prep");
addTest(root, &Test_nfs4_mixed_prep, "spreptst/Test_nfs4_mixed_prep");
+ addTest(root, &TestBEAMWarning, "spreptst/TestBEAMWarning");
+ addTest(root, &TestCoverage, "spreptst/TestCoverage");
}
static void
@@ -290,6 +294,12 @@ unescapeData(const char* src, int32_t srcLen,
static void Test_nfs4_cis_prep(void){
int32_t i=0;
+ UErrorCode loadStatus = U_ZERO_ERROR;
+ loadTestData(&loadStatus);
+ if (U_FAILURE(loadStatus)) {
+ log_err("Test could not initialize. Got %s\n", u_errorName(loadStatus));
+ return;
+ }
for(i=0;i< (int32_t)(sizeof(conformanceTestCases)/sizeof(conformanceTestCases[0]));i++){
const char* src = conformanceTestCases[i].in;
@@ -403,6 +413,13 @@ static const char* mixed_prep_data[] ={
static void
Test_nfs4_mixed_prep(void){
+ UErrorCode loadStatus = U_ZERO_ERROR;
+ loadTestData(&loadStatus);
+ if (U_FAILURE(loadStatus)) {
+ log_err("Test could not initialize. Got %s\n", u_errorName(loadStatus));
+ return;
+ }
+
{
int32_t i=0;
char src[MAX_BUFFER_SIZE];
@@ -550,6 +567,45 @@ Test_nfs4_cs_prep(void){
}
}
+
+
+static void TestBEAMWarning(){
+ UErrorCode status = U_ZERO_ERROR;
+ UParseError parseError;
+ UStringPrepProfile* profile = NULL;
+ /* get the test data path */
+ const char *testdatapath = NULL;
+ UChar src =0x0000;
+ testdatapath = loadTestData(&status);
+ /* open the profile */
+ profile = usprep_open(testdatapath, "nfscis", &status);
+ usprep_prepare(profile,&src , 0, NULL, 0, USPREP_DEFAULT, &parseError, &status);
+
+ usprep_close(profile);
+}
+
+static void TestCoverage(void) {
+ UErrorCode status = U_USELESS_COLLATOR_ERROR;
+ UParseError parseError;
+
+ usprep_open(NULL, NULL, &status);
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("usprep_open didn't react correctly to a bad UErrorCode\n");
+ }
+ usprep_prepare(NULL, NULL, 0, NULL, 0, USPREP_DEFAULT, &parseError, &status);
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("usprep_prepare didn't react correctly to a bad UErrorCode\n");
+ }
+ status = U_ZERO_ERROR;
+ usprep_prepare(NULL, NULL, 0, NULL, 0, USPREP_DEFAULT, &parseError, &status);
+ if (status != U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("usprep_prepare didn't check its arguments\n");
+ }
+
+ /* Don't crash */
+ usprep_close(NULL);
+}
+
#endif
/*
diff --git a/Build/source/libs/icu-xetex/test/cintltst/stdnmtst.c b/Build/source/libs/icu-xetex/test/cintltst/stdnmtst.c
index 89ae5711b45..7bfa257c391 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/stdnmtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/stdnmtst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2000-2005, International Business Machines Corporation and
+ * Copyright (c) 2000-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
@@ -100,7 +100,7 @@ static void TestStandardName()
/*dotestname("cp1252", "MIME", "windows-1252") &&*/
dotestname("ascii", "MIME", "US-ASCII") &&
dotestname("csiso2022jp2", "MIME", "ISO-2022-JP-2") &&
- dotestname("Iso20-22__cN", "MIME", "ISO-2022-CN") &&
+ dotestname("Iso20-22__cN", "IANA", "ISO-2022-CN") &&
dotestname("ascii", "IANA", "ANSI_X3.4-1968") &&
dotestname("cp850", "IANA", "IBM850") &&
dotestname("crazy", "MIME", NULL) &&
@@ -152,7 +152,7 @@ static void TestCanonicalName()
dotestconv("ibm-5305", "IANA", NULL) && /* mapping does not exist */
dotestconv("cp1208", "", "UTF-8") && /* default name due to ordering */
dotestconv("UTF16_BigEndian", "", "UTF-16BE") && /* non-default name due to ordering */
- dotestconv("ISO-2022-CN", "MIME", "ISO_2022,locale=zh,version=0") &&/* default name */
+ dotestconv("ISO-2022-CN", "IANA", "ISO_2022,locale=zh,version=0") &&/* default name */
dotestconv("Shift_JIS", "MIME", "ibm-943_P15A-2003") &&/* ambiguous alias */
dotestconv("Shift_JIS", "", "ibm-943_P130-1999") &&/* ambiguous alias */
dotestconv("ibm-943", "", "ibm-943_P15A-2003") &&/* ambiguous alias */
@@ -170,8 +170,9 @@ static void TestCanonicalName()
static UBool doTestNames(const char *name, const char *standard, const char **expected, int32_t size) {
UErrorCode err = U_ZERO_ERROR;
UEnumeration *myEnum = ucnv_openStandardNames(name, standard, &err);
+ const char *enumName, *testName;
int32_t enumCount = uenum_count(myEnum, &err);
- int32_t idx, repeatTimes = 3;
+ int32_t idx, len, repeatTimes = 3;
if (size != enumCount) {
log_err("FAIL: different size arrays. Got %d. Expected %d\n", enumCount, size);
return 0;
@@ -183,9 +184,8 @@ static UBool doTestNames(const char *name, const char *standard, const char **ex
log_verbose("\n%s %s\n", name, standard);
while (repeatTimes-- > 0) {
for (idx = 0; idx < enumCount; idx++) {
- int32_t len;
- const char *enumName = uenum_next(myEnum, &len, &err);
- const char *testName = expected[idx];
+ enumName = uenum_next(myEnum, &len, &err);
+ testName = expected[idx];
if (uprv_strcmp(enumName, testName) != 0 || U_FAILURE(err)
|| len != (int32_t)uprv_strlen(expected[idx]))
{
@@ -195,6 +195,13 @@ static UBool doTestNames(const char *name, const char *standard, const char **ex
log_verbose("%s\n", enumName);
err = U_ZERO_ERROR;
}
+ if (enumCount >= 0) {
+ /* one past the list of all names must return NULL */
+ enumName = uenum_next(myEnum, &len, &err);
+ if (enumName != NULL || len != 0 || U_FAILURE(err)) {
+ log_err("FAIL: uenum_next(past the list) did not return NULL[0] with U_SUCCESS(). name=%s standard=%s len=%d err=%s\n", name, standard, len, u_errorName(err));
+ }
+ }
log_verbose("\n reset\n");
uenum_reset(myEnum, &err);
if (U_FAILURE(err)) {
diff --git a/Build/source/libs/icu-xetex/test/cintltst/tracetst.c b/Build/source/libs/icu-xetex/test/cintltst/tracetst.c
index 4fc36be4b79..54268ac818c 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/tracetst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/tracetst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2003-2004, International Business Machines Corporation and
+ * Copyright (c) 2003-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
@@ -290,8 +290,11 @@ static void TestTraceAPI() {
test_format("a 64 bit ptr %p", 50, 0, "a 64 bit ptr 1000200030004000", __LINE__, ptr);
} else if (sizeof(void *) == 16) {
/* iSeries */
- int32_t massiveBigEndianPtr[] = { 0x10002000, 0x30004000, 0x50006000, 0x70008000 };
- ptr = *((void **)massiveBigEndianPtr);
+ union {
+ int32_t arr[4];
+ void *ptr;
+ } massiveBigEndianPtr = {{ 0x10002000, 0x30004000, 0x50006000, 0x70008000 }};
+ ptr = massiveBigEndianPtr.ptr;
test_format("a 128 bit ptr %p", 50, 0, "a 128 bit ptr 10002000300040005000600070008000", __LINE__, ptr);
} else {
TEST_ASSERT(FALSE);
diff --git a/Build/source/libs/icu-xetex/test/cintltst/ucmptst.c b/Build/source/libs/icu-xetex/test/cintltst/ucmptst.c
deleted file mode 100644
index 98c1998dabe..00000000000
--- a/Build/source/libs/icu-xetex/test/cintltst/ucmptst.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/********************************************************************
- * COPYRIGHT:
- * Copyright (c) 1998-2004, International Business Machines Corporation
- * and others. All Rights Reserved.
- ********************************************************************/
-/*
-* File test.c
-*
-* Modification History:
-*
-* Date Name Description
-* 07/28/2000 Madhu Creation
-*******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-#include "ucmp8.h"
-#include "cmemory.h"
-#include "cintltst.h"
-#include "ucol_imp.h"
-
-
-static void TestUCMP8API(void);
-
-void addCompactArrayTest(TestNode** root);
-
-
-void
-addCompactArrayTest(TestNode** root)
-{
- addTest(root, &TestUCMP8API, "ucmptst/TestUCMP8API");
-}
-
-static void query(CompactByteArray *array) {
- int32_t i = 0;
- const uint8_t *valuesSet=(uint8_t *)ucmp8_getArray(array);
- for(i =0 ; i< 10; i++ ){
- if(valuesSet[0] != (uint8_t)0xFD ){
- log_err("ERROR: did not get the values expected values\n");
- break;
- }
- }
-}
-
-static void TestUCMP8API(){
- UErrorCode status = U_ZERO_ERROR;
- CompactByteArray* ucmp8Array=NULL;
- CompactByteArray* pAliaser=NULL;
- CompactByteArray* pAdopter=NULL;
-
- CompactByteArray aliaser;
- CompactByteArray adopter;
-
-
- CompactByteArray ucmp8Array1;
- CompactByteArray ucmp8Array2;
- CompactByteArray ucmp8Clone;
- int8_t *values;
- uint8_t *valuesSet;
- static const int8_t TEST_DEFAULT_VALUE = (int8_t)0xFF;
-
-
- /*ucmp8_open*/
- log_verbose("Testing ucmp8_open()\n");
- ucmp8Array=ucmp8_open(TEST_DEFAULT_VALUE);
- if(ucmp8Array == NULL){
- log_err("ERROR: ucmp8_open() failed\n");
- }
- if( (int32_t)ucmp8_getCount(ucmp8Array) != (int32_t)ucmp8_getkUnicodeCount()) {
- log_err("ERROR: ucmp8_open failed\n");
- }
-
- /*ucmp8_init*/
- log_verbose("Testing ucmp8_init()\n");
- ucmp8_init(&ucmp8Array1, TEST_DEFAULT_VALUE);
- if( (int32_t)ucmp8_getCount(&ucmp8Array1) != (int32_t)ucmp8_getkUnicodeCount() ||
- ucmp8_getIndex(&ucmp8Array1) == NULL ||
- ucmp8_getArray(&ucmp8Array1) == NULL ||
- ucmp8Array1.fBogus != FALSE){
- log_err("Error: ucmp8_init() failed\n");
- }
- /*ucmp8_initBogus*/
- log_verbose("Testing ucmp8_initBogus()\n");
- ucmp8_initBogus(&ucmp8Array2);
- if((int32_t)ucmp8_getCount(&ucmp8Array2) != ucmp8Array2.fCount ||
- ucmp8_getIndex(&ucmp8Array2) != NULL ||
- ucmp8_getArray(&ucmp8Array2) != NULL ||
- ucmp8Array2.fBogus != TRUE){
- log_err("Error: ucmp8_initBogus() failed\n");
- }
- /*ucmp8_getkBlockCount*/
- if(ucmp8_getkBlockCount() != 128 ){
- log_err("Error in ucmp8_getkBlockCount()\n");
- }
- values=(int8_t*)ucmp8_getArray(&ucmp8Array1);
- if((uint8_t)values[0] != (uint8_t)TEST_DEFAULT_VALUE){
- log_err("Error: getArray() or init failed\n");
- }
-
- /*ucmp8_compact*/
- if(ucmp8Array1.fCompact == TRUE){
- log_err("Error: ucmp8_open failed Got compact for expanded data\n");
- }
- ucmp8_compact(&ucmp8Array1, 1);
- if(ucmp8Array1.fCompact != TRUE){
- log_err("Error: ucmp8_compact failed\n");
- }
- /*ucmp8_set*/
- ucmp8_set(&ucmp8Array1, 0, (uint8_t)0xFE);
- valuesSet=(uint8_t*)ucmp8_getArray(&ucmp8Array1);
- if(valuesSet[0] != (uint8_t)0xFE ){
- log_err("ERROR: ucmp8_set() failed\n");
- }
- if(ucmp8Array1.fCompact == TRUE){
- log_err("Error: ucmp8_set didn't expand the compact data \n");
- }
-
- /*ucmp8_set*/
- ucmp8_compact(&ucmp8Array1, 1);
- ucmp8_set(&ucmp8Array1, 0, (uint8_t)0xFD);
- valuesSet=(uint8_t*)ucmp8_getArray(&ucmp8Array1);
- if(valuesSet[0] != (uint8_t)0xFD ){
- log_err("ERROR: ucmp8_set() failed\n");
- }
- if(ucmp8Array1.fCompact == TRUE){
- log_err("Error: ucmp8_set didn't expand the compact data \n");
- }
- /*ucmp8_setRange*/
- ucmp8_compact(&ucmp8Array1, 1);
- ucmp8_setRange(&ucmp8Array1, 0, 10, (uint8_t)0xFD);
- query(&ucmp8Array1);
-
- log_verbose("Testing ucmp8_flattenMem()\n");
- {
- int32_t len = 0;
- int32_t size = ucmp8_flattenMem(&ucmp8Array1, NULL);
- uint8_t *buff = malloc(size);
- uint8_t *buffLocation = buff;
- len = ucmp8_flattenMem(&ucmp8Array1, buff);
-
- if(size != len || size == 0 || len == 0 || buff == NULL) {
- log_err("Unable to flatten!\n");
- } else {
- log_verbose("Testing ucmp8_initFromData()\n");
- ucmp8_initFromData(&ucmp8Clone, (const uint8_t **)&buffLocation, &status);
- if(U_FAILURE(status) || ucmp8_isBogus(&ucmp8Clone) == TRUE || (buffLocation-buff) != len){
- log_err("ERROR: ucmp8_initFromData() failed\n");
- status = U_ZERO_ERROR;
- } else {
- query(&ucmp8Clone);
- ucmp8_close(&ucmp8Clone);
- }
- }
- free(buff);
- }
-
-/*
-openAdopt, initAdopt, openAlias, initAlias
-*/
- log_verbose("Testing aliasers and adopters\n");
- {
- int32_t count = ucmp8_getCount(&ucmp8Array1);
- const uint16_t *tIndex = ucmp8_getIndex(&ucmp8Array1);
- const int8_t *tValues = ucmp8_getArray(&ucmp8Array1);
- uint16_t *index = (uint16_t *)uprv_malloc(UCMP8_kIndexCount*sizeof(uint16_t));
-
- values = (int8_t *)uprv_malloc(count);
-
- memcpy(index, tIndex, UCMP8_kIndexCount*sizeof(uint16_t));
- memcpy(values, tValues, count);
-
- ucmp8_initAlias(&aliaser, index, values, count);
- query(&aliaser);
- ucmp8_close(&aliaser);
-
- pAliaser = ucmp8_openAlias(index, values, count);
- query(pAliaser);
- ucmp8_close(pAliaser);
-
- ucmp8_initAdopt(&adopter, index, values, count); /* TODO: BAD API. Adopted memory MUST be allocated with uprv_malloc */
- query(&adopter);
- ucmp8_close(&adopter);
-
- index = (uint16_t *)uprv_malloc(UCMP8_kIndexCount*sizeof(uint16_t));
- values = (int8_t *)uprv_malloc(count);
-
- memcpy(index, tIndex, UCMP8_kIndexCount*sizeof(uint16_t));
- memcpy(values, tValues, count);
-
- pAdopter = ucmp8_openAdopt(index, values, count); /* TODO: BAD API */
- query(pAdopter);
- ucmp8_close(pAdopter);
-
- }
- ucmp8_close(&ucmp8Array1);
- ucmp8_close(&ucmp8Array2);
- ucmp8_close(ucmp8Array);
-
-}
-
-
diff --git a/Build/source/libs/icu-xetex/test/cintltst/ucsdetst.c b/Build/source/libs/icu-xetex/test/cintltst/ucsdetst.c
new file mode 100644
index 00000000000..3c884e474f9
--- /dev/null
+++ b/Build/source/libs/icu-xetex/test/cintltst/ucsdetst.c
@@ -0,0 +1,356 @@
+/*
+ ****************************************************************************
+ * Copyright (c) 2005-2006, International Business Machines Corporation and *
+ * others. All Rights Reserved. *
+ ****************************************************************************
+ */
+
+#include "unicode/utypes.h"
+
+#include "unicode/ucsdet.h"
+#include "unicode/ucnv.h"
+#include "unicode/ustring.h"
+
+#include "cintltst.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+
+#define NEW_ARRAY(type,count) (type *) ctst_malloc((count) * sizeof(type))
+#define DELETE_ARRAY(array)
+
+static void TestConstruction(void);
+static void TestUTF8(void);
+static void TestUTF16(void);
+static void TestC1Bytes(void);
+static void TestInputFilter(void);
+static void TestChaining(void);
+
+void addUCsdetTest(TestNode** root);
+
+void addUCsdetTest(TestNode** root)
+{
+ addTest(root, &TestConstruction, "ucsdetst/TestConstruction");
+ addTest(root, &TestUTF8, "ucsdetst/TestUTF8");
+ addTest(root, &TestUTF16, "ucsdetst/TestUTF16");
+ addTest(root, &TestC1Bytes, "ucsdetst/TestC1Bytes");
+ addTest(root, &TestInputFilter, "ucsdetst/TestInputFilter");
+ addTest(root, &TestChaining, "ucsdetst/TestErrorChaining");
+}
+
+static int32_t preflight(const UChar *src, int32_t length, UConverter *cnv)
+{
+ UErrorCode status;
+ char buffer[1024];
+ char *dest, *destLimit = buffer + sizeof(buffer);
+ const UChar *srcLimit = src + length;
+ int32_t result = 0;
+
+ do {
+ dest = buffer;
+ status = U_ZERO_ERROR;
+ ucnv_fromUnicode(cnv, &dest, destLimit, &src, srcLimit, 0, TRUE, &status);
+ result += (int32_t) (dest - buffer);
+ } while (status == U_BUFFER_OVERFLOW_ERROR);
+
+ return result;
+}
+
+static UChar *unescape(const char *src, int32_t *length)
+{
+ int32_t charCount = u_unescape(src, NULL, 0);
+ UChar *chars = NEW_ARRAY(UChar, charCount + 1);
+
+ u_unescape(src, chars, charCount);
+
+ *length = charCount;
+ return chars;
+}
+
+static char *extractBytes(const UChar *src, int32_t length, const char *codepage, int32_t *byteLength)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UConverter *cnv = ucnv_open(codepage, &status);
+ int32_t byteCount = preflight(src, length, cnv);
+ const UChar *srcLimit = src + length;
+ char *bytes = NEW_ARRAY(char, byteCount + 1);
+ char *dest = bytes, *destLimit = bytes + byteCount + 1;
+
+ ucnv_fromUnicode(cnv, &dest, destLimit, &src, srcLimit, 0, TRUE, &status);
+ ucnv_close(cnv);
+
+ *byteLength = byteCount;
+ return bytes;
+}
+
+static void freeBytes(char *bytes)
+{
+ DELETE_ARRAY(bytes);
+}
+
+static void TestConstruction(void)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCharsetDetector *csd = ucsdet_open(&status);
+ UEnumeration *e = ucsdet_getAllDetectableCharsets(csd, &status);
+ const char *name;
+ int32_t count = uenum_count(e, &status);
+ int32_t i, length;
+
+ for(i = 0; i < count; i += 1) {
+ name = uenum_next(e, &length, &status);
+
+ if(name == NULL || length <= 0) {
+ log_err("ucsdet_getAllDetectableCharsets() returned a null or empty name!\n");
+ }
+ }
+ /* one past the list of all names must return NULL */
+ name = uenum_next(e, &length, &status);
+ if(name != NULL || length != 0 || U_FAILURE(status)) {
+ log_err("ucsdet_getAllDetectableCharsets(past the list) returned a non-null name!\n");
+ }
+
+ uenum_close(e);
+ ucsdet_close(csd);
+}
+
+static void TestUTF8(void)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ const char *ss = "This is a string with some non-ascii characters that will "
+ "be converted to UTF-8, then shoved through the detection process. "
+ "\\u0391\\u0392\\u0393\\u0394\\u0395"
+ "Sure would be nice if our source could contain Unicode directly!";
+ int32_t byteLength = 0, sLength = 0, dLength = 0;
+ UChar *s = unescape(ss, &sLength);
+ char *bytes = extractBytes(s, sLength, "UTF-8", &byteLength);
+ UCharsetDetector *csd = ucsdet_open(&status);
+ const UCharsetMatch *match;
+ UChar *detected = NEW_ARRAY(UChar, sLength);
+
+ ucsdet_setText(csd, bytes, byteLength, &status);
+ match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ log_err("Detection failure for UTF-8: got no matches.\n");
+ goto bail;
+ }
+
+ dLength = ucsdet_getUChars(match, detected, sLength, &status);
+
+ if (u_strCompare(detected, dLength, s, sLength, FALSE) != 0) {
+ log_err("Round-trip test failed!\n");
+ }
+
+ ucsdet_setDeclaredEncoding(csd, "UTF-8", 5, &status); /* for coverage */
+
+bail:
+ DELETE_ARRAY(detected);
+ freeBytes(bytes);
+ ucsdet_close(csd);
+}
+
+static void TestUTF16(void)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ /* Notice the BOM on the start of this string */
+ UChar chars[] = {
+ 0xFEFF, 0x0623, 0x0648, 0x0631, 0x0648, 0x0628, 0x0627, 0x002C,
+ 0x0020, 0x0628, 0x0631, 0x0645, 0x062c, 0x064a, 0x0627, 0x062a,
+ 0x0020, 0x0627, 0x0644, 0x062d, 0x0627, 0x0633, 0x0648, 0x0628,
+ 0x0020, 0x002b, 0x0020, 0x0627, 0x0646, 0x062a, 0x0631, 0x0646,
+ 0x064a, 0x062a, 0x0000};
+ int32_t beLength = 0, leLength = 0, cLength = ARRAY_SIZE(chars);
+ char *beBytes = extractBytes(chars, cLength, "UTF-16BE", &beLength);
+ char *leBytes = extractBytes(chars, cLength, "UTF-16LE", &leLength);
+ UCharsetDetector *csd = ucsdet_open(&status);
+ const UCharsetMatch *match;
+ const char *name;
+ int32_t conf;
+
+ ucsdet_setText(csd, beBytes, beLength, &status);
+ match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ log_err("Encoding detection failure for UTF-16BE: got no matches.\n");
+ goto try_le;
+ }
+
+ name = ucsdet_getName(match, &status);
+ conf = ucsdet_getConfidence(match, &status);
+
+ if (strcmp(name, "UTF-16BE") != 0) {
+ log_err("Encoding detection failure for UTF-16BE: got %s\n", name);
+ }
+
+ if (conf != 100) {
+ log_err("Did not get 100%% confidence for UTF-16BE: got %d\n", conf);
+ }
+
+try_le:
+ ucsdet_setText(csd, leBytes, leLength, &status);
+ match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ log_err("Encoding detection failure for UTF-16LE: got no matches.\n");
+ goto bail;
+ }
+
+ name = ucsdet_getName(match, &status);
+ conf = ucsdet_getConfidence(match, &status);
+
+
+ if (strcmp(name, "UTF-16LE") != 0) {
+ log_err("Enconding detection failure for UTF-16LE: got %s\n", name);
+ }
+
+ if (conf != 100) {
+ log_err("Did not get 100%% confidence for UTF-16LE: got %d\n", conf);
+ }
+
+bail:
+ freeBytes(leBytes);
+ freeBytes(beBytes);
+ ucsdet_close(csd);
+}
+
+static void TestC1Bytes(void)
+{
+#if !UCONFIG_NO_LEGACY_CONVERSION
+ UErrorCode status = U_ZERO_ERROR;
+ const char *ssISO = "This is a small sample of some English text. Just enough to be sure that it detects correctly.";
+ const char *ssWindows = "This is another small sample of some English text. Just enough to be sure that it detects correctly. It also includes some \\u201CC1\\u201D bytes.";
+ int32_t sISOLength = 0, sWindowsLength = 0;
+ UChar *sISO = unescape(ssISO, &sISOLength);
+ UChar *sWindows = unescape(ssWindows, &sWindowsLength);
+ int32_t lISO = 0, lWindows = 0;
+ char *bISO = extractBytes(sISO, sISOLength, "ISO-8859-1", &lISO);
+ char *bWindows = extractBytes(sWindows, sWindowsLength, "windows-1252", &lWindows);
+ UCharsetDetector *csd = ucsdet_open(&status);
+ const UCharsetMatch *match;
+ const char *name;
+
+ ucsdet_setText(csd, bWindows, lWindows, &status);
+ match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ log_err("English test with C1 bytes got no matches.\n");
+ goto bail;
+ }
+
+ name = ucsdet_getName(match, &status);
+
+ if (strcmp(name, "windows-1252") != 0) {
+ log_err("English text with C1 bytes does not detect as windows-1252, but as %s\n", name);
+ }
+
+ ucsdet_setText(csd, bISO, lISO, &status);
+ match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ log_err("English text without C1 bytes got no matches.\n");
+ goto bail;
+ }
+
+ name = ucsdet_getName(match, &status);
+
+ if (strcmp(name, "ISO-8859-1") != 0) {
+ log_err("English text without C1 bytes does not detect as ISO-8859-1, but as %s\n", name);
+ }
+
+bail:
+ freeBytes(bWindows);
+ freeBytes(bISO);
+
+ ucsdet_close(csd);
+#endif
+}
+
+static void TestInputFilter(void)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ const char *ss = "<a> <lot> <of> <English> <inside> <the> <markup> Un tr\\u00E8s petit peu de Fran\\u00E7ais. <to> <confuse> <the> <detector>";
+ int32_t sLength = 0;
+ UChar *s = unescape(ss, &sLength);
+ int32_t byteLength = 0;
+ char *bytes = extractBytes(s, sLength, "ISO-8859-1", &byteLength);
+ UCharsetDetector *csd = ucsdet_open(&status);
+ const UCharsetMatch *match;
+ const char *lang, *name;
+
+ ucsdet_enableInputFilter(csd, TRUE);
+
+ if (!ucsdet_isInputFilterEnabled(csd)) {
+ log_err("ucsdet_enableInputFilter(csd, TRUE) did not enable input filter!\n");
+ }
+
+
+ ucsdet_setText(csd, bytes, byteLength, &status);
+ match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ log_err("Turning on the input filter resulted in no matches.\n");
+ goto turn_off;
+ }
+
+ name = ucsdet_getName(match, &status);
+
+ if (name == NULL || strcmp(name, "ISO-8859-1") != 0) {
+ log_err("Turning on the input filter resulted in %s rather than ISO-8859-1\n", name);
+ } else {
+ lang = ucsdet_getLanguage(match, &status);
+
+ if (lang == NULL || strcmp(lang, "fr") != 0) {
+ log_err("Input filter did not strip markup!\n");
+ }
+ }
+
+turn_off:
+ ucsdet_enableInputFilter(csd, FALSE);
+ ucsdet_setText(csd, bytes, byteLength, &status);
+ match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ log_err("Turning off the input filter resulted in no matches.\n");
+ goto bail;
+ }
+
+ name = ucsdet_getName(match, &status);
+
+ if (name == NULL || strcmp(name, "ISO-8859-1") != 0) {
+ log_err("Turning off the input filter resulted in %s rather than ISO-8859-1\n", name);
+ } else {
+ lang = ucsdet_getLanguage(match, &status);
+
+ if (lang == NULL || strcmp(lang, "en") != 0) {
+ log_err("Unfiltered input did not detect as English!\n");
+ }
+ }
+
+bail:
+ freeBytes(bytes);
+ ucsdet_close(csd);
+}
+
+static void TestChaining(void) {
+ UErrorCode status = U_USELESS_COLLATOR_ERROR;
+
+ ucsdet_open(&status);
+ ucsdet_setText(NULL, NULL, 0, &status);
+ ucsdet_getName(NULL, &status);
+ ucsdet_getConfidence(NULL, &status);
+ ucsdet_getLanguage(NULL, &status);
+ ucsdet_detect(NULL, &status);
+ ucsdet_setDeclaredEncoding(NULL, NULL, 0, &status);
+ ucsdet_detectAll(NULL, NULL, &status);
+ ucsdet_getUChars(NULL, NULL, 0, &status);
+ ucsdet_getUChars(NULL, NULL, 0, &status);
+ ucsdet_close(NULL);
+
+ /* All of this code should have done nothing. */
+ if (status != U_USELESS_COLLATOR_ERROR) {
+ log_err("Status got changed to %s\n", u_errorName(status));
+ }
+}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/udatatst.c b/Build/source/libs/icu-xetex/test/cintltst/udatatst.c
index 156a1582d56..b68ec82ab65 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/udatatst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/udatatst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1998-2005, International Business Machines Corporation and
+ * Copyright (c) 1998-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
@@ -26,6 +26,7 @@
#include "filestrm.h"
#include "udatamem.h"
#include "cintltst.h"
+#include "ubrkimpl.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -600,10 +601,12 @@ static void TestUDataOpenChoiceDemo1() {
const char* name[]={
"cnvalias",
"unames",
- "test"
+ "test",
+ "nam"
};
const char* type="icu";
const char* testPath="testdata";
+ const char* fullTestDataPath = loadTestData(&status);
result=udata_openChoice(NULL, "icu", name[0], isAcceptable1, NULL, &status);
if(U_FAILURE(status)){
@@ -613,6 +616,7 @@ static void TestUDataOpenChoiceDemo1() {
udata_close(result);
}
+ status=U_ZERO_ERROR;
result=udata_openChoice(NULL, type, name[1], isAcceptable1, NULL, &status);
if(U_FAILURE(status)){
status=U_ZERO_ERROR;
@@ -621,11 +625,15 @@ static void TestUDataOpenChoiceDemo1() {
log_err("FAIL: udata_openChoice() failed name=%s, type=%s, \n errorcode=%s\n", name[1], type, myErrorName(status));
}
}
+ else {
+ log_err("FAIL: udata_openChoice() unexpectedly passed. name=%s, type=%s, \n errorcode=%s\n", name[1], type, myErrorName(status));
+ }
if(U_SUCCESS(status)){
udata_close(result);
}
+ status=U_ZERO_ERROR;
result=udata_openChoice(testPath, type, name[2], isAcceptable1, NULL, &status);
if(U_FAILURE(status)){
status=U_ZERO_ERROR;
@@ -634,10 +642,26 @@ static void TestUDataOpenChoiceDemo1() {
log_err("FAIL: udata_openChoice() failed path=%s name=%s, type=%s, \n errorcode=%s\n", testPath, name[2], type, myErrorName(status));
}
}
+ else {
+ log_err("FAIL: udata_openChoice() unexpectedly passed. name=%s, type=%s, \n errorcode=%s\n", name[2], type, myErrorName(status));
+ }
if(U_SUCCESS(status)){
udata_close(result);
}
+
+ status=U_ZERO_ERROR;
+ type="typ";
+ result=udata_openChoice(fullTestDataPath, type, name[3], isAcceptable1, NULL, &status);
+ if(status != U_INVALID_FORMAT_ERROR){
+ log_err("FAIL: udata_openChoice() did not fail as expected. name=%s, type=%s, \n errorcode=%s\n", name[3], type, myErrorName(status));
+ }
+
+ status=U_USELESS_COLLATOR_ERROR;
+ result=udata_openChoice(fullTestDataPath, type, name[3], isAcceptable1, NULL, &status);
+ if(status != U_USELESS_COLLATOR_ERROR){
+ log_err("FAIL: udata_openChoice() did not fail as expected. name=%s, type=%s, \n errorcode=%s\n", name[3], type, myErrorName(status));
+ }
}
static UBool U_CALLCONV
@@ -1100,6 +1124,97 @@ static void TestICUDataName()
/* test data swapping ------------------------------------------------------- */
+#ifdef OS400
+/* See comments in genccode.c on when this special implementation can be removed. */
+static const struct {
+ double bogus;
+ const char *bytes;
+} gOffsetTOCAppDataItem1={ 0.0, /* alignment bytes */
+ "\x00\x14" /* sizeof(UDataInfo) *//* MappedData { */
+ "\xda"
+ "\x27" /* } */
+ "\x00\x14" /* sizeof(UDataInfo) *//* UDataInfo { */
+ "\0\0"
+ "\1" /* U_IS_BIG_ENDIAN */
+ "\1" /* U_CHARSET_FAMILY */
+ "\2" /* U_SIZEOF_WHAR_T */
+ "\0"
+ "\x31\x31\x31\x31"
+ "\0\0\0\0"
+ "\0\0\0\0" /* } */
+};
+#else
+static const struct {
+ double bogus;
+ MappedData bytes1;
+ UDataInfo bytes2;
+ uint8_t bytes3;
+} gOffsetTOCAppDataItem1={
+ 0.0, /* alignment bytes */
+ { sizeof(UDataInfo), 0xda, 0x27 }, /* MappedData */
+
+ {sizeof(UDataInfo),
+ 0,
+
+ U_IS_BIG_ENDIAN,
+ U_CHARSET_FAMILY,
+ sizeof(UChar),
+ 0,
+
+ {0x31, 0x31, 0x31, 0x31}, /* dataFormat="1111" */
+ {0, 0, 0, 0}, /* formatVersion */
+ {0, 0, 0, 0}} /* dataVersion */
+};
+#endif
+
+static const UChar gOffsetTOCGarbage[] = { /* "I have been very naughty!" */
+ 0x49, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x62, 0x65, 0x65, 0x6E,
+ 0x20, 0x76, 0x65, 0x72, 0x79, 0x20, 0x6E, 0x61, 0x75, 0x67, 0x68, 0x74, 0x79, 0x21
+};
+
+/* Original source: icu/source/tools/genccode */
+static const struct {
+ uint16_t headerSize;
+ uint8_t magic1, magic2;
+ UDataInfo info;
+ char padding[8];
+ uint32_t count, reserved;
+ const struct {
+ const char *const name;
+ const void *const data;
+ } toc[3];
+} gOffsetTOCAppData_dat = {
+ 32, /* headerSize */
+ 0xda, /* magic1, (see struct MappedData in udata.c) */
+ 0x27, /* magic2 */
+ { /*UDataInfo */
+ sizeof(UDataInfo), /* size */
+ 0, /* reserved */
+ U_IS_BIG_ENDIAN,
+ U_CHARSET_FAMILY,
+ sizeof(UChar),
+ 0, /* reserved */
+ { /* data format identifier */
+ 0x54, 0x6f, 0x43, 0x50}, /* "ToCP" */
+ {1, 0, 0, 0}, /* format version major, minor, milli, micro */
+ {0, 0, 0, 0} /* dataVersion */
+ },
+ {0,0,0,0,0,0,0,0}, /* Padding[8] */
+ 3, /* count */
+ 0, /* Reserved */
+ { /* TOC structure */
+ { "OffsetTOCAppData/a/b", &gOffsetTOCAppDataItem1 },
+ { "OffsetTOCAppData/gOffsetTOCAppDataItem1", &gOffsetTOCAppDataItem1 },
+ { "OffsetTOCAppData/gOffsetTOCGarbage", &gOffsetTOCGarbage }
+ }
+};
+
+/* Unfortunately, trie dictionaries are in a C++ header */
+int32_t
+triedict_swap(const UDataSwapper *ds,
+ const void *inData, int32_t length, void *outData,
+ UErrorCode *pErrorCode);
+
/* test cases for maximum data swapping code coverage */
static const struct {
const char *name, *type;
@@ -1116,6 +1231,8 @@ static const struct {
{"el", "res", ures_swap},
/* ICU's root */
{"root", "res", ures_swap},
+ /* Test a 32-bit key table. This is large. */
+ {"*testtable32", "res", ures_swap},
/* ICU 2.6 resource bundle - data format 1.0, without indexes[] (little-endian ASCII) */
{"*icu26_testtypes", "res", ures_swap},
@@ -1143,7 +1260,9 @@ static const struct {
{"gb18030", "cnv", ucnv_swap},
/* MBCS conversion table file with extension */
{"*test4x", "cnv", ucnv_swap},
+#endif
+#if !UCONFIG_NO_CONVERSION
/* alias table */
{"cnvalias", "icu", ucnv_swapAliases},
#endif
@@ -1154,6 +1273,7 @@ static const struct {
#if !UCONFIG_NO_BREAK_ITERATION
{"char", "brk", ubrk_swap},
+ {"thaidict", "ctd", triedict_swap},
#endif
/* the last item should not be #if'ed so that it can reliably omit the last comma */
@@ -1181,7 +1301,8 @@ static const struct {
{"unames", "icu", uchar_swapNames}
};
-#define SWAP_BUFFER_SIZE 1000000
+/* Large enough for the largest swappable data item. */
+#define SWAP_BUFFER_SIZE 1800000
static void U_CALLCONV
printError(void *context, const char *fmt, va_list args) {
@@ -1198,6 +1319,7 @@ TestSwapCase(UDataMemory *pData, const char *name,
int32_t length, dataLength, length2, headerLength;
UErrorCode errorCode;
+ UErrorCode badStatus;
UBool inEndian, oppositeEndian;
uint8_t inCharset, oppositeCharset;
@@ -1259,6 +1381,20 @@ TestSwapCase(UDataMemory *pData, const char *name,
}
}
+ /*
+ Check error checking of swappable data not specific to this swapper.
+ This should always fail.
+ */
+ badStatus = U_ZERO_ERROR;
+ length=swapFn(ds, &gOffsetTOCAppData_dat, -1, NULL, &badStatus);
+ if(badStatus != U_UNSUPPORTED_ERROR) {
+ log_err("swapFn(%s->!isBig+same charset) unexpectedly succeeded on bad data - %s\n",
+ name, u_errorName(errorCode));
+ udata_closeSwapper(ds);
+ return;
+ }
+
+ /* Now allow errors to be printed */
ds->printError=printError;
/* preflight the length */
@@ -1415,6 +1551,13 @@ TestSwapData() {
}
/* Test that printError works as expected. */
+ errorCode=U_USELESS_COLLATOR_ERROR;
+ ds=udata_openSwapper(U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
+ !U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
+ &errorCode);
+ if (ds != NULL || errorCode != U_USELESS_COLLATOR_ERROR) {
+ log_err("udata_openSwapper should have returned NULL with bad argument\n", name);
+ }
errorCode=U_ZERO_ERROR;
ds=udata_openSwapper(U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
!U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
@@ -1427,19 +1570,39 @@ TestSwapData() {
log_err("udata_printError can't properly print error messages. Got = %s\n", name);
}
errorCode = U_USELESS_COLLATOR_ERROR;
- if (udata_openSwapperForInputData(NULL, 0,
+ ds=udata_openSwapperForInputData(NULL, 0,
!U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
- &errorCode) != NULL) {
+ &errorCode);
+ if (ds != NULL || errorCode != U_USELESS_COLLATOR_ERROR) {
log_err("udata_openSwapperForInputData should have returned NULL with bad argument\n", name);
}
+ errorCode=U_ZERO_ERROR;
ds=udata_openSwapperForInputData(NULL, 0,
!U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
&errorCode);
- if (ds != NULL || errorCode != U_USELESS_COLLATOR_ERROR) {
+ if (ds != NULL || errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("udata_openSwapperForInputData should have returned NULL with bad argument\n", name);
+ }
+ errorCode=U_ZERO_ERROR;
+ memset(buffer, 0, sizeof(2*SWAP_BUFFER_SIZE));
+ ds=udata_openSwapperForInputData(buffer, 2*SWAP_BUFFER_SIZE,
+ !U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
+ &errorCode);
+ if (ds != NULL || errorCode != U_UNSUPPORTED_ERROR) {
log_err("udata_openSwapperForInputData should have returned NULL with bad argument\n", name);
}
errorCode=U_ZERO_ERROR;
+ /* Test argument checking. ucol_swapBinary is normally tested via ures_swap, and isn't normally called directly. */
+#if !UCONFIG_NO_COLLATION
+ ucol_swapBinary(NULL, NULL, -1, NULL, NULL);
+ ucol_swapBinary(NULL, NULL, -1, NULL, &errorCode);
+ if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
+ log_err("ucol_swapBinary did not fail as expected\n", name);
+ }
+ errorCode=U_ZERO_ERROR;
+#endif
+
for(i=0; i<LENGTHOF(swapCases); ++i) {
/* build the name for logging */
errorCode=U_ZERO_ERROR;
@@ -1447,6 +1610,11 @@ TestSwapData() {
pkg=loadTestData(&errorCode);
nm=swapCases[i].name+1;
uprv_strcpy(name, "testdata");
+ } else if (uprv_strcmp(swapCases[i].type, "brk")==0
+ || uprv_strcmp(swapCases[i].type, "ctd")==0) {
+ pkg=U_ICUDATA_BRKITR;
+ nm=swapCases[i].name;
+ uprv_strcpy(name, U_ICUDATA_BRKITR);
} else {
pkg=NULL;
nm=swapCases[i].name;
@@ -1471,92 +1639,6 @@ TestSwapData() {
}
-#ifdef OS400
-/* See comments in genccode.c on when this special implementation can be removed. */
-static const struct {
- double bogus;
- const char *bytes;
-} gOffsetTOCAppDataItem1={ 0.0, /* alignment bytes */
- "\x00\x14" /* sizeof(UDataInfo) *//* MappedData { */
- "\xda"
- "\x27" /* } */
- "\x00\x14" /* sizeof(UDataInfo) *//* UDataInfo { */
- "\0\0"
- "\1" /* U_IS_BIG_ENDIAN */
- "\1" /* U_CHARSET_FAMILY */
- "\2" /* U_SIZEOF_WHAR_T */
- "\0"
- "\x31\x31\x31\x31"
- "\0\0\0\0"
- "\0\0\0\0" /* } */
-};
-#else
-static const struct {
- double bogus;
- MappedData bytes1;
- UDataInfo bytes2;
- uint8_t bytes3;
-} gOffsetTOCAppDataItem1={
- 0.0, /* alignment bytes */
- { sizeof(UDataInfo), 0xda, 0x27 }, /* MappedData */
-
- {sizeof(UDataInfo),
- 0,
-
- U_IS_BIG_ENDIAN,
- U_CHARSET_FAMILY,
- sizeof(UChar),
- 0,
-
- {0x31, 0x31, 0x31, 0x31}, /* dataFormat="1111" */
- {0, 0, 0, 0}, /* formatVersion */
- {0, 0, 0, 0}} /* dataVersion */
-};
-#endif
-
-static const UChar gOffsetTOCGarbage[] = { /* "I have been very naughty!" */
- 0x49, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x62, 0x65, 0x65, 0x6E,
- 0x20, 0x76, 0x65, 0x72, 0x79, 0x20, 0x6E, 0x61, 0x75, 0x67, 0x68, 0x74, 0x79, 0x21
-};
-
-/* Original source: icu/source/tools/genccode */
-static const struct {
- uint16_t headerSize;
- uint8_t magic1, magic2;
- UDataInfo info;
- char padding[8];
- uint32_t count, reserved;
- const struct {
- const char *const name;
- const void *const data;
- } toc[3];
-} gOffsetTOCAppData_dat = {
- 32, /* headerSize */
- 0xda, /* magic1, (see struct MappedData in udata.c) */
- 0x27, /* magic2 */
- { /*UDataInfo */
- sizeof(UDataInfo), /* size */
- 0, /* reserved */
- U_IS_BIG_ENDIAN,
- U_CHARSET_FAMILY,
- sizeof(UChar),
- 0, /* reserved */
- { /* data format identifier */
- 0x54, 0x6f, 0x43, 0x50}, /* "ToCP" */
- {1, 0, 0, 0}, /* format version major, minor, milli, micro */
- {0, 0, 0, 0} /* dataVersion */
- },
- {0,0,0,0,0,0,0,0}, /* Padding[8] */
- 3, /* count */
- 0, /* Reserved */
- { /* TOC structure */
- { "OffsetTOCAppData/a/b", &gOffsetTOCAppDataItem1 },
- { "OffsetTOCAppData/gOffsetTOCAppDataItem1", &gOffsetTOCAppDataItem1 },
- { "OffsetTOCAppData/gOffsetTOCGarbage", &gOffsetTOCGarbage }
- }
-};
-
-
static void PointerTableOfContents() {
UDataMemory *dataItem;
UErrorCode status=U_ZERO_ERROR;
@@ -1612,6 +1694,10 @@ static void SetBadCommonData(void) {
/* It's difficult to test that udata_setCommonData really works within the test framework.
So we just test that foolish people can't do bad things. */
UErrorCode status;
+ char badBuffer[sizeof(gOffsetTOCAppData_dat)];
+
+ memset(badBuffer, 0, sizeof(badBuffer));
+ strcpy(badBuffer, "Hello! I'm not good data.");
/* Check that we don't do anything */
status = U_FILE_ACCESS_ERROR;
@@ -1637,5 +1723,12 @@ static void SetBadCommonData(void) {
else {
log_verbose("Can't test setting common data because files mode may have been used.\n");
}
+
+ /* Check that we verify that the data isn't bad */
+ status = U_ZERO_ERROR;
+ udata_setAppData("invalid path", badBuffer, &status);
+ if (status != U_INVALID_FORMAT_ERROR) {
+ log_err("FAIL: udata_setAppData doesn't verify data validity.\n");
+ }
}
diff --git a/Build/source/libs/icu-xetex/test/cintltst/utexttst.c b/Build/source/libs/icu-xetex/test/cintltst/utexttst.c
index 3d8f426e452..be5941df403 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/utexttst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/utexttst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2005, International Business Machines Corporation and
+ * Copyright (c) 2005-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
@@ -86,14 +86,14 @@ static void TestAPI(void) {
/* utext_clone() */
{
UChar uString[] = {0x41, 0x42, 0x43, 0};
- int32_t len;
+ int64_t len;
UText *uta;
UText *utb;
status = U_ZERO_ERROR;
uta = utext_openUChars(NULL, uString, -1, &status);
TEST_SUCCESS(status);
- utb = utext_clone(NULL, uta, FALSE, &status);
+ utb = utext_clone(NULL, uta, FALSE, FALSE, &status);
TEST_SUCCESS(status);
TEST_ASSERT(utb != NULL);
TEST_ASSERT(utb != uta);
@@ -108,9 +108,9 @@ static void TestAPI(void) {
UChar uString[] = {0x41, 0x42, 0x43, 0};
UText *uta;
UChar32 c;
- int32_t len;
+ int64_t len;
UBool b;
- int32_t i;
+ int64_t i;
status = U_ZERO_ERROR;
uta = utext_openUChars(NULL, uString, -1, &status);
diff --git a/Build/source/libs/icu-xetex/test/cintltst/utf8tst.c b/Build/source/libs/icu-xetex/test/cintltst/utf8tst.c
index 420a5f3dbc5..eaa8fb28c54 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/utf8tst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/utf8tst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1998-2003, International Business Machines Corporation and
+ * Copyright (c) 1998-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
@@ -20,6 +20,44 @@
#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
+/* lenient UTF-8 ------------------------------------------------------------ */
+
+/*
+ * Lenient UTF-8 differs from conformant UTF-8 in that it allows surrogate
+ * code points with their "natural" encoding.
+ * Effectively, this allows a mix of UTF-8 and CESU-8 as well as encodings of
+ * single surrogates.
+ *
+ * This is not conformant with UTF-8.
+ *
+ * Supplementary code points may be encoded as pairs of 3-byte sequences, but
+ * the macros below do not attempt to assemble such pairs.
+ */
+
+#define L8_NEXT(s, i, length, c) { \
+ (c)=(uint8_t)(s)[(i)++]; \
+ if((c)>=0x80) { \
+ if(U8_IS_LEAD(c)) { \
+ (c)=utf8_nextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -2); \
+ } else { \
+ (c)=U_SENTINEL; \
+ } \
+ } \
+}
+
+#define L8_PREV(s, start, i, c) { \
+ (c)=(uint8_t)(s)[--(i)]; \
+ if((c)>=0x80) { \
+ if((c)<=0xbf) { \
+ (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -2); \
+ } else { \
+ (c)=U_SENTINEL; \
+ } \
+ } \
+}
+
+/* -------------------------------------------------------------------------- */
+
static void printUChars(const uint8_t *uchars, int16_t len);
static void TestCodeUnitValues(void);
@@ -30,6 +68,7 @@ static void TestFwdBack(void);
static void TestSetChar(void);
static void TestAppendChar(void);
static void TestAppend(void);
+static void TestSurrogates(void);
void addUTF8Test(TestNode** root);
@@ -44,6 +83,7 @@ addUTF8Test(TestNode** root)
addTest(root, &TestSetChar, "utf8tst/TestSetChar" );
addTest(root, &TestAppendChar, "utf8tst/TestAppendChar" );
addTest(root, &TestAppend, "utf8tst/TestAppend" );
+ addTest(root, &TestSurrogates, "utf8tst/TestSurrogates" );
}
static void TestCodeUnitValues()
@@ -817,6 +857,97 @@ static void TestAppend() {
}
}
+static void
+TestSurrogates() {
+ static const uint8_t b[]={
+ 0xc3, 0x9f, /* 00DF */
+ 0xed, 0x9f, 0xbf, /* D7FF */
+ 0xed, 0xa0, 0x81, /* D801 */
+ 0xed, 0xbf, 0xbe, /* DFFE */
+ 0xee, 0x80, 0x80, /* E000 */
+ 0xf0, 0x97, 0xbf, 0xbe /* 17FFE */
+ };
+ static const UChar32 cp[]={
+ 0xdf, 0xd7ff, 0xd801, 0xdffe, 0xe000, 0x17ffe
+ };
+
+ UChar32 cu, cs, cl;
+ int32_t i, j, k, iu, is, il, length;
+
+ k=0; /* index into cp[] */
+ length=LENGTHOF(b);
+ for(i=0; i<length;) {
+ j=i;
+ U8_NEXT_UNSAFE(b, j, cu);
+ iu=j;
+
+ j=i;
+ U8_NEXT(b, j, length, cs);
+ is=j;
+
+ j=i;
+ L8_NEXT(b, j, length, cl);
+ il=j;
+
+ if(cu!=cp[k]) {
+ log_err("U8_NEXT_UNSAFE(b[%ld])=U+%04lX != U+%04lX\n", (long)i, (long)cu, (long)cp[k]);
+ }
+
+ /* U8_NEXT() returns <0 for surrogate code points */
+ if(U_IS_SURROGATE(cu) ? cs>=0 : cs!=cu) {
+ log_err("U8_NEXT(b[%ld])=U+%04lX != U+%04lX\n", (long)i, (long)cs, (long)cu);
+ }
+
+ /* L8_NEXT() returns surrogate code points like U8_NEXT_UNSAFE() */
+ if(cl!=cu) {
+ log_err("L8_NEXT(b[%ld])=U+%04lX != U+%04lX\n", (long)i, (long)cl, (long)cu);
+ }
+
+ if(is!=iu || il!=iu) {
+ log_err("U8_NEXT(b[%ld]) or L8_NEXT(b[%ld]) did not advance the index correctly\n", (long)i, (long)i);
+ }
+
+ ++k; /* next code point */
+ i=iu; /* advance by one UTF-8 sequence */
+ }
+
+ while(i>0) {
+ --k; /* previous code point */
+
+ j=i;
+ U8_PREV_UNSAFE(b, j, cu);
+ iu=j;
+
+ j=i;
+ U8_PREV(b, 0, j, cs);
+ is=j;
+
+ j=i;
+ L8_PREV(b, 0, j, cl);
+ il=j;
+
+ if(cu!=cp[k]) {
+ log_err("U8_PREV_UNSAFE(b[%ld])=U+%04lX != U+%04lX\n", (long)i, (long)cu, (long)cp[k]);
+ }
+
+ /* U8_PREV() returns <0 for surrogate code points */
+ if(U_IS_SURROGATE(cu) ? cs>=0 : cs!=cu) {
+ log_err("U8_PREV(b[%ld])=U+%04lX != U+%04lX\n", (long)i, (long)cs, (long)cu);
+ }
+
+ /* L8_PREV() returns surrogate code points like U8_PREV_UNSAFE() */
+ if(cl!=cu) {
+ log_err("L8_PREV(b[%ld])=U+%04lX != U+%04lX\n", (long)i, (long)cl, (long)cu);
+ }
+
+ if(is!=iu || il !=iu) {
+ log_err("U8_PREV(b[%ld]) or L8_PREV(b[%ld]) did not advance the index correctly\n", (long)i, (long)i);
+ }
+
+ i=iu; /* go back by one UTF-8 sequence */
+ }
+}
+
static void printUChars(const uint8_t *uchars, int16_t len){
int16_t i=0;
for(i=0; i<len; i++){
diff --git a/Build/source/libs/icu-xetex/test/cintltst/utmstest.c b/Build/source/libs/icu-xetex/test/cintltst/utmstest.c
index f68b5bdd461..93c0c330deb 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/utmstest.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/utmstest.c
@@ -1,6 +1,6 @@
/*
****************************************************************************
- * Copyright (c) 1997-2004, International Business Machines Corporation and *
+ * Copyright (c) 1997-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
****************************************************************************
*/
@@ -10,17 +10,21 @@
#if !UCONFIG_NO_FORMATTING
#include "unicode/utmscale.h"
+#include "unicode/ucal.h"
#include "cintltst.h"
#include <stdlib.h>
#include <time.h>
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
#define LOOP_COUNT 10000
static void TestAPI(void);
static void TestData(void);
static void TestMonkey(void);
+static void TestDotNet(void);
void addUtmsTest(TestNode** root);
@@ -29,6 +33,7 @@ void addUtmsTest(TestNode** root)
addTest(root, &TestAPI, "tsformat/utmstest/TestAPI");
addTest(root, &TestData, "tsformat/utmstest/TestData");
addTest(root, &TestMonkey, "tsformat/utmstest/TestMonkey");
+ addTest(root, &TestDotNet, "tsformat/utmstest/TestDotNet");
}
/**
@@ -339,4 +344,143 @@ static void TestMonkey(void)
}
}
+struct DotNetDateTimeTicks {
+ int32_t year;
+ int32_t month;
+ int32_t day;
+ int64_t ticks;
+};
+typedef struct DotNetDateTimeTicks DotNetDateTimeTicks;
+
+/*
+ * This data was generated by C++.Net code like
+ * Console::WriteLine(L" {{ {0}, 1, 1, INT64_C({1}) }},", year, DateTime(year, 1, 1).Ticks);
+ * with the DateTime constructor taking int values for year, month, and date.
+ */
+static const DotNetDateTimeTicks dotNetDateTimeTicks[]={
+ /* year, month, day, ticks */
+ { 100, 1, 1, INT64_C(31241376000000000) },
+ { 100, 3, 1, INT64_C(31292352000000000) },
+ { 200, 1, 1, INT64_C(62798112000000000) },
+ { 200, 3, 1, INT64_C(62849088000000000) },
+ { 300, 1, 1, INT64_C(94354848000000000) },
+ { 300, 3, 1, INT64_C(94405824000000000) },
+ { 400, 1, 1, INT64_C(125911584000000000) },
+ { 400, 3, 1, INT64_C(125963424000000000) },
+ { 500, 1, 1, INT64_C(157469184000000000) },
+ { 500, 3, 1, INT64_C(157520160000000000) },
+ { 600, 1, 1, INT64_C(189025920000000000) },
+ { 600, 3, 1, INT64_C(189076896000000000) },
+ { 700, 1, 1, INT64_C(220582656000000000) },
+ { 700, 3, 1, INT64_C(220633632000000000) },
+ { 800, 1, 1, INT64_C(252139392000000000) },
+ { 800, 3, 1, INT64_C(252191232000000000) },
+ { 900, 1, 1, INT64_C(283696992000000000) },
+ { 900, 3, 1, INT64_C(283747968000000000) },
+ { 1000, 1, 1, INT64_C(315253728000000000) },
+ { 1000, 3, 1, INT64_C(315304704000000000) },
+ { 1100, 1, 1, INT64_C(346810464000000000) },
+ { 1100, 3, 1, INT64_C(346861440000000000) },
+ { 1200, 1, 1, INT64_C(378367200000000000) },
+ { 1200, 3, 1, INT64_C(378419040000000000) },
+ { 1300, 1, 1, INT64_C(409924800000000000) },
+ { 1300, 3, 1, INT64_C(409975776000000000) },
+ { 1400, 1, 1, INT64_C(441481536000000000) },
+ { 1400, 3, 1, INT64_C(441532512000000000) },
+ { 1500, 1, 1, INT64_C(473038272000000000) },
+ { 1500, 3, 1, INT64_C(473089248000000000) },
+ { 1600, 1, 1, INT64_C(504595008000000000) },
+ { 1600, 3, 1, INT64_C(504646848000000000) },
+ { 1700, 1, 1, INT64_C(536152608000000000) },
+ { 1700, 3, 1, INT64_C(536203584000000000) },
+ { 1800, 1, 1, INT64_C(567709344000000000) },
+ { 1800, 3, 1, INT64_C(567760320000000000) },
+ { 1900, 1, 1, INT64_C(599266080000000000) },
+ { 1900, 3, 1, INT64_C(599317056000000000) },
+ { 2000, 1, 1, INT64_C(630822816000000000) },
+ { 2000, 3, 1, INT64_C(630874656000000000) },
+ { 2100, 1, 1, INT64_C(662380416000000000) },
+ { 2100, 3, 1, INT64_C(662431392000000000) },
+ { 2200, 1, 1, INT64_C(693937152000000000) },
+ { 2200, 3, 1, INT64_C(693988128000000000) },
+ { 2300, 1, 1, INT64_C(725493888000000000) },
+ { 2300, 3, 1, INT64_C(725544864000000000) },
+ { 2400, 1, 1, INT64_C(757050624000000000) },
+ { 2400, 3, 1, INT64_C(757102464000000000) },
+ { 2500, 1, 1, INT64_C(788608224000000000) },
+ { 2500, 3, 1, INT64_C(788659200000000000) },
+ { 2600, 1, 1, INT64_C(820164960000000000) },
+ { 2600, 3, 1, INT64_C(820215936000000000) },
+ { 2700, 1, 1, INT64_C(851721696000000000) },
+ { 2700, 3, 1, INT64_C(851772672000000000) },
+ { 2800, 1, 1, INT64_C(883278432000000000) },
+ { 2800, 3, 1, INT64_C(883330272000000000) },
+ { 2900, 1, 1, INT64_C(914836032000000000) },
+ { 2900, 3, 1, INT64_C(914887008000000000) },
+ { 3000, 1, 1, INT64_C(946392768000000000) },
+ { 3000, 3, 1, INT64_C(946443744000000000) },
+ { 1, 1, 1, INT64_C(0) },
+ { 1601, 1, 1, INT64_C(504911232000000000) },
+ { 1899, 12, 31, INT64_C(599265216000000000) },
+ { 1904, 1, 1, INT64_C(600527520000000000) },
+ { 1970, 1, 1, INT64_C(621355968000000000) },
+ { 2001, 1, 1, INT64_C(631139040000000000) },
+ { 9900, 3, 1, INT64_C(3123873216000000000) },
+ { 9999, 12, 31, INT64_C(3155378112000000000) }
+};
+
+/*
+ * ICU's Universal Time Scale is designed to be tick-for-tick compatible with
+ * .Net System.DateTime. Verify that this is so for the
+ * .Net-supported date range (years 1-9999 AD).
+ * This requires a proleptic Gregorian calendar because that's what .Net uses.
+ * Proleptic: No Julian/Gregorian switchover, or a switchover before
+ * any date that we test, that is, before 0001 AD.
+ */
+static void
+TestDotNet() {
+ static const UChar utc[] = { 0x45, 0x74, 0x63, 0x2f, 0x47, 0x4d, 0x54, 0 }; /* "Etc/GMT" */
+ const int32_t dayMillis = 86400 * INT64_C(1000); /* 1 day = 86400 seconds */
+ const int64_t dayTicks = 86400 * INT64_C(10000000);
+ const DotNetDateTimeTicks *dt;
+ UCalendar *cal;
+ UErrorCode errorCode;
+ UDate icuDate;
+ int64_t ticks, millis;
+ int32_t i;
+
+ /* Open a proleptic Gregorian calendar. */
+ errorCode = U_ZERO_ERROR;
+ cal = ucal_open(utc, -1, "", UCAL_GREGORIAN, &errorCode);
+ ucal_setGregorianChange(cal, -1000000 * (dayMillis * (UDate)1), &errorCode);
+ if(U_FAILURE(errorCode)) {
+ log_err("ucal_open(UTC/proleptic Gregorian) failed: %s\n", u_errorName(errorCode));
+ ucal_close(cal);
+ return;
+ }
+ for(i = 0; i < LENGTHOF(dotNetDateTimeTicks); ++i) {
+ /* Test conversion from .Net/Universal time to ICU time. */
+ dt = dotNetDateTimeTicks + i;
+ millis = utmscale_toInt64(dt->ticks, UDTS_ICU4C_TIME, &errorCode);
+ ucal_clear(cal);
+ ucal_setDate(cal, dt->year, dt->month - 1, dt->day, &errorCode); /* Java & ICU use January = month 0. */
+ icuDate = ucal_getMillis(cal, &errorCode);
+ if(millis != icuDate) {
+ /* Print days not millis to stay within printf() range. */
+ log_err("utmscale_toInt64(ticks[%d], ICU4C)=%dd != %dd=ucal_getMillis(%04d-%02d-%02d)\n",
+ (int)i, (int)(millis/dayMillis), (int)(icuDate/dayMillis), (int)dt->year, (int)dt->month, (int)dt->day);
+ }
+
+ /* Test conversion from ICU time to .Net/Universal time. */
+ ticks = utmscale_fromInt64((int64_t)icuDate, UDTS_ICU4C_TIME, &errorCode);
+ if(ticks != dt->ticks) {
+ /* Print days not ticks to stay within printf() range. */
+ log_err("utmscale_fromInt64(date[%d], ICU4C)=%dd != %dd=.Net System.DateTime(%04d-%02d-%02d).Ticks\n",
+ (int)i, (int)(ticks/dayTicks), (int)(dt->ticks/dayTicks), (int)dt->year, (int)dt->month, (int)dt->day);
+ }
+ }
+
+ ucal_close(cal);
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */
diff --git a/Build/source/libs/icu-xetex/test/cintltst/utransts.c b/Build/source/libs/icu-xetex/test/cintltst/utransts.c
index b472fe16a62..ec99292aa9f 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/utransts.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/utransts.c
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 1997-2004, International Business Machines
+ * Copyright (C) 1997-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* Date Name Description
@@ -605,6 +605,7 @@ static void _expect(const UTransliterator* trans,
int32_t limit;
UTransPosition pos;
XReplaceable xrep;
+ XReplaceable *xrepPtr = &xrep;
UReplaceableCallbacks xrepVtable;
u_uastrcpy(from, cfrom);
@@ -659,7 +660,7 @@ static void _expect(const UTransliterator* trans,
InitXReplaceableCallbacks(&xrepVtable);
InitXReplaceable(&xrep, cfrom);
limit = u_strlen(from);
- utrans_trans(trans, (UReplaceable*)&xrep, &xrepVtable, 0, &limit, &status);
+ utrans_trans(trans, (UReplaceable*)xrepPtr, &xrepVtable, 0, &limit, &status);
if (U_FAILURE(status)) {
log_err("FAIL: utrans_trans() failed, error=%s\n",
u_errorName(status));
@@ -682,8 +683,8 @@ static void _expect(const UTransliterator* trans,
InitXReplaceable(&xrep, cfrom);
pos.start = pos.contextStart = 0;
pos.limit = pos.contextLimit = u_strlen(from);
- utrans_transIncremental(trans, (UReplaceable*)&xrep, &xrepVtable, &pos, &status);
- utrans_trans(trans, (UReplaceable*)&xrep, &xrepVtable, pos.start, &pos.limit, &status);
+ utrans_transIncremental(trans, (UReplaceable*)xrepPtr, &xrepVtable, &pos, &status);
+ utrans_trans(trans, (UReplaceable*)xrepPtr, &xrepVtable, pos.start, &pos.limit, &status);
if (U_FAILURE(status)) {
log_err("FAIL: utrans_transIncremental() failed, error=%s\n",
u_errorName(status));