mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-28 22:47:04 +00:00
Merge pull request #1614 from cacaodev/CPDictionary-initWithObjectsAndKeys
CPDictionary -initWithObjectsAndKeys: do not treat a nil value as a final value
This commit is contained in:
@@ -300,7 +300,7 @@
|
||||
var value = arguments[index];
|
||||
|
||||
if (value === nil)
|
||||
break;
|
||||
continue;
|
||||
|
||||
[self setObject:value forKey:arguments[index + 1]];
|
||||
}
|
||||
|
||||
@@ -399,4 +399,13 @@
|
||||
[self assert:'@{\n @"key1": @[\n @"1",\n @"2",\n @"3"\n ],\n @"key2": @"This is a string",\n @"key3": @{\n @"another": @"object"\n }\n}' equals:[json_dict description]];
|
||||
}
|
||||
|
||||
- (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