mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Add unit test for NSNull and KVC
This commit is contained in:
parent
61bb82e902
commit
4e45c968d5
1 changed files with 31 additions and 0 deletions
31
Tests/base/KVC/nsnull.m
Normal file
31
Tests/base/KVC/nsnull.m
Normal file
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue