CPDictionary -initWithObjectsAndKeys: skip a nil key instead of breaking

This commit is contained in:
cacaodev committed 2012-07-13 21:47:39 +02:00
1 parent 3fe2e4487e
commit de04c72767
2 files changed
+10 -1

No files matched your search

+1 -1
View File
@@ -299,7 +299,7 @@
var value = arguments[index];
if (value === nil)
break;
continue;
[self setObject:value forKey:arguments[index + 1]];
}
+9
View File
@@ -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