Added test for unarchiving with switched class names.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19441 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2004-06-02 05:29:13 +00:00
parent f191c5bc11
commit 720b25f4a3

View file

@ -10,9 +10,33 @@
#include <Foundation/NSValue.h>
#include <Foundation/NSDate.h>
@interface ClassOne : NSObject
@end
@implementation ClassOne
- (void) encodeWithCoder: (NSCoder*)aCoder
{
}
- (id) initWithCoder: (NSCoder*)aCoder
{
return self;
}
@end
@interface ClassTwo : NSObject
@end
@implementation ClassTwo
- (void) encodeWithCoder: (NSCoder*)aCoder
{
}
- (id) initWithCoder: (NSCoder*)aCoder
{
return self;
}
@end
typedef struct { char a; double b; char c;} tstruct;
int main()
{
id obj;
id set;
id arp;
id arc;
@ -98,6 +122,14 @@ printf("%u\n", [arc retainCount]);
printf("%s\n", [[o description] cString]);
}
obj = [ClassOne new];
[NSArchiver archiveRootObject: obj toFile: @"./nsarchiver.dat"];
RELEASE(obj);
[NSUnarchiver decodeClassName: @"ClassOne" asClassName: @"ClassTwo"];
obj = [NSUnarchiver unarchiveObjectWithFile: @"./nsarchiver.dat"];
if ([obj isKindOfClass: [ClassTwo class]] == NO)
NSLog(@"ERROR: ClassOne decoded as %@", NSStringFromClass([obj class]));
#if 0
/*
* Benchmark use of very lightwight archiving - a single