mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-2189 eliminate duplicates in add(string)
X-SVN-Rev: 9815
This commit is contained in:
parent
3325f6a02b
commit
ae8bbc8773
2 changed files with 11 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue