29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
+
-
-
+
-
-
-
+
+
|
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 = [server bindToHost: @"127.0.0.1" port: 0]))
port: 0]))
TEST(@"-[listen]", R([server listen]))
TEST(@"-[connectToHost:port:]",
R([client connectToHost: @"127.0.0.1"
R([client connectToHost: @"127.0.0.1" port: port]))
port: port]))
TEST(@"-[accept]", (accepted = [server accept]))
TEST(@"-[remoteAddress]",
[of_socket_address_ip_string(accepted.remoteAddress, NULL)
isEqual: @"127.0.0.1"])
TEST(@"-[writeString:]", [client writeString: @"Hello!"])
TEST(@"-[readIntoBuffer:length:]", [accepted readIntoBuffer: buf
length: 6] &&
TEST(@"-[readIntoBuffer:length:]",
[accepted readIntoBuffer: buf length: 6] &&
!memcmp(buf, "Hello!", 6))
objc_autoreleasePoolPop(pool);
}
@end
|