mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-02 11:12:58 +00:00
Test CPArray enumerateObjectsUsingBlock:.
This commit is contained in:
1 parent
2951a83e73
commit
e19a782954
1 file changed
+20
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user