ICU-8154 update defines and add regression test

X-SVN-Rev: 29925
This commit is contained in:
Steven R. Loomis 2011-04-29 17:39:36 +00:00
parent bb9af46cfe
commit 8a69ab8bba
3 changed files with 55 additions and 7 deletions

View file

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 2000-2010, International Business Machines
* Copyright (C) 2000-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -461,14 +461,14 @@ u_shapeArabic(const UChar *source, int32_t sourceLength,
* Shaping Mode: Only shaping.
* De-shaping Mode: N/A.
* Affects: All Seen options
* @draft ICU 4.2
* @draft ICU 4.8
*/
#define SHAPE_TAIL_NEW_UNICODE 0x8000000
#define U_SHAPE_TAIL_NEW_UNICODE 0x8000000
/**
* Bit mask for new Unicode Tail option
* @draft ICU 4.2
* @draft ICU 4.8
*/
#define SHAPE_TAIL_TYPE_MASK 0x8000000
#define U_SHAPE_TAIL_TYPE_MASK 0x8000000
#endif

View file

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 2000-2010, International Business Machines
* Copyright (C) 2000-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -1469,7 +1469,7 @@ u_shapeArabic(const UChar *source, int32_t sourceLength,
}
/* Does Options contain the new Seen Tail Unicode code point option */
if ( (options&SHAPE_TAIL_TYPE_MASK) == SHAPE_TAIL_NEW_UNICODE){
if ( (options&U_SHAPE_TAIL_TYPE_MASK) == U_SHAPE_TAIL_NEW_UNICODE){
tailChar = NEW_TAIL_CHAR;
}else {
tailChar = OLD_TAIL_CHAR;

View file

@ -76,6 +76,8 @@ static void testGetBaseDirection(void);
static void testContext(void);
static void doTailTest(void);
/* new BIDI API */
static void testReorderingMode(void);
static void testReorderRunsOnly(void);
@ -128,6 +130,7 @@ addComplexTest(TestNode** root) {
addTest(root, doTashkeelSpecialVLTRArabicShapingTest, "complex/arabic-shaping/tashkeel");
addTest(root, doLOGICALArabicDeShapingTest, "complex/arabic-shaping/unshaping");
addTest(root, doArabicShapingTestForBug5421, "complex/arabic-shaping/bug-5421");
addTest(root, doTailTest, "complex/arabic-shaping/tailtest");
}
static void
@ -2762,6 +2765,51 @@ doLOGICALArabicDeShapingTest(void) {
}
static void
doTailTest(void) {
static const UChar src[] = { 0x0020, 0x0633, 0 };
static const UChar dst_old[] = { 0xFEB1, 0x200B,0 };
static const UChar dst_new[] = { 0xFEB1, 0xFE73,0 };
UChar dst[3] = { 0x0000, 0x0000,0 };
int32_t length;
UErrorCode status;
log_verbose("SRC: U+%04X U+%04X\n", src[0],src[1]);
log_verbose("Trying old tail\n");
status = U_ZERO_ERROR;
length = u_shapeArabic(src, -1, dst, LENGTHOF(dst),
U_SHAPE_LETTERS_SHAPE|U_SHAPE_SEEN_TWOCELL_NEAR, &status);
if(U_FAILURE(status)) {
log_err("Fail: status %s\n", u_errorName(status));
} else if(length!=2) {
log_err("Fail: len %d expected 3\n", length);
} else if(u_strncmp(dst,dst_old,LENGTHOF(dst))) {
log_err("Fail: got U+%04X U+%04X expected U+%04X U+%04X\n",
dst[0],dst[1],dst_old[0],dst_old[1]);
} else {
log_verbose("OK: U+%04X U+%04X len %d err %s\n",
dst[0],dst[1],length,u_errorName(status));
}
log_verbose("Trying new tail\n");
status = U_ZERO_ERROR;
length = u_shapeArabic(src, -1, dst, LENGTHOF(dst),
U_SHAPE_LETTERS_SHAPE|U_SHAPE_SEEN_TWOCELL_NEAR|U_SHAPE_TAIL_NEW_UNICODE, &status);
if(U_FAILURE(status)) {
log_err("Fail: status %s\n", u_errorName(status));
} else if(length!=2) {
log_err("Fail: len %d expected 3\n", length);
} else if(u_strncmp(dst,dst_new,LENGTHOF(dst))) {
log_err("Fail: got U+%04X U+%04X expected U+%04X U+%04X\n",
dst[0],dst[1],dst_new[0],dst_new[1]);
} else {
log_verbose("OK: U+%04X U+%04X len %d err %s\n",
dst[0],dst[1],length,u_errorName(status));
}
}
static void
doArabicShapingTestForBug5421(void) {
static const UChar