mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
Mimic OSX handling of what appears to be an ICU bug
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37793 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
be29047e59
commit
3df1043cea
5 changed files with 70 additions and 24 deletions
|
@ -1,21 +1,45 @@
|
|||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSRegularExpression.h>
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
[NSAutoreleasePool new];
|
||||
START_SET("NSString + regex")
|
||||
[NSAutoreleasePool new];
|
||||
START_SET("NSString + regex")
|
||||
|
||||
#if !(__APPLE__ || GS_USE_ICU)
|
||||
SKIP("NSRegularExpression not built, please install libicu")
|
||||
SKIP("NSRegularExpression not built, please install libicu")
|
||||
#else
|
||||
NSString *regex = @"abcd*";
|
||||
NSString *source = @"abcdddddd e f g";
|
||||
NSRange r = [source rangeOfString: regex options: NSRegularExpressionSearch];
|
||||
PASS(r.length == 9, "Correct length for regex, expected 9 got %d", (int)r.length);
|
||||
regex = @"aBcD*";
|
||||
r = [source rangeOfString: regex options: (NSRegularExpressionSearch | NSCaseInsensitiveSearch)];
|
||||
PASS(r.length == 9, "Correct length for regex, expected 9 got %d", (int)r.length);
|
||||
NSRegularExpression *expr;
|
||||
NSString *regex;
|
||||
NSString *source;
|
||||
NSInteger index;
|
||||
NSRange r;
|
||||
|
||||
source = @"abcdddddd e f g";
|
||||
|
||||
regex = @"abcd*";
|
||||
r = [source rangeOfString: regex options: NSRegularExpressionSearch];
|
||||
PASS(r.length == 9, "Correct length for regex, expected 9 got %d",
|
||||
(int)r.length);
|
||||
|
||||
regex = @"aBcD*";
|
||||
r = [source rangeOfString: regex
|
||||
options: (NSRegularExpressionSearch | NSCaseInsensitiveSearch)];
|
||||
PASS(r.length == 9, "Correct length for regex, expected 9 got %d",
|
||||
(int)r.length);
|
||||
|
||||
source = @"h1. Real Acme\n\n||{noborder}{left}Item||{right}Price||\n|Testproduct|{right}2 x $59.50|\n| |{right}net amount: $100.00|\n| |{right}total amount: $119.00|\n\n\nh2. Thanks for your purchase!\n\n\n";
|
||||
|
||||
expr = [NSRegularExpression regularExpressionWithPattern: @"h[123]\\. "
|
||||
options: NSRegularExpressionCaseInsensitive error: NULL];
|
||||
index = 33;
|
||||
|
||||
NSLog(@"%@", [expr firstMatchInString: source
|
||||
options: NSMatchingAnchored
|
||||
range: NSMakeRange(index, [source length] - index - 1)]);
|
||||
#endif
|
||||
END_SET("NSString + regex")
|
||||
return 0;
|
||||
|
||||
END_SET("NSString + regex")
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue