15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "config.h"
#include <string.h>
#import "TestsAppDelegate.h"
static OFString *module = @"OFTCPSocket";
@implementation TestsAppDelegate (OFTCPSocketTests)
- (void)TCPSocketTests
{
void *pool = objc_autoreleasePoolPush();
OFTCPSocket *server, *client = nil, *accepted;
uint16_t port;
char buf[6];
TEST(@"+[socket]", (server = [OFTCPSocket socket]) &&
(client = [OFTCPSocket socket]))
TEST(@"-[bindToHost:port:]",
(port = [server bindToHost: @"127.0.0.1" port: 0]))
|
|
|
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "config.h"
#include <string.h>
#import "TestsAppDelegate.h"
static OFString *const module = @"OFTCPSocket";
@implementation TestsAppDelegate (OFTCPSocketTests)
- (void)TCPSocketTests
{
void *pool = objc_autoreleasePoolPush();
OFTCPSocket *server, *client = nil, *accepted;
uint16_t port;
char buffer[6];
TEST(@"+[socket]", (server = [OFTCPSocket socket]) &&
(client = [OFTCPSocket socket]))
TEST(@"-[bindToHost:port:]",
(port = [server bindToHost: @"127.0.0.1" port: 0]))
|
45
46
47
48
49
50
51
52
53
54
55
56
57
|
TEST(@"-[remoteAddress]",
[OFSocketAddressString(accepted.remoteAddress)
isEqual: @"127.0.0.1"])
TEST(@"-[writeString:]", [client writeString: @"Hello!"])
TEST(@"-[readIntoBuffer:length:]",
[accepted readIntoBuffer: buf length: 6] &&
!memcmp(buf, "Hello!", 6))
objc_autoreleasePoolPop(pool);
}
@end
|
|
|
|
45
46
47
48
49
50
51
52
53
54
55
56
57
|
TEST(@"-[remoteAddress]",
[OFSocketAddressString(accepted.remoteAddress)
isEqual: @"127.0.0.1"])
TEST(@"-[writeString:]", [client writeString: @"Hello!"])
TEST(@"-[readIntoBuffer:length:]",
[accepted readIntoBuffer: buffer length: 6] &&
!memcmp(buffer, "Hello!", 6))
objc_autoreleasePoolPop(pool);
}
@end
|