Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

unit test to test CWDoublyLinkedLists insertObjecttAtIndex count works

  • Loading branch information...
commit e95d059e167fdcdfb51cb0e18cff5297806c38da 1 parent edd5275
@Machx authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 Source/CWDoublyLinkedListTests.m
View
36 Source/CWDoublyLinkedListTests.m
@@ -163,4 +163,40 @@ -(void)testListWithRange
STAssertNil([rangedList objectAtIndex:2],@"shouldn't have a valid object here");
}
+-(void)testCountIncrementsUsingInsertObjectAtIndex
+{
+ CWDoublyLinkedList *list = [CWDoublyLinkedList new];
+
+ [list addObject:@5];
+ [list addObject:@10];
+ [list addObject:@42];
+
+ STAssertTrue([list count] == 3, nil);
+
+ [list insertObject:@9 atIndex:1];
+
+ STAssertTrue([list count] == 4, nil);
+
+ [list enumerateObjectsWithBlock:^(id object, NSUInteger index, BOOL *stop) {
+ NSNumber *num = (NSNumber *)object;
+ switch (index) {
+ case 0:
+ STAssertTrue([num integerValue] == 5, nil);
+ break;
+ case 1:
+ STAssertTrue([num integerValue] == 9, nil);
+ break;
+ case 2:
+ STAssertTrue([num integerValue] == 10, nil);
+ break;
+ case 3:
+ STAssertTrue([num integerValue] == 42, nil);
+ break;
+ default:
+ STFail(@"List is hitting an index out of bounds");
+ break;
+ }
+ }];
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.