mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 22:15:31 +00:00
ICU-3944 work in progress
X-SVN-Rev: 17880
This commit is contained in:
parent
e712baf4af
commit
452456c2b3
5 changed files with 73 additions and 14 deletions
|
@ -50,8 +50,8 @@
|
|||
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/rep.h"
|
||||
#ifdef XP_CPLUSPLUS
|
||||
#include "unicode/rep.h"
|
||||
#include "unicode/unistr.h"
|
||||
#endif
|
||||
|
||||
|
@ -543,9 +543,9 @@ utext_extract(UText *ut,
|
|||
* @draft ICU 3.4
|
||||
*/
|
||||
#define UTEXT_NEXT32FROM(ut, index) \
|
||||
((index) >= (ut)->start && \
|
||||
(index) < (ut)->limit && \
|
||||
(ut)->chunk.UTF16Indexes && \
|
||||
((index) >= (ut)->chunk.start && \
|
||||
(index) < (ut)->chunk.limit && \
|
||||
!(ut)->chunk.nonUTF16Indexes && \
|
||||
(ut)->chunk.contents[(ut)->chunk.offset=(ut)->chunk.start+(index)] < 0xd800 ? \
|
||||
(ut)->chunk.contents[((ut)->chunk.offset)++] : utext_next32From(ut, index))
|
||||
|
||||
|
@ -559,11 +559,11 @@ utext_extract(UText *ut,
|
|||
* @draft ICU 3.4
|
||||
*/
|
||||
#define UTEXT_PREVIOUS32FROM(ut, index) \
|
||||
((index) > (ut)->start && \
|
||||
(index) <= (ut)->limit && \
|
||||
(ut)->chunk.UTF16Indexes && \
|
||||
((index) > (ut)->chunk.start && \
|
||||
(index) <= (ut)->chunk.limit && \
|
||||
!(ut)->chunk.nonUTF16Indexes && \
|
||||
(ut)->chunk.contents[(ut)->chunk.offset=(ut)->chunk.start+(index-1)] < 0xd800 ? \
|
||||
(ut)->chunk.contents[--((ut)->chunk.offset)] : utext_previous32From(ut, index))
|
||||
(ut)->chunk.contents[(ut)->chunk.offset] : utext_previous32From(ut, index))
|
||||
|
||||
|
||||
|
||||
|
@ -1255,7 +1255,7 @@ enum {
|
|||
NULL, /* copy () */ \
|
||||
NULL, NULL, /* map * 2 () */ \
|
||||
NULL /* close () */ \
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
U_CDECL_END
|
||||
|
|
|
@ -52,7 +52,7 @@ cucdapi.o cucdtst.o custrtst.o cstrcase.o cutiltst.o nucnvtst.o nccbtst.o bocu1t
|
|||
cbiditst.o cbididat.o eurocreg.o udatatst.o utf16tst.o utransts.o \
|
||||
ncnvfbts.o ncnvtst.o putiltst.o cstrtest.o utf8tst.o ucmptst.o \
|
||||
stdnmtst.o ctstdep.o usrchtst.o custrtrn.o sorttest.o trietest.o usettest.o uenumtst.o utmstest.o \
|
||||
idnatest.o nfsprep.o spreptst.o sprpdata.o hpmufn.o tracetst.o reapits.o
|
||||
idnatest.o nfsprep.o spreptst.o sprpdata.o hpmufn.o tracetst.o reapits.o utexttst.o
|
||||
|
||||
DEPS = $(OBJECTS:.o=.d)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1996-2004, International Business Machines Corporation and
|
||||
* Copyright (c) 1996-2005, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
|
@ -37,6 +37,8 @@ void addIDNATest(TestNode** root);
|
|||
void addHeapMutexTest(TestNode **root);
|
||||
void addUTraceTest(TestNode** root);
|
||||
void addURegexTest(TestNode** root);
|
||||
void addUTextTest(TestNode** root);
|
||||
|
||||
|
||||
void addAllTests(TestNode** root)
|
||||
{
|
||||
|
@ -73,5 +75,6 @@ void addAllTests(TestNode** root)
|
|||
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
|
||||
addURegexTest(root);
|
||||
#endif
|
||||
addUTextTest(root);
|
||||
}
|
||||
|
||||
|
|
|
@ -342,9 +342,6 @@
|
|||
<Filter
|
||||
Name="formatting"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\calltest.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ccaltst.c">
|
||||
</File>
|
||||
|
@ -428,6 +425,9 @@
|
|||
<Filter
|
||||
Name="misc"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\calltest.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cintltst.c">
|
||||
</File>
|
||||
|
@ -494,6 +494,9 @@
|
|||
<File
|
||||
RelativePath=".\custrtst.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\utexttst.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\utf16tst.c">
|
||||
</File>
|
||||
|
|
|
@ -221,6 +221,33 @@ void UTextTest::TestAccess(const UnicodeString &us, UText *ut, int cpCount, m *c
|
|||
foundIndex = utext_getIndex(ut);
|
||||
TEST_ASSERT(foundIndex == 0);
|
||||
|
||||
foundC = utext_previous32(ut);
|
||||
TEST_ASSERT(foundC == U_SENTINEL);
|
||||
foundIndex = utext_getIndex(ut);
|
||||
TEST_ASSERT(foundIndex == 0);
|
||||
|
||||
|
||||
// And again, with the macros
|
||||
utext_setIndex(ut, len);
|
||||
for (i=cpCount-1; i>=0; i--) {
|
||||
expectedC = cpMap[i].cp;
|
||||
expectedIndex = cpMap[i].nativeIdx;
|
||||
foundC = UTEXT_PREVIOUS32(ut);
|
||||
foundIndex = utext_getIndex(ut);
|
||||
TEST_ASSERT(expectedIndex == foundIndex);
|
||||
TEST_ASSERT(expectedC == foundC);
|
||||
if (gFailed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Backwards iteration, above, should have left our iterator
|
||||
// position at zero, and continued backwards iterationshould fail.
|
||||
//
|
||||
foundIndex = utext_getIndex(ut);
|
||||
TEST_ASSERT(foundIndex == 0);
|
||||
|
||||
foundC = utext_previous32(ut);
|
||||
TEST_ASSERT(foundC == U_SENTINEL);
|
||||
foundIndex = utext_getIndex(ut);
|
||||
|
@ -258,6 +285,32 @@ void UTextTest::TestAccess(const UnicodeString &us, UText *ut, int cpCount, m *c
|
|||
}
|
||||
}
|
||||
|
||||
cpIndex = 0;
|
||||
for (i=0; i<cpCount; i++) {
|
||||
cpIndex = (cpIndex + 9973) % cpCount;
|
||||
index = cpMap[cpIndex].nativeIdx;
|
||||
expectedC = cpMap[cpIndex].cp;
|
||||
foundC = UTEXT_NEXT32FROM(ut, index);
|
||||
TEST_ASSERT(expectedC == foundC);
|
||||
TEST_ASSERT(expectedIndex == foundIndex);
|
||||
if (gFailed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cpIndex = 0;
|
||||
for (i=0; i<cpCount; i++) {
|
||||
cpIndex = (cpIndex + 9973) % cpCount;
|
||||
index = cpMap[cpIndex+1].nativeIdx;
|
||||
expectedC = cpMap[cpIndex].cp;
|
||||
foundC = UTEXT_PREVIOUS32FROM(ut, index);
|
||||
TEST_ASSERT(expectedC == foundC);
|
||||
TEST_ASSERT(expectedIndex == foundIndex);
|
||||
if (gFailed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// moveIndex(int32_t delta);
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue