| OLD | NEW |
| 1 /******************************************************************** | 1 /******************************************************************** |
| 2 * COPYRIGHT: | 2 * COPYRIGHT: |
| 3 * Copyright (c) 2002-2007, International Business Machines Corporation and | 3 * Copyright (c) 2002-2008, International Business Machines Corporation and |
| 4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
| 5 ********************************************************************/ | 5 ********************************************************************/ |
| 6 | 6 |
| 7 // | 7 // |
| 8 // regextst.cpp | 8 // regextst.cpp |
| 9 // | 9 // |
| 10 // ICU Regular Expressions test, part of intltest. | 10 // ICU Regular Expressions test, part of intltest. |
| 11 // | 11 // |
| 12 | 12 |
| 13 #include "intltest.h" | 13 #include "intltest.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 break; | 59 break; |
| 60 case 4: name = "Extended"; | 60 case 4: name = "Extended"; |
| 61 if (exec) Extended(); | 61 if (exec) Extended(); |
| 62 break; | 62 break; |
| 63 case 5: name = "Errors"; | 63 case 5: name = "Errors"; |
| 64 if (exec) Errors(); | 64 if (exec) Errors(); |
| 65 break; | 65 break; |
| 66 case 6: name = "PerlTests"; | 66 case 6: name = "PerlTests"; |
| 67 if (exec) PerlTests(); | 67 if (exec) PerlTests(); |
| 68 break; | 68 break; |
| 69 case 7: name = "Bug 6149"; |
| 70 if (exec) Bug6149(); |
| 71 break; |
| 72 |
| 69 | 73 |
| 70 | 74 |
| 71 default: name = ""; | 75 default: name = ""; |
| 72 break; //needed to end loop | 76 break; //needed to end loop |
| 73 } | 77 } |
| 74 } | 78 } |
| 75 | 79 |
| 76 | 80 |
| 77 //--------------------------------------------------------------------------- | 81 //--------------------------------------------------------------------------- |
| 78 // | 82 // |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 REGEX_ERR("abc{5,50000000000}", 1, 17, U_REGEX_NUMBER_TOO_BIG); // Ov
erflows int during scan | 1636 REGEX_ERR("abc{5,50000000000}", 1, 17, U_REGEX_NUMBER_TOO_BIG); // Ov
erflows int during scan |
| 1633 REGEX_ERR("abc{5,687865858}", 1, 16, U_REGEX_NUMBER_TOO_BIG); // Ov
erflows regex binary format | 1637 REGEX_ERR("abc{5,687865858}", 1, 16, U_REGEX_NUMBER_TOO_BIG); // Ov
erflows regex binary format |
| 1634 REGEX_ERR("abc{687865858,687865859}", 1, 24, U_REGEX_NUMBER_TOO_BIG); | 1638 REGEX_ERR("abc{687865858,687865859}", 1, 24, U_REGEX_NUMBER_TOO_BIG); |
| 1635 | 1639 |
| 1636 | 1640 |
| 1637 // UnicodeSet containing a string | 1641 // UnicodeSet containing a string |
| 1638 REGEX_ERR("abc[{def}]xyz", 1, 10, U_REGEX_SET_CONTAINS_STRING); | 1642 REGEX_ERR("abc[{def}]xyz", 1, 10, U_REGEX_SET_CONTAINS_STRING); |
| 1639 | 1643 |
| 1640 // Ticket 5389 | 1644 // Ticket 5389 |
| 1641 REGEX_ERR("*c", 1, 1, U_REGEX_RULE_SYNTAX); | 1645 REGEX_ERR("*c", 1, 1, U_REGEX_RULE_SYNTAX); |
| 1646 |
| 1647 // Invalid Back Reference \0 |
| 1648 // For ICU 3.8 and earlier |
| 1649 // For ICU versions newer than 3.8, \0 introduces an octal escape. |
| 1650 // |
| 1651 REGEX_ERR("(ab)\\0", 1, 6, U_REGEX_INVALID_BACK_REF); |
| 1642 | 1652 |
| 1643 } | 1653 } |
| 1644 | 1654 |
| 1645 | 1655 |
| 1646 //------------------------------------------------------------------------------
- | 1656 //------------------------------------------------------------------------------
- |
| 1647 // | 1657 // |
| 1648 // Read a text data file, convert it to UChars, and return the data | 1658 // Read a text data file, convert it to UChars, and return the data |
| 1649 // in one big UChar * buffer, which the caller must delete. | 1659 // in one big UChar * buffer, which the caller must delete. |
| 1650 // | 1660 // |
| 1651 //------------------------------------------------------------------------------
-- | 1661 //------------------------------------------------------------------------------
-- |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2115 | 2125 |
| 2116 delete fieldPat; | 2126 delete fieldPat; |
| 2117 delete [] testData; | 2127 delete [] testData; |
| 2118 | 2128 |
| 2119 | 2129 |
| 2120 logln("%d tests skipped because of unimplemented regexp features.", skippedU
nimplementedCount); | 2130 logln("%d tests skipped because of unimplemented regexp features.", skippedU
nimplementedCount); |
| 2121 | 2131 |
| 2122 } | 2132 } |
| 2123 | 2133 |
| 2124 | 2134 |
| 2135 //-------------------------------------------------------------- |
| 2136 // |
| 2137 // Bug6149 Verify limits to heap expansion for backtrack stack. |
| 2138 // Use this pattern, |
| 2139 // "(a?){1,}" |
| 2140 // The zero-length match will repeat forever. |
| 2141 // (That this goes into a loop is another bug) |
| 2142 // |
| 2143 //--------------------------------------------------------------- |
| 2144 void RegexTest::Bug6149() { |
| 2145 UnicodeString pattern("(a?){1,}"); |
| 2146 UnicodeString s("xyz"); |
| 2147 uint32_t flags = 0; |
| 2148 UErrorCode status = U_ZERO_ERROR; |
| 2149 |
| 2150 RegexMatcher matcher(pattern, s, flags, status); |
| 2151 UBool result = false; |
| 2152 REGEX_ASSERT_FAIL(result=matcher.matches(status), U_BUFFER_OVERFLOW_ERROR); |
| 2153 REGEX_ASSERT(result == FALSE); |
| 2154 } |
| 2125 | 2155 |
| 2126 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ | 2156 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ |
| 2127 | 2157 |
| OLD | NEW |