Create temporarry file in current directory and delete it when done ... fixes testcase to work on windows.

This commit is contained in:
Richard Frith-Macdonald 2020-12-03 09:22:15 -05:00
parent 1b7bf26bea
commit aff02f4d08

View file

@ -160,7 +160,7 @@
- (void)cr2549370
{
NSString *path = @"/tmp/json.data";
NSString *path = @"./json.data";
NSString *string = @"Hello garçon! ¡Ola! A little more coöperation please!";
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSMutableArray *array = [NSMutableArray array];
@ -177,6 +177,7 @@
[stream open];
dict = [NSJSONSerialization JSONObjectWithStream:stream options:0 error:0];
dict = [[dict objectForKey: @"datacenters"] objectAtIndex:0];
[[NSFileManager defaultManager] removeFileAtPath: path handler: nil];
NSAssert(dict != nil, @"JSON returned nil");
NSAssert([string isEqualToString:[dict objectForKey: @"nickname"]], @"data mismatch");
}
@ -200,12 +201,17 @@ static NSString *percentQuoted(NSString *s)
unsigned char c;
const char *allowedNonalnumChars = "-_,.'~!$&*();";
while ((c = *p++) != '\0') {
while ((c = *p++) != '\0')
{
if (isalnum(c) || strchr(allowedNonalnumChars, c) != 0)
{
[retval appendFormat: @"%c", c];
}
else
{
[retval appendFormat: @"%%%02x", c];
}
}
}
return retval;
}