• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/ICU-531.30/icuSources/test/intltest/

Lines Matching refs:set

36 UnicodeString operator+(const UnicodeString& left, const UnicodeSet& set) {
38 set.toPattern(pat);
263 UnicodeSet set;
264 expectPattern(set, UnicodeString("[[a-m]&[d-z]&[k-y]]", ""), "km");
265 expectPattern(set, UnicodeString("[[a-z]-[m-y]-[d-r]]", ""), "aczz");
266 expectPattern(set, UnicodeString("[a\\-z]", ""), "--aazz");
267 expectPattern(set, UnicodeString("[-az]", ""), "--aazz");
268 expectPattern(set, UnicodeString("[az-]", ""), "--aazz");
269 expectPattern(set, UnicodeString("[[[a-z]-[aeiou]i]]", ""), "bdfnptvz");
272 set.complement();
275 expectPairs(set, exp);
282 UnicodeSet set(pat, status);
284 dataerrln((UnicodeString)"Fail: Can't construct set with " + pat + " - " + UnicodeString(u_errorName(status)));
287 expectContainment(set, pat, "ABC", "abc");
292 // Make sure generation of L doesn't pollute cached Lu set
294 set.applyPattern("[:L:]", status);
298 if (l != set.contains(i)) {
300 set.contains(i));
305 set.applyPattern("[:Lu:]", status);
309 if (lu != set.contains(i)) {
311 set.contains(i));
325 dataerrln((UnicodeString)"FAIL: Can't construst set with category->Ll" + " - " + UnicodeString(u_errorName(status)));
331 errln((UnicodeString)"FAIL: Can't construct set with category->Nd");
389 UnicodeSet set; // Construct empty set
390 doAssert(set.isEmpty() == TRUE, "set should be empty");
391 doAssert(set.size() == 0, "size should be 0");
392 set.complement();
393 doAssert(set.size() == 0x110000, "size should be 0x110000");
394 set.clear();
395 set.add(0x0061, 0x007a);
396 expectPairs(set, "az");
397 doAssert(set.isEmpty() == FALSE, "set should not be empty");
398 doAssert(set.size() != 0, "size should not be equal to 0");
399 doAssert(set.size() == 26, "size should be equal to 26");
400 set.remove(0x006d, 0x0070);
401 expectPairs(set, "alqz");
402 doAssert(set.size() == 22, "size should be equal to 22");
403 set.remove(0x0065, 0x0067);
404 expectPairs(set, "adhlqz");
405 doAssert(set.size() == 19, "size should be equal to 19");
406 set.remove(0x0064, 0x0069);
407 expectPairs(set, "acjlqz");
408 doAssert(set.size() == 16, "size should be equal to 16");
409 set.remove(0x0063, 0x0072);
410 expectPairs(set, "absz");
411 doAssert(set.size() == 10, "size should be equal to 10");
412 set.add(0x0066, 0x0071);
413 expectPairs(set, "abfqsz");
414 doAssert(set.size() == 22, "size should be equal to 22");
415 set.remove(0x0061, 0x0067);
416 expectPairs(set, "hqsz");
417 set.remove(0x0061, 0x007a);
418 expectPairs(set, "");
419 doAssert(set.isEmpty() == TRUE, "set should be empty");
420 doAssert(set.size() == 0, "size should be 0");
421 set.add(0x0061);
422 doAssert(set.isEmpty() == FALSE, "set should not be empty");
423 doAssert(set.size() == 1, "size should not be equal to 1");
424 set.add(0x0062);
425 set.add(0x0063);
426 expectPairs(set, "ac");
427 doAssert(set.size() == 3, "size should not be equal to 3");
428 set.add(0x0070);
429 set.add(0x0071);
430 expectPairs(set, "acpq");
431 doAssert(set.size() == 5, "size should not be equal to 5");
432 set.clear();
433 expectPairs(set, "");
434 doAssert(set.isEmpty() == TRUE, "set should be empty");
435 doAssert(set.size() == 0, "size should be 0");
437 // Try removing an entire set from another set
438 expectPattern(set, "[c-x]", "cx");
441 set.removeAll(set2);
442 expectPairs(set, "deluxx");
444 // Try adding an entire set to another set
445 expectPattern(set, "[jackiemclean]", "aacceein");
447 set.addAll(set2);
448 expectPairs(set, "aacehort");
449 doAssert(set.containsAll(set2) == TRUE, "set should contain all the elements in set2");
451 // Try retaining an set of elements contained in another set (intersection)
454 doAssert(set.containsAll(set3) == FALSE, "set doesn't contain all the elements in set3");
457 doAssert(set.containsAll(set3) == TRUE, "set should contain all the elements in set3");
458 set.retainAll(set3);
459 expectPairs(set, "aacc");
460 doAssert(set.size() == set3.size(), "set.size() should be set3.size()");
461 doAssert(set.containsAll(set3) == TRUE, "set should contain all the elements in set3");
462 set.clear();
463 doAssert(set.size() != set3.size(), "set.size() != set3.size()");
466 expectPattern(set, "[hitoshinamekatajamesanderson]", "aadehkmort");
468 set.addAll(set2);
469 expectPairs(set, "aacehort");
470 doAssert(set.containsAll(set2) == TRUE, "set should contain all the elements in set2");
487 UnicodeSet set("[h-km-q]", status);
491 set.addAll(set2);
492 expectPairs(set, "hq");
494 set.applyPattern("[a-m]", status);
498 set.addAll(set2);
499 expectPairs(set, "ao");
501 set.applyPattern("[e-o]", status);
505 set.addAll(set2);
506 expectPairs(set, "ao");
508 set.applyPattern("[a-eg-mo-w]", status);
512 set.addAll(set2);
513 expectPairs(set, "aw");
519 UnicodeSet set;
520 if (!set.isEmpty() || set.getRangeCount() != 0) {
521 errln((UnicodeString)"FAIL, set should be empty but isn't: " +
522 set);
526 set.add(0x0061);
527 if (set.isEmpty()) {
528 errln((UnicodeString)"FAIL, set shouldn't be empty but is: " +
529 set);
531 set.clear();
532 if (!set.isEmpty()) {
533 errln((UnicodeString)"FAIL, set should be empty but isn't: " +
534 set);
538 set.clear();
539 if (set.size() != 0) {
540 errln((UnicodeString)"FAIL, size should be 0, but is " + set.size() +
541 ": " + set);
543 set.add(0x0061);
544 if (set.size() != 1) {
545 errln((UnicodeString)"FAIL, size should be 1, but is " + set.size() +
546 ": " + set);
548 set.add(0x0031, 0x0039);
549 if (set.size() != 10) {
550 errln((UnicodeString)"FAIL, size should be 10, but is " + set.size() +
551 ": " + set);
555 set.clear();
556 set.applyPattern("[A-Y 1-8 b-d l-y]", status);
558 for (int32_t i = 0; i<set.getRangeCount(); ++i) {
559 UChar32 a = set.getRangeStart(i);
560 UChar32 b = set.getRangeEnd(i);
561 if (!set.contains(a, b)) {
563 " but doesn't: " + set);
565 if (set.contains((UChar32)(a-1), b)) {
568 " but does: " + set);
570 if (set.contains(a, (UChar32)(b+1))) {
573 " but does: " + set);
588 logln((UnicodeString)"c.set(a).add(b): " + c);
590 errln((UnicodeString)"FAIL: c.set(a).add(b) = " + c + ", expect " + exp);
593 exp.set((UChar32)0, (UChar32)2);
601 exp.set((UChar32)3, (UChar32)15);
609 exp.set((UChar32)3,(UChar32)6);
612 logln((UnicodeString)"c.set(a).exclusiveOr(b): " + c);
614 errln((UnicodeString)"FAIL: c.set(a).exclusiveOr(b) = " + c + ", expect " + exp);
637 set.clear();
638 set.complement("ab");
641 if (set != exp) { errln("FAIL: complement(\"ab\")"); return; }
643 UnicodeSetIterator iset(set);
650 set.add((UChar32)0x61, (UChar32)0x7A);
651 set.complementAll("alan");
654 if (set != exp) { errln("FAIL: complementAll(\"alan\")"); return; }
658 if (set.containsNone(exp)) { errln("FAIL: containsNone(UnicodeSet)"); }
659 if (!set.containsSome(exp)) { errln("FAIL: containsSome(UnicodeSet)"); }
662 if (!set.containsNone(exp)) { errln("FAIL: containsNone(UnicodeSet)"); }
663 if (set.containsSome(exp)) { errln("FAIL: containsSome(UnicodeSet)"); }
665 if (set.containsNone((UChar32)0x61, (UChar32)0x7A)) {
668 if (!set.containsSome((UChar32)0x61, (UChar32)0x7A)) {
671 if (!set.containsNone((UChar32)0x41, (UChar32)0x5A)) {
674 if (set.containsSome((UChar32)0x41, (UChar32)0x5A)) {
678 set.removeAll("liu");
681 if (set != exp) { errln("FAIL: removeAll(\"liu\")"); return; }
683 set.retainAll("star");
686 if (set != exp) { errln("FAIL: retainAll(\"star\")"); return; }
688 set.retain((UChar32)0x73);
691 if (set != exp) { errln("FAIL: retain('s')"); return; }
694 int32_t slen = set.serialize(buf, sizeof(buf)/sizeof(buf[0]), status);
702 UnicodeSet *uniset = &set;
752 UnicodeSet set(UNICODE_STRING_SIMPLE("[zabyc\\U0001abcd{str1}{str2}]"), ec);
754 UnicodeSetIterator it(set);
1179 UnicodeSet set("[a-cx-y3578]", ec);
1184 for (int32_t i=0; i<set.size(); ++i) {
1185 UChar32 c = set.charAt(i);
1186 if (set.indexOf(c) != i) {
1188 i, c, set.indexOf(c));
1191 UChar32 c = set.charAt(set.size());
1195 int32_t j = set.indexOf((UChar32)0x71/*'q'*/);
1402 UnicodeSet set(pat, ec);
1412 if (set.contains((UChar)0x0644)){
1417 set.toPattern(newpat, TRUE);
1424 for (int32_t i=0; i<set.getRangeCount(); ++i) {
1428 .append((UChar32)set.getRangeStart(i))
1430 .append((UChar32)set.getRangeEnd(i));
1431 str = str + " (" + set.getRangeStart(i) + " - " +
1432 set.getRangeEnd(i) + ")";
1433 if (set.getRangeStart(i) < 0) {
1443 const UnicodeSet& set,
1447 if (set == exp) {
1448 logln(label + " => " + set.toPattern(pat, TRUE));
1452 set.toPattern(pat, TRUE) +
1478 UnicodeSet set(start, end);
1480 set, xstart, xend);
1482 set.clear();
1483 set.set(start, end);
1484 expectRange((UnicodeString)"set(" + start + "," + end + ")",
1485 set, xstart, xend);
1487 UBool b = set.contains(start);
1488 b = set.contains(start, end);
1489 b = set.containsNone(start, end);
1490 b = set.containsSome(start, end);
1491 (void)b; // Suppress set but not used warning.
1493 /*int32_t index = set.indexOf(start);*/
1495 set.clear();
1496 set.add(start);
1497 set.add(start, end);
1499 set, xstart, xend);
1501 set.set(0, 0x10FFFF);
1502 set.retain(start, end);
1504 set, xstart, xend);
1505 set.retain(start);
1507 set.set(0, 0x10FFFF);
1508 set.remove(start);
1509 set.remove(start, end);
1510 set.complement();
1512 set, xstart, xend);
1514 set.set(0, 0x10FFFF);
1515 set.complement(start, end);
1516 set.complement();
1518 set, xstart, xend);
1519 set.complement(start);
1534 UnicodeSet set(0, 0x10FFFF);
1537 UBool b = set.contains(c);
1548 b = set.contains(c, end);
1552 b = set.containsNone(c, end);
1556 b = set.containsSome(c, end);
1560 int32_t index = set.indexOf(c);
1632 // Multiple test cases can be set up here. Each test case
1707 UnicodeSet set(str, ec);
1712 expectContainment(set,
1715 if (set.size() != 4) {
1717 set.size() + ", expected 4");
1815 void UnicodeSetTest::checkCanonicalRep(const UnicodeSet& set, const UnicodeString& msg) {
1816 int32_t n = set.getRangeCount();
1820 n /*+ " for " + set.toPattern())*/);
1825 UChar32 start = set.getRangeStart(i);
1826 UChar32 end = set.getRangeEnd(i);
1831 " for " + set);
1837 " for " + set);
1873 * For example, the set [a-zA-M3] is represented as "33AMaz".
1875 UnicodeString UnicodeSetTest::getPairs(const UnicodeSet& set) {
1877 for (int32_t i=0; i<set.getRangeCount(); ++i) {
1878 UChar32 start = set.getRangeStart(i);
1879 UChar32 end = set.getRangeEnd(i);
1882 i = set.getRangeCount(); // Should be unnecessary
1973 UnicodeSet set(pat, ec);
1979 expectContainment(set, pat, charsIn, charsOut);
1983 UnicodeSetTest::expectContainment(const UnicodeSet& set,
1987 set.toPattern(pat);
1988 expectContainment(set, pat, charsIn, charsOut);
1992 UnicodeSetTest::expectContainment(const UnicodeSet& set,
2002 if (!set.contains(c)) {
2007 errln((UnicodeString)"Fail: set " + setName + " does not contain " + prettify(bad) +
2010 logln((UnicodeString)"Ok: set " + setName + " contains " + prettify(charsIn));
2016 if (set.contains(c)) {
2021 errln((UnicodeString)"Fail: set " + setName + " contains " + prettify(bad) +
2024 logln((UnicodeString)"Ok: set " + setName + " does not contain " + prettify(charsOut));
2029 UnicodeSetTest::expectPattern(UnicodeSet& set,
2033 set.applyPattern(pattern, status);
2039 if (getPairs(set) != expectedPairs ) {
2042 escape(getPairs(set)) + "\", expected \"" +
2047 escape(getPairs(set)) + "\"");
2050 // the result of calling set.toPattern(), which is the string representation of
2051 // this set(set), is passed to a UnicodeSet constructor, and tested that it
2052 // will produce another set that is equal to this one.
2054 set.toPattern(temppattern);
2060 if(*tempset != set || getPairs(*tempset) != getPairs(set)){
2062 escape(getPairs(set)) + "\""));
2072 UnicodeSetTest::expectPairs(const UnicodeSet& set, const UnicodeString& expectedPairs) {
2073 if (getPairs(set) != expectedPairs) {
2076 escape(getPairs(set)) + "\"");
2080 void UnicodeSetTest::expectToPattern(const UnicodeSet& set,
2084 set.toPattern(pat, TRUE);
2101 UBool contained = set.contains(s);
2176 errln("FAIL: a copy-constructed frozen set differs from its original");
2181 errln("FAIL: a frozen set was modified by operator=");
2186 errln("FAIL: a copied frozen set differs from its frozen original");
2189 errln("FAIL: copy-constructing a frozen set results in a thawed one");
2197 errln("FAIL: copying a frozen set results in a thawed one");
2220 frozen.set(5, 55);
2222 errln("FAIL: UnicodeSet::set() modified a frozen set");
2227 errln("FAIL: UnicodeSet::clear() modified a frozen set");
2232 errln("FAIL: UnicodeSet::closeOver() modified a frozen set");
2237 errln("FAIL: UnicodeSet::compact() modified a frozen set");
2248 errln("FAIL: UnicodeSet::applyXYZ() modified a frozen set");
2258 errln("FAIL: UnicodeSet::addXYZ() modified a frozen set");
2267 errln("FAIL: UnicodeSet::retainXYZ() modified a frozen set");
2277 errln("FAIL: UnicodeSet::removeXYZ() modified a frozen set");
2288 errln("FAIL: UnicodeSet::complementXYZ() modified a frozen set");
2315 set(normalSet), stringsLength(0), hasSurrogates(FALSE) {
2316 int32_t size=set.size();
2317 if(size>0 && set.charAt(size-1)<0) {
2318 // If a set's last element is not a code point, then it must contain strings.
2319 // Iterate over the set, skip all code point ranges, and cache the strings.
2321 UnicodeSetIterator iter(set);
2327 // Store the pointer to the set's string element
2345 return set;
2359 const UnicodeSet &set;
2371 UnicodeSetWithStringsIterator(const UnicodeSetWithStrings &set) :
2372 fSet(set), nextStringIndex(0), nextUTF8Start(0) {
2419 static int32_t containsSpanUTF16(const UnicodeSetWithStrings &set, const UChar *s, int32_t length,
2421 const UnicodeSet &realSet(set.getSet());
2422 if(!set.hasStrings()) {
2437 UnicodeSetWithStringsIterator iter(set);
2457 UnicodeSetWithStringsIterator iter(set);
2487 int32_t spanLength=containsSpanUTF16(set, s+matchLimit, length-matchLimit,
2517 static int32_t containsSpanBackUTF16(const UnicodeSetWithStrings &set, const UChar *s, int32_t length,
2522 const UnicodeSet &realSet(set.getSet());
2523 if(!set.hasStrings()) {
2538 UnicodeSetWithStringsIterator iter(set);
2557 UnicodeSetWithStringsIterator iter(set);
2587 int32_t spanStart=containsSpanBackUTF16(set, s, matchStart,
2616 static int32_t containsSpanUTF8(const UnicodeSetWithStrings &set, const char *s, int32_t length,
2618 const UnicodeSet &realSet(set.getSet());
2619 if(!set.hasStrings()) {
2634 UnicodeSetWithStringsIterator iter(set);
2655 UnicodeSetWithStringsIterator iter(set);
2686 int32_t spanLength=containsSpanUTF8(set, s+matchLimit, length-matchLimit,
2716 static int32_t containsSpanBackUTF8(const UnicodeSetWithStrings &set, const char *s, int32_t length,
2721 const UnicodeSet &realSet(set.getSet());
2722 if(!set.hasStrings()) {
2737 UnicodeSetWithStringsIterator iter(set);
2757 UnicodeSetWithStringsIterator iter(set);
2788 int32_t spanStart=containsSpanBackUTF8(set, s, matchStart,
2847 * Count spans on a string with the method according to type and set the span limits.
2848 * The set may be the complement of the original.
2854 static int32_t getSpans(const UnicodeSetWithStrings &set, UBool isComplement,
2860 const UnicodeSet &realSet(set.getSet());
2914 // Default first span condition for going forward with an uncomplemented set.
2943 start+= isUTF16 ? containsSpanUTF16(set, (const UChar *)s+start, length-start, spanCondition) :
2944 containsSpanUTF8(set, (const char *)s+start, length-start, spanCondition);
2984 length= isUTF16 ? containsSpanBackUTF16(set, (const UChar *)s, length, spanCondition) :
2985 containsSpanBackUTF8(set, (const char *)s, length, spanCondition);
3042 * span() or spanBack(), using unfrozen or frozen versions of the set,
3043 * and using the set or its complement (switching the spanConditions accordingly).
3045 * set.span(spanCondition) == set.complement().span(!spanCondition).
3111 // but only if we have expectLimits[] from the uncomplemented set.
3265 // Verify that all implementations represent the same set.
3268 // or the set contains strings with unpaired surrogates which don't translate to valid UTF-8:
3419 // Take a set of span options and multiply them so that
3421 // If b==0, then the set of options is just modified with mask and a.
3422 // If b!=0 and c==0, then the set of options is just modified with mask, a and b.
3451 // "-options" limits the scope of testing for the current set.
3459 // or the set contains strings with unpaired surrogates
3461 // c -- set.span() and set.complement().span() boundaries may differ.
3464 // Cause: Strings in the set overlap, and spanBack(USET_SPAN_CONTAINED)
3467 // For example, with a set containing "ab" and "ba",
3473 // Cause: Strings in the set overlap, and a longer match may
3475 // For example, with a set containing "ab", "abc" and "cd",
3480 // The options are also reset for each new set.
3511 "xyaxyaxyaxya" // set.complement().span(longest match) will stop here.
3512 "xx" // set.complement().span(contained) will stop between the two 'x'es.
3557 // Test with non-ASCII set strings - test proper handling of surrogate pairs
3582 // because b is not in the complement set and there is an odd number of b's
3587 // Test with set strings with an initial or final code point span
3634 // Intermediate set: Test cloning of a frozen set.
3693 errln("FAIL: unrecognized span set option in \"%s\"", testdata[i]);
3751 UnicodeSet set(pattern16, errorCode);
3759 if(set.containsAll(string16)) {
3765 if(!set.containsAll(string16)) {
3772 (void)length16; // Suppress set but not used warning.
3773 if( set.span(s16, 8, USET_SPAN_NOT_CONTAINED)!=4 ||
3774 set.span(s16, 7, USET_SPAN_NOT_CONTAINED)!=4 ||
3775 set.span(s16, 6, USET_SPAN_NOT_CONTAINED)!=4 ||
3776 set.span(s16, 5, USET_SPAN_NOT_CONTAINED)!=5 ||
3777 set.span(s16, 4, USET_SPAN_NOT_CONTAINED)!=4 ||
3778 set.span(s16, 3, USET_SPAN_NOT_CONTAINED)!=3
3785 set.applyPattern(pattern16, errorCode);
3793 if( set.span(s16, 12, USET_SPAN_CONTAINED)!=12 ||
3794 set.span(s16, 12, USET_SPAN_SIMPLE)!=6 ||
3795 set.span(s16+7, 5, USET_SPAN_SIMPLE)!=5
3802 set.applyPattern(pattern16, errorCode).freeze();
3810 if( set.spanBack(s16, 12, USET_SPAN_CONTAINED)!=0 ||
3811 set.spanBack(s16, 12, USET_SPAN_SIMPLE)!=6 ||
3812 set.spanBack(s16, 5, USET_SPAN_SIMPLE)!=0