Adding failing test demonstrating that CPIndexSet throws with negative delta (e.g. shifting indexes at starting point upwards). Simple downward shift example included and working successfully.

Misc method reorganization with test suite so it's a bit more intuitive.
This commit is contained in:
Andrew Burkhalter authored and Ross Boucher committed 2010-03-12 18:50:35 -08:00
1 parent 503ce5502e
commit dc9d79bc3d
1 file changed
+25 -11
+25 -11
View File
@@ -12,6 +12,11 @@ function descriptionWithoutEntity(aString)
CPIndexSet _set;
}
- (void)setUp
{
_set = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(10, 10)];
}
- (void)testAddIndexes
{
var indexSet = [CPIndexSet indexSet];
@@ -177,16 +182,6 @@ function descriptionWithoutEntity(aString)
[self assert:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59] equals:array];
}
- (void)setUp
{
_set = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(10, 10)];
}
- (void)tearDown
{
_set = nil;
}
- (void)testIndexSet:(CPIndexSet)set containsRange:(CPRange)range
{
[self assertFalse:[set containsIndex:range.location -1]];
@@ -358,5 +353,24 @@ function descriptionWithoutEntity(aString)
[self assertFalse:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(9, 2)]]];
}
@end
- (void)testShiftIndexesStartingAtIndex
{
var startRange = CPMakeRange(1, 5),
shiftRange = CPMakeRange(2, 5);
_set = [CPIndexSet indexSetWithIndexesInRange:startRange];
// positive delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:shiftRange]]];
// negative delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:-1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:startRange]]];
}
- (void)tearDown
{
_set = nil;
}
@end