mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-12 09:01:05 +00:00
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:
parent
f191c5bc11
commit
720b25f4a3
1 changed files with 32 additions and 0 deletions
|
@ -10,9 +10,33 @@
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <Foundation/NSDate.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;
|
typedef struct { char a; double b; char c;} tstruct;
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
id obj;
|
||||||
id set;
|
id set;
|
||||||
id arp;
|
id arp;
|
||||||
id arc;
|
id arc;
|
||||||
|
@ -98,6 +122,14 @@ printf("%u\n", [arc retainCount]);
|
||||||
printf("%s\n", [[o description] cString]);
|
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
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Benchmark use of very lightwight archiving - a single
|
* Benchmark use of very lightwight archiving - a single
|
||||||
|
|
Loading…
Reference in a new issue