mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
import testsuite
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32187 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
734c214892
commit
0e02133729
374 changed files with 20864 additions and 0 deletions
67
Tests/base/KVC/nil.m
Normal file
67
Tests/base/KVC/nil.m
Normal file
|
@ -0,0 +1,67 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
|
||||
@interface DefaultNil : NSObject
|
||||
{
|
||||
int num;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation DefaultNil
|
||||
- (id)init
|
||||
{
|
||||
num = 7;
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DeprecatedNil : DefaultNil
|
||||
- (void)unableToSetNilForKey:(NSString *)key;
|
||||
@end
|
||||
|
||||
@implementation DeprecatedNil
|
||||
- (void)unableToSetNilForKey:(NSString *)key
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface SetNil : DefaultNil
|
||||
- (void)setNilValueForKey:(NSString *)key;
|
||||
@end
|
||||
|
||||
@implementation SetNil
|
||||
- (void)setNilValueForKey:(NSString *)key
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
|
||||
DefaultNil * defaultNil = [DefaultNil new];
|
||||
DeprecatedNil * deprecatedNil = [DeprecatedNil new];
|
||||
SetNil * setNil = [SetNil new];
|
||||
|
||||
PASS_EXCEPTION([defaultNil setValue: nil forKey: @"num"],
|
||||
NSInvalidArgumentException, "KVC handles setting nil for a scalar")
|
||||
|
||||
PASS_EXCEPTION([defaultNil takeValue: nil forKey: @"num"],
|
||||
NSInvalidArgumentException,
|
||||
"KVC handles setting nil for a scalar via takeValue:")
|
||||
|
||||
[setNil setValue:nil forKey: @"num"];
|
||||
PASS([[setNil valueForKey: @"num"] intValue] == 0,
|
||||
"KVC uses setNilValueForKey:")
|
||||
|
||||
[deprecatedNil setValue:nil forKey: @"num"];
|
||||
PASS([[deprecatedNil valueForKey: @"num"] intValue] == 0,
|
||||
"KVC uses deprecated unableToSetNilForKey:")
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue