From 8a69ab8bbac3795cd2684afee11603d1972230dc Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 29 Apr 2011 17:39:36 +0000 Subject: [PATCH] ICU-8154 update defines and add regression test X-SVN-Rev: 29925 --- icu4c/source/common/unicode/ushape.h | 10 +++--- icu4c/source/common/ushape.c | 4 +-- icu4c/source/test/cintltst/cbiditst.c | 48 +++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/icu4c/source/common/unicode/ushape.h b/icu4c/source/common/unicode/ushape.h index 6c3655f7a1a..52695fff6c8 100644 --- a/icu4c/source/common/unicode/ushape.h +++ b/icu4c/source/common/unicode/ushape.h @@ -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 diff --git a/icu4c/source/common/ushape.c b/icu4c/source/common/ushape.c index 05940bcf99b..5ed5c1d74ee 100644 --- a/icu4c/source/common/ushape.c +++ b/icu4c/source/common/ushape.c @@ -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; diff --git a/icu4c/source/test/cintltst/cbiditst.c b/icu4c/source/test/cintltst/cbiditst.c index f24a08797ed..9d82a1df4a7 100644 --- a/icu4c/source/test/cintltst/cbiditst.c +++ b/icu4c/source/test/cintltst/cbiditst.c @@ -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