From c8f3445fa6ecf7641e9d7a18a3a006477607005f Mon Sep 17 00:00:00 2001 From: Alan Rogers Date: Wed, 10 Mar 2010 14:09:54 +1100 Subject: [PATCH] Adding a unit test to verify fix to +[CPDictionary dictionaryWithJSObject:(JSObject)object recursively:(BOOL)recursively] --- Tests/Foundation/CPDictionaryTest.j | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Tests/Foundation/CPDictionaryTest.j b/Tests/Foundation/CPDictionaryTest.j index f3936b26b..8a29cd853 100644 --- a/Tests/Foundation/CPDictionaryTest.j +++ b/Tests/Foundation/CPDictionaryTest.j @@ -16,6 +16,12 @@ string_dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key1", @"key2"]]; json_dict = [CPDictionary dictionaryWithJSObject:json recursively:YES]; + + json_with_nulls = { + "key1": ['1', '2', '3'], + "key2": "This is a string", + "key3": null + } } - (void)testInitWithDictionary @@ -58,6 +64,14 @@ [self assert:[[dict objectForKey:@"key3"] count] equals:1]; } +- (void)testDictionaryWithJSObjectRecursiveWithNull +{ + var dict = [CPDictionary dictionaryWithJSObject:json_with_nulls recursively:YES]; + [self assert:2 equals:[dict count]]; + [self assert:[@"key1", @"key2"] equals:[dict allKeys]]; + [self assert:[dict objectForKey:@"key3"] equals:nil]; +} + - (void)testDictionaryWithJSObjectNonRecursive { var non_recursive_dict = [CPDictionary dictionaryWithJSObject:json recursively:NO];