Refs #1071. indexOfObject:inSortedRange:options:usingComparator is incorrectly implemented.

Add more tests to cover more features of the indexOfObject:inSortedRange:options:usingComparator method
This commit is contained in:
Ilya Kulakov authored and Alexander Ljungberg committed 2011-01-04 13:37:06 -03:00
1 parent 95a2b46ae1
commit db6608571a
2 files changed
+67 -7

No files matched your search

+4 -4
View File
@@ -440,13 +440,13 @@ CPBinarySearchingInsertionIndex = 1 << 10;
else
{
if (options & CPBinarySearchingFirstEqual)
while (middle++ < count - 1 &&
aComparator(anObject, [self objectAtIndex:middle]) === CPOrderedSame);
while (middle > first && aComparator(anObject, [self objectAtIndex:middle - 1]) === CPOrderedSame)
--middle;
else if (options & CPBinarySearchingLastEqual)
{
while (middle-- > 0 &&
aComparator(anObject, [self objectAtIndex:middle]) === CPOrderedSame);
while (middle < last && aComparator(anObject, [self objectAtIndex:middle + 1]) === CPOrderedSame)
++middle;
if (options & CPBinarySearchingInsertionIndex)
++middle;