mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-02 21:43:36 +00:00
Fixed: searching a string for @"" with CPString rangeOfString returned results other than CPNotFound.
This commit is contained in:
@@ -361,10 +361,14 @@ var CPStringRegexSpecialCharacters = [
|
||||
@param aMask the options to use in the search
|
||||
@param aRange the range of the receiver in which to search for
|
||||
@return the range of characters in the receiver. If the string was not found,
|
||||
the \c length of the range will be 0.
|
||||
or if it was @"", the range will be {CPNotFound, 0}.
|
||||
*/
|
||||
- (CPRange)rangeOfString:(CPString)aString options:(int)aMask range:(CPrange)aRange
|
||||
{
|
||||
// Searching for @"" always returns CPNotFound.
|
||||
if (!aString)
|
||||
return CPMakeRange(CPNotFound, 0);
|
||||
|
||||
var string = (aRange == nil) ? self : [self substringWithRange:aRange],
|
||||
location = CPNotFound;
|
||||
|
||||
|
||||
@@ -388,6 +388,16 @@
|
||||
|
||||
[self assert:8 equals:unAnchoredSuffixRange.location message:"backwards search for LAG"];
|
||||
[self assert:CPNotFound equals:anchoredSuffixRange.location message:"anchored backwards search for LAG"];
|
||||
|
||||
anchoredSuffixRange = [endsTest rangeOfString:@"AGE" options:(CPAnchoredSearch | CPCaseInsensitiveSearch | CPBackwardsSearch)];
|
||||
[self assert:9 equals:anchoredSuffixRange.location message:"anchored backwards search for AGE"];
|
||||
|
||||
anchoredSuffixRange = [endsTest rangeOfString:endsTest options:(CPAnchoredSearch | CPCaseInsensitiveSearch | CPBackwardsSearch)];
|
||||
[self assert:0 equals:anchoredSuffixRange.location message:"anchored backwards search for whole string (location)"];
|
||||
[self assert:endsTest.length equals:anchoredSuffixRange.length message:"anchored backwards search for whole string (length)"];
|
||||
|
||||
anchoredSuffixRange = [endsTest rangeOfString:@"" options:(CPAnchoredSearch | CPCaseInsensitiveSearch | CPBackwardsSearch)];
|
||||
[self assert:CPNotFound equals:anchoredSuffixRange.location message:"anchored backwards search for nothing"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user