Fixed: CPArrayController's addObject and CPArray's insertObject:inArraySortedByDescriptors:.

CPArray insertObject:inArraySortedByDescriptors: now quickly inserts objects at the end of the array if no sort descriptors are specified.

CPArrayController initialises its sort descriptors to an empty array.

Fixed: array controller's addObject added objects to the arranged objects array in a different order than in the content array if no sort descriptor was set.
This commit is contained in:
Alexander Ljungberg committed 2010-12-14 23:33:14 +01:00
1 parent 2af2fc31a1
commit 8ef7f07195
3 files changed
+42 -11

No files matched your search

+24
View File
@@ -92,6 +92,30 @@
[self assert:[CPIndexSet indexSetWithIndex:count - 1] equals:[arrayController selectionIndexes]];
}
/*
Verify that the arranged objects ordering is correct versus the content array when objects are added with addObject and no sort descriptors are set.
*/
- (void)testAddObjects
{
_arrayController = [[CPArrayController alloc] init];
var content = [];
[_arrayController setContent:content];
[_arrayController addObject:[CPNumber numberWithInt:1]];
[_arrayController addObject:[CPNumber numberWithInt:2]];
[self assert:[CPNumber numberWithInt:1] equals:content[0]];
[self assert:[CPNumber numberWithInt:2] equals:content[1]];
[self assert:[CPNumber numberWithInt:1] equals:[_arrayController arrangedObjects][0] message:"arranged objects should be in the correct order"];
[self assert:[CPNumber numberWithInt:2] equals:[_arrayController arrangedObjects][1] message:"arranged objects should be in the correct order"];
[_arrayController rearrangeObjects];
[self assert:[CPNumber numberWithInt:1] equals:[_arrayController arrangedObjects][0]];
[self assert:[CPNumber numberWithInt:2] equals:[_arrayController arrangedObjects][1]];
}
- (void)testRemoveObjects
{
var arrayController = [self arrayController];