alter code to check 64bit data

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36437 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-03-26 10:24:29 +00:00
parent cd6f06ce97
commit ee2731f49b
19 changed files with 47 additions and 22 deletions

View file

@ -199,29 +199,54 @@ void test(Class class)
for (; v >= 0; v--)
{
filename = [NSString stringWithFormat: @"%@.%i.data", class, v];
d = [NSData dataWithContentsOfFile: filename];
if (!d)
{
if (v == [class version])
{
if (!update)
PASS(0, "%s has reference data for the current version",
POBJECT(class))
else
[NSArchiver archiveRootObject:
[NSArray arrayWithObjects: instance, sentinel, nil]
toFile: filename];
}
continue;
}
int w;
decodedInstance = [NSUnarchiver unarchiveObjectWithData: d];
NSCAssert([sentinel isEqual: [decodedInstance objectAtIndex: 1]],
NSInternalInconsistencyException);
PASS([class verifyTestInstance: [decodedInstance objectAtIndex: 0]
ofVersion: v], "decoding version %i of class %s",
v, POBJECT(class));
for (w = 0; w < 2; w++)
{
const char *width;
if (0 == w)
{
if (YES == update && 4 != sizeof(void*))
{
continue; // Can't write a 32bit update.
}
width = "32bit";
}
else
{
if (YES == update && 8 != sizeof(void*))
{
continue; // Can't write a 64bit update.
}
width = "64bit";
}
filename = [NSString stringWithFormat: @"%@.%i.%s",
class, v, width];
d = [NSData dataWithContentsOfFile: filename];
if (!d)
{
if (v == [class version])
{
if (!update)
PASS(0, "%s has %s reference data for current version",
POBJECT(class), width)
else
[NSArchiver archiveRootObject:
[NSArray arrayWithObjects: instance, sentinel, nil]
toFile: filename];
}
continue;
}
decodedInstance = [NSUnarchiver unarchiveObjectWithData: d];
NSCAssert([sentinel isEqual: [decodedInstance objectAtIndex: 1]],
NSInternalInconsistencyException);
PASS([class verifyTestInstance: [decodedInstance objectAtIndex: 0]
ofVersion: v], "decoding %s version %i of class %s",
width, v, POBJECT(class));
}
}
}
NS_HANDLER