Add a few tests and fix a few warnings

This commit is contained in:
Richard Frith-Macdonald 2020-04-05 10:25:54 +01:00
parent adb67ee405
commit 4bc622bafd
3 changed files with 17 additions and 5 deletions

View file

@ -65,8 +65,8 @@
}
else
{
lengthHeader = [NSString stringWithFormat: @"Content-Length: %d\r\n",
[bodyData length]];
lengthHeader = [NSString stringWithFormat: @"Content-Length: %u\r\n",
(unsigned)[bodyData length]];
headers = [[NSArray alloc] initWithObjects: @"HTTP/1.1 200 OK\r\n",
@"Content-type: text/plain\r\n", lengthHeader, nil];
}
@ -232,7 +232,7 @@
case NSStreamEventOpenCompleted:
break;
default:
NSLog(@"Unknown event %d on stream %p", streamEvent, theStream);
NSLog(@"Unknown event %u on stream %p", (unsigned)streamEvent, theStream);
break;
}
}

View file

@ -86,7 +86,7 @@
{
NSRunLoop *rl = [NSRunLoop currentRunLoop];
NSLog(@"Server %p %d", theStream, streamEvent);
NSLog(@"Server %p %u", theStream, (unsigned)streamEvent);
switch (streamEvent)
{
case NSStreamEventHasBytesAvailable:
@ -249,7 +249,7 @@ NSLog(@"Server %p %d", theStream, streamEvent);
break;
default:
NSLog(@"Unexpected event %d on %p", streamEvent, theStream);
NSLog(@"Unexpected event %u on %p", (unsigned)streamEvent, theStream);
break;
}
}

View file

@ -70,6 +70,18 @@ int main()
PASS_EQUAL([components percentEncodedQueryItems], emptyArray,
"percent encoded query items is empty")
[components setQuery: @"&"];
PASS_EQUAL([components query], @"&",
"set query to ampersand")
PASS_EQUAL([components percentEncodedQuery], @"&",
"percent encoded ampersand query is still ampersand")
[components setPercentEncodedQuery: @"%26"];
PASS_EQUAL([components query], @"&",
"set query to item containing ampersand")
PASS_EQUAL([components percentEncodedQuery], @"%26",
"percent encoded query item encodes ampersand")
END_SET("components")
return 0;