ICU-3170 cope with bidi class changes for +-/ in Unicode 4.0.1

X-SVN-Rev: 14860
This commit is contained in:
Markus Scherer 2004-04-05 18:06:41 +00:00
parent 853a991c48
commit c2ef9b9084
3 changed files with 45 additions and 4 deletions

View File

@ -23,7 +23,7 @@ dirPropNames[dirPropCount]={
"LRE", "LRO", "AL", "RLE", "RLO", "PDF", "NSM", "BN"
};
const UChar
UChar
charFromDirProp[dirPropCount]={
/* L R EN ES ET AN CS B S WS ON */
0x61, 0x5d0, 0x30, 0x2f, 0x25, 0x660, 0x2c, 0xa, 0x9, 0x20, 0x26,

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2003, International Business Machines Corporation and
* Copyright (c) 1997-2004, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* file name: cbiditst.cpp
@ -26,6 +26,9 @@
/* prototypes ---------------------------------------------------------------*/
static void
charFromDirPropTest(void);
static void
doBiDiTest(void);
@ -68,6 +71,9 @@ static void TestReorder(void);
static const char *levelString="...............................................................";
static void
initCharFromDirProps(void);
static UChar *
getStringFromDirProps(const uint8_t *dirProps, int32_t length);
@ -80,6 +86,7 @@ void addComplexTest(TestNode** root);
void
addComplexTest(TestNode** root) {
addTest(root, charFromDirPropTest, "complex/bidi/charFromDirPropTest");
addTest(root, doBiDiTest, "complex/bidi/BiDiTest");
addTest(root, doInverseBiDiTest, "complex/bidi/inverse");
addTest(root, TestReorder,"complex/bidi/TestReorder");
@ -89,6 +96,21 @@ addComplexTest(TestNode** root) {
addTest(root, doLOGICALArabicDeShapingTest, "complex/arabic-shaping/unshaping");
}
/* verify that the exemplar characters have the expected bidi classes */
static void
charFromDirPropTest(void) {
int32_t i;
initCharFromDirProps();
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\n",
i, charFromDirProp[i], i);
}
}
}
static void
doBiDiTest() {
UBiDi *pBiDi, *pLine=NULL;
@ -1352,12 +1374,31 @@ doLOGICALArabicDeShapingTest() {
/* helpers ------------------------------------------------------------------ */
static void
initCharFromDirProps() {
static const UVersionInfo ucd401={ 4, 0, 1, 0 };
static UVersionInfo ucdVersion={ 0, 0, 0, 0 };
/* lazy initialization */
if(ucdVersion[0]>0) {
return;
}
u_getUnicodeVersion(ucdVersion);
if(memcmp(ucdVersion, ucd401, sizeof(UVersionInfo))>0) {
/* Unicode 4.0.1 changes bidi classes for +-/ */
charFromDirProp[U_EUROPEAN_NUMBER_SEPARATOR]=0x2b; /* change ES character from / to + */
}
}
/* 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];
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]];

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2001, International Business Machines Corporation and
* Copyright (c) 1997-2004, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* file name: cbiditst.h
@ -58,7 +58,7 @@ enum {
extern const char *
dirPropNames[dirPropCount];
extern const UChar
extern UChar
charFromDirProp[dirPropCount];
typedef struct {