mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix for #243
This commit is contained in:
parent
61d14215fa
commit
ae72ee4593
3 changed files with 22 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2022-03-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPredicate.m:
|
||||
* Tests/base/NSPredicate/basic.m:
|
||||
Fix for git #243
|
||||
|
||||
2022-02-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSDistantObject.m:
|
||||
|
|
|
@ -1019,15 +1019,22 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
#endif
|
||||
case NSBeginsWithPredicateOperatorType:
|
||||
{
|
||||
NSRange range = NSMakeRange(0, [rightResult length]);
|
||||
NSRange range;
|
||||
NSUInteger ll = [leftResult length];
|
||||
NSUInteger rl = [rightResult length];
|
||||
|
||||
if (rl > ll)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
range = NSMakeRange(0, rl);
|
||||
return ([leftResult compare: rightResult
|
||||
options: compareOptions
|
||||
range: range] == NSOrderedSame ? YES : NO);
|
||||
}
|
||||
case NSEndsWithPredicateOperatorType:
|
||||
{
|
||||
NSRange range;
|
||||
NSRange range;
|
||||
NSUInteger ll = [leftResult length];
|
||||
NSUInteger rl = [rightResult length];
|
||||
|
||||
|
|
|
@ -40,6 +40,13 @@ testString(NSDictionary *dict)
|
|||
PASS([p evaluateWithObject: dict], "%%K BEGINSWITH %%@");
|
||||
p = [NSPredicate predicateWithFormat: @"(%K == %@) AND (%K == %@)", @"Record1.Name", @"John", @"Record2.Name", @"Mary"];
|
||||
PASS([p evaluateWithObject: dict], "(%%K == %%@) AND (%%K == %%@)");
|
||||
|
||||
NSMutableArray *strings = [NSMutableArray arrayWithObjects: @"a", @"aa",
|
||||
@"aaa", @"aaaa", nil];
|
||||
NSArray *expect = [NSMutableArray arrayWithObjects: @"aaa", @"aaaa", nil];
|
||||
p = [NSPredicate predicateWithFormat: @"self beginswith 'aaa'"];
|
||||
[strings filterUsingPredicate: p];
|
||||
PASS_EQUAL(strings, expect, "filter using BEGINSWITH")
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue