ICU-3094 fixed setOffset(0) error

X-SVN-Rev: 12608
This commit is contained in:
Syn Wee Quek 2003-07-09 23:16:04 +00:00
parent 8c0145ac8e
commit 5dc7d189e3
4 changed files with 27 additions and 3 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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);

View file

@ -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);