ICU-2761 make UnicodeString::extractBetween() pin properly
X-SVN-Rev: 15179
This commit is contained in:
parent
714e26a455
commit
01889c4280
@ -3748,8 +3748,11 @@ inline void
|
||||
UnicodeString::extractBetween(int32_t start,
|
||||
int32_t limit,
|
||||
UChar *dst,
|
||||
int32_t dstStart) const
|
||||
{ doExtract(start, limit - start, dst, dstStart); }
|
||||
int32_t dstStart) const {
|
||||
pinIndex(start);
|
||||
pinIndex(limit);
|
||||
doExtract(start, limit - start, dst, dstStart);
|
||||
}
|
||||
|
||||
inline UChar
|
||||
UnicodeString::doCharAt(int32_t offset) const
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1999-2003, International Business Machines Corporation and *
|
||||
* Copyright (C) 1999-2004, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*
|
||||
@ -1621,8 +1621,11 @@ UnicodeString::extract(char *dest, int32_t destCapacity,
|
||||
void
|
||||
UnicodeString::extractBetween(int32_t start,
|
||||
int32_t limit,
|
||||
UnicodeString& target) const
|
||||
{ doExtract(start, limit - start, target); }
|
||||
UnicodeString& target) const {
|
||||
pinIndex(start);
|
||||
pinIndex(limit);
|
||||
doExtract(start, limit - start, target);
|
||||
}
|
||||
|
||||
int32_t
|
||||
UnicodeString::doExtract(int32_t start, int32_t length,
|
||||
|
@ -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.
|
||||
********************************************************************/
|
||||
|
||||
@ -440,6 +440,13 @@ UnicodeStringTest::TestExtract()
|
||||
if (test1.extract(11, 12, test4) != 12 || test4[12] != 0) {
|
||||
errln("UnicodeString.extract(char *) failed to return the correct size of destination buffer.");
|
||||
}
|
||||
|
||||
// test proper pinning in extractBetween()
|
||||
test1.extractBetween(-3, 7, test5);
|
||||
if(test5!=UNICODE_STRING("Now is ", 7)) {
|
||||
errln("UnicodeString.extractBetween(-3, 7) did not pin properly.");
|
||||
}
|
||||
|
||||
test1.extractBetween(11, 23, test5);
|
||||
if (test1.extract(60, 71, test6) != 9) {
|
||||
errln("UnicodeString.extract() failed to return the correct size of destination buffer for end of buffer.");
|
||||
|
Loading…
Reference in New Issue
Block a user