ICU-2189 eliminate duplicates in add(string)

X-SVN-Rev: 9815
This commit is contained in:
Alan Liu 2002-08-29 04:58:00 +00:00
parent 3325f6a02b
commit ae8bbc8773
2 changed files with 11 additions and 2 deletions

View file

@ -1068,8 +1068,10 @@ UnicodeSet& UnicodeSet::add(const UnicodeString& s) {
if (s.length() == 0) return *this;
int32_t cp = getSingleCP(s);
if (cp < 0) {
_add(s);
pat.truncate(0);
if (!strings->contains((void*) &s)) {
_add(s);
pat.truncate(0);
}
} else {
add((UChar32)cp, (UChar32)cp);
}

View file

@ -579,6 +579,13 @@ void UnicodeSetTest::TestStringPatterns() {
const char* exp5[] = {"\\u4E01\\u4E02", "\n\r", NULL};
expectToPattern(*s, "[a-z{\\u4E01\\u4E02}{\\n\\r}]", exp5);
// j2189
s->clear();
s->add(UnicodeString("abc", ""));
s->add(UnicodeString("abc", ""));
const char* exp6[] = {"abc", NOT, "ab", NULL};
expectToPattern(*s, "[{abc}]", exp6);
break;
}