OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 2002-2014, International Business Machines Corporation and | 3 * Copyright (c) 2002-2014, 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. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 break; | 137 break; |
138 case 22: name = "Bug10459"; | 138 case 22: name = "Bug10459"; |
139 if (exec) Bug10459(); | 139 if (exec) Bug10459(); |
140 break; | 140 break; |
141 case 23: name = "TestCaseInsensitiveStarters"; | 141 case 23: name = "TestCaseInsensitiveStarters"; |
142 if (exec) TestCaseInsensitiveStarters(); | 142 if (exec) TestCaseInsensitiveStarters(); |
143 break; | 143 break; |
144 case 24: name = "TestBug11049"; | 144 case 24: name = "TestBug11049"; |
145 if (exec) TestBug11049(); | 145 if (exec) TestBug11049(); |
146 break; | 146 break; |
| 147 case 25: name = "TestBug11371"; |
| 148 if (exec) TestBug11371(); |
| 149 break; |
147 default: name = ""; | 150 default: name = ""; |
148 break; //needed to end loop | 151 break; //needed to end loop |
149 } | 152 } |
150 } | 153 } |
151 | 154 |
152 | 155 |
153 | 156 |
154 /** | 157 /** |
155 * Calls utext_openUTF8 after, potentially, converting invariant text from the c
ompilation codepage | 158 * Calls utext_openUTF8 after, potentially, converting invariant text from the c
ompilation codepage |
156 * into ASCII. | 159 * into ASCII. |
(...skipping 5203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5360 errln("File %s, line %d (UTF-8 check): expected %d, got %d. Pattern = \"
%s\", text = \"%s\"", | 5363 errln("File %s, line %d (UTF-8 check): expected %d, got %d. Pattern = \"
%s\", text = \"%s\"", |
5361 __FILE__, lineNumber, expectMatch, result, pattern, data); | 5364 __FILE__, lineNumber, expectMatch, result, pattern, data); |
5362 } | 5365 } |
5363 delete [] utf8Buffer; | 5366 delete [] utf8Buffer; |
5364 | 5367 |
5365 utext_close(ut); | 5368 utext_close(ut); |
5366 delete [] exactBuffer; | 5369 delete [] exactBuffer; |
5367 } | 5370 } |
5368 | 5371 |
5369 | 5372 |
| 5373 void RegexTest::TestBug11371() { |
| 5374 if (quick) { |
| 5375 logln("Skipping test. Runs in exhuastive mode only."); |
| 5376 return; |
| 5377 } |
| 5378 UErrorCode status = U_ZERO_ERROR; |
| 5379 UnicodeString patternString; |
| 5380 |
| 5381 for (int i=0; i<8000000; i++) { |
| 5382 patternString.append(UnicodeString("()")); |
| 5383 } |
| 5384 LocalPointer<RegexPattern> compiledPat(RegexPattern::compile(patternString,
0, status)); |
| 5385 if (status != U_REGEX_PATTERN_TOO_BIG) { |
| 5386 errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.
", |
| 5387 __FILE__, __LINE__, u_errorName(status)); |
| 5388 } |
| 5389 |
| 5390 status = U_ZERO_ERROR; |
| 5391 patternString = "("; |
| 5392 for (int i=0; i<20000000; i++) { |
| 5393 patternString.append(UnicodeString("A++")); |
| 5394 } |
| 5395 patternString.append(UnicodeString("){0}B++")); |
| 5396 LocalPointer<RegexPattern> compiledPat2(RegexPattern::compile(patternString,
0, status)); |
| 5397 if (status != U_REGEX_PATTERN_TOO_BIG) { |
| 5398 errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.
", |
| 5399 __FILE__, __LINE__, u_errorName(status)); |
| 5400 } |
| 5401 |
| 5402 // Pattern with too much string data, such that string indexes overflow oper
and data field size |
| 5403 // in compiled instruction. |
| 5404 status = U_ZERO_ERROR; |
| 5405 patternString = ""; |
| 5406 while (patternString.length() < 0x00ffffff) { |
| 5407 patternString.append(UnicodeString("stuff and things dont you know, thes
e are a few of my favorite strings\n")); |
| 5408 } |
| 5409 patternString.append(UnicodeString("X? trailing string")); |
| 5410 LocalPointer<RegexPattern> compiledPat3(RegexPattern::compile(patternString,
0, status)); |
| 5411 if (status != U_REGEX_PATTERN_TOO_BIG) { |
| 5412 errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.
", |
| 5413 __FILE__, __LINE__, u_errorName(status)); |
| 5414 } |
| 5415 } |
5370 | 5416 |
5371 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ | 5417 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ |
5372 | 5418 |
OLD | NEW |