mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-10 02:40:59 +00:00
CPDictionary -initWithObjectsAndKeys: skip a nil key instead of breaking
This commit is contained in:
1 parent
3fe2e4487e
commit
de04c72767
2 files changed
+10
-1
No files matched your search
@@ -299,7 +299,7 @@
|
||||
var value = arguments[index];
|
||||
|
||||
if (value === nil)
|
||||
break;
|
||||
continue;
|
||||
|
||||
[self setObject:value forKey:arguments[index + 1]];
|
||||
}
|
||||
|
||||
@@ -250,4 +250,13 @@
|
||||
[self assertTrue:d.indexOf("y: 6") !== -1 message:"Can't find 'y: 6' in description of dictionary " + d];
|
||||
}
|
||||
|
||||
- (void)testInitWithObjectsAndKeys
|
||||
{
|
||||
var dict = [[CPDictionary alloc] initWithObjectsAndKeys:@"Value1", @"Key1", nil, @"Key2", @"Value3", @"Key3"];
|
||||
|
||||
[self assert:2 equals:[dict count]];
|
||||
[self assert:@"Value1" equals:[dict objectForKey:@"Key1"]];
|
||||
[self assert:nil equals:[dict objectForKey:@"Key2"]]; // No key/value pair
|
||||
[self assert:@"Value3" equals:[dict objectForKey:@"Key3"]];
|
||||
}
|
||||
@end
|
||||
Reference in new issue
Block a user