Fix and test case for issue #746

This commit is contained in:
Aparajita Fishman authored and Ross Boucher committed 2010-07-28 16:12:02 -07:00
1 parent f26d2f4ebf
commit 8ecac8d03c
2 files changed
+9 -2

No files matched your search

+2 -2
View File
@@ -698,12 +698,12 @@
var range = _ranges[i],
maximum = CPMaxRange(range);
if (anIndex > maximum)
if (anIndex >= maximum)
break;
// If our index is within our range, but not the first index,
// then this range will be split.
if (anIndex > range.location && anIndex < maximum)
if (anIndex > range.location)
{
// Split the range into shift and unshifted.
shifted = CPMakeRange(anIndex + aDelta, maximum - anIndex);
+7
View File
@@ -366,6 +366,13 @@ function descriptionWithoutEntity(aString)
// negative delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:-1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:startRange]]];
// test for fix to issue #746 (last item is mistakenly shifted)
_set = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 1)];
[self assertTrue:[_set lastIndex] === 0];
[_set shiftIndexesStartingAtIndex:[_set lastIndex] + 1 by:1];
[self assertTrue:[_set lastIndex] === 0];
}
- (void)tearDown