Test CPArray enumerateObjectsUsingBlock:.

This commit is contained in:
Alexander Ljungberg committed 2012-03-23 00:26:05 +00:00
1 parent 2951a83e73
commit e19a782954
1 file changed
+20 -1
+20 -1
View File
@@ -1,4 +1,3 @@
@import <Foundation/Foundation.j>
@@ -494,6 +493,26 @@
[self assert:[tests[index][0] componentsJoinedByString:tests[index][1]] equals:tests[index][2]];
}
- (void)testEnumateObjectsUsingBlock_
{
var input0 = [],
input1 = [1, 3, "b"],
output = [CPMutableDictionary dictionary],
outputFunction = function(anObject, idx)
{
[output setValue:anObject forKey:"" + idx];
};
[input0 enumerateObjectsUsingBlock:outputFunction];
[self assert:0 equals:[output count] message:@"output when enumerating empty array"];
[input1 enumerateObjectsUsingBlock:outputFunction];
[self assert:3 equals:[output count] message:@"output when enumerating input1"];
[self assert:input1[0] equals:[output valueForKey:"0"] message:@"output[0]"];
[self assert:input1[1] equals:[output valueForKey:"1"] message:@"output[0]"];
[self assert:input1[2] equals:[output valueForKey:"2"] message:@"output[0]"];
}
@end
@implementation AlwaysEqual : CPObject