-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#import "ObjectTesting.h" | ||
#import <Foundation/NSNull.h> | ||
#import <Foundation/NSAutoreleasePool.h> | ||
#import <Foundation/NSKeyValueCoding.h> | ||
|
||
int main(void) { | ||
NSAutoreleasePool *arp = [NSAutoreleasePool new]; | ||
|
||
NSNull *nullObject = [NSNull null]; | ||
|
||
// Accessing an undefined key | ||
id result = [nullObject valueForKey:@"undefinedKey"]; | ||
PASS(result == nullObject, "NSNull returns itself for undefined keys."); | ||
|
||
// Attempting to set a value for an undefined key | ||
PASS_EXCEPTION([nullObject setValue:@"value" forKey:@"undefinedKey"], | ||
NSUndefinedKeyException, | ||
"Setting an undefined key on NSNull should not crash."); | ||
|
||
// Accessing an undefined key path | ||
id result = [nullObject valueForKeyPath:@"some.path"]; | ||
PASS(result == nullObject, "NSNull returns itself for undefined key paths."); | ||
|
||
// Attempting to set a value for an undefined key path | ||
PASS_EXCEPTION([nullObject setValue:@"value" forKeyPath:@"some.path"], | ||
NSUndefinedKeyException, | ||
"Setting an undefined key path on NSNull should not crash."); | ||
|
||
[arp release]; | ||
return 0; | ||
} |