diff --git a/icu4c/source/common/chariter.cpp b/icu4c/source/common/chariter.cpp index 1b2f76b1e63..20b10395a42 100644 --- a/icu4c/source/common/chariter.cpp +++ b/icu4c/source/common/chariter.cpp @@ -26,8 +26,8 @@ CharacterIterator::CharacterIterator(int32_t length, UTextOffset position) } } -CharacterIterator::CharacterIterator(int32_t length, UTextOffset begin, UTextOffset end, UTextOffset position) - : textLength(length), pos(position), begin(begin), end(end) { +CharacterIterator::CharacterIterator(int32_t length, UTextOffset textBegin, UTextOffset textEnd, UTextOffset position) + : textLength(length), pos(position), begin(textBegin), end(textEnd) { if(textLength < 0) { textLength = 0; } diff --git a/icu4c/source/common/unicode/chariter.h b/icu4c/source/common/unicode/chariter.h index a77902c8974..44d2faff174 100644 --- a/icu4c/source/common/unicode/chariter.h +++ b/icu4c/source/common/unicode/chariter.h @@ -523,7 +523,7 @@ protected: CharacterIterator() {} CharacterIterator(int32_t length); CharacterIterator(int32_t length, UTextOffset position); - CharacterIterator(int32_t length, UTextOffset begin, UTextOffset end, UTextOffset position); + CharacterIterator(int32_t length, UTextOffset textBegin, UTextOffset textEnd, UTextOffset position); CharacterIterator(const CharacterIterator &that); CharacterIterator &operator=(const CharacterIterator &that); diff --git a/icu4c/source/test/intltest/citrtest.cpp b/icu4c/source/test/intltest/citrtest.cpp index 3de47f8f056..535ede06b71 100644 --- a/icu4c/source/test/intltest/citrtest.cpp +++ b/icu4c/source/test/intltest/citrtest.cpp @@ -50,6 +50,13 @@ void CharIterTest::TestConstructionAndEquality() { CharacterIterator* test4 = new StringCharacterIterator(testText2); CharacterIterator* test5 = test1->clone(); + if (test1d->startIndex() < 0) + errln("Construction failed: startIndex is negative"); + if (test1d->endIndex() > testText.length()) + errln("Construction failed: endIndex is greater than the text length"); + if (test1d->getIndex() < test1d->startIndex() || test1d->endIndex() < test1d->getIndex()) + errln("Construction failed: startIndex is negative"); + if (*test1 == *test2 || *test1 == *test3 || *test1 == *test4) errln("Construction or operator== failed: Unequal objects compared equal"); if (*test1 != *test5)