mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-16 10:17:23 +00:00
ICU-3094 fixed setOffset(0) error
X-SVN-Rev: 12608
This commit is contained in:
parent
8c0145ac8e
commit
5dc7d189e3
4 changed files with 27 additions and 3 deletions
|
@ -98,8 +98,7 @@ UBool CollationElementIterator::operator==(
|
|||
}
|
||||
|
||||
// option comparison
|
||||
if (!(m_data_->reset_ == that.m_data_->reset_
|
||||
&& m_data_->iteratordata_.coll == that.m_data_->iteratordata_.coll))
|
||||
if (m_data_->iteratordata_.coll != that.m_data_->iteratordata_.coll)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -243,6 +243,7 @@ ucol_setOffset(UCollationElements *elems,
|
|||
ci->flags |= UCOL_ITER_HASLEN;
|
||||
}
|
||||
ci->fcdPosition = NULL;
|
||||
elems->reset_ = FALSE;
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
|
|
|
@ -578,6 +578,19 @@ static void TestOffset()
|
|||
ucol_close(en_us);
|
||||
return;
|
||||
}
|
||||
|
||||
/* testing boundaries */
|
||||
ucol_setOffset(iter, 0, &status);
|
||||
if (U_FAILURE(status) || ucol_previous(iter, &status) != UCOL_NULLORDER) {
|
||||
log_err("Error: After setting offset to 0, we should be at the end "
|
||||
"of the backwards iteration");
|
||||
}
|
||||
ucol_setOffset(iter, u_strlen(test1), &status);
|
||||
if (U_FAILURE(status) || ucol_next(iter, &status) != UCOL_NULLORDER) {
|
||||
log_err("Error: After setting offset to end of the string, we should "
|
||||
"be at the end of the backwards iteration");
|
||||
}
|
||||
|
||||
/* Run all the way through the iterator, then get the offset */
|
||||
|
||||
orders = getOrders(iter, &orderLength);
|
||||
|
|
|
@ -173,6 +173,18 @@ void CollationIteratorTest::TestPrevious(/* char* par */)
|
|||
void CollationIteratorTest::TestOffset(/* char* par */)
|
||||
{
|
||||
CollationElementIterator *iter = en_us->createCollationElementIterator(test1);
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
// testing boundaries
|
||||
iter->setOffset(0, status);
|
||||
if (U_FAILURE(status) || iter->previous(status) != UCOL_NULLORDER) {
|
||||
errln("Error: After setting offset to 0, we should be at the end "
|
||||
"of the backwards iteration");
|
||||
}
|
||||
iter->setOffset(test1.length(), status);
|
||||
if (U_FAILURE(status) || iter->next(status) != UCOL_NULLORDER) {
|
||||
errln("Error: After setting offset to end of the string, we should "
|
||||
"be at the end of the backwards iteration");
|
||||
}
|
||||
|
||||
// Run all the way through the iterator, then get the offset
|
||||
int32_t orderLength = 0;
|
||||
|
@ -190,7 +202,6 @@ void CollationIteratorTest::TestOffset(/* char* par */)
|
|||
|
||||
// Now set the offset back to the beginning and see if it works
|
||||
CollationElementIterator *pristine = en_us->createCollationElementIterator(test1);
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
iter->setOffset(0, status);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue