29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
OFUNIXDatagramSocket *sock;
OFSocketAddress address1, address2;
char buffer[5];
path = [[OFSystemInfo temporaryDirectoryPath]
stringByAppendingPathComponent: [[OFUUID UUID] UUIDString]];
TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))
TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path]))
TEST(@"-[sendBuffer:length:receiver:]",
R([sock sendBuffer: "Hello" length: 5 receiver: &address1]))
TEST(@"-[receiveIntoBuffer:length:sender:]",
[sock receiveIntoBuffer: buffer length: 5 sender: &address2] == 5 &&
memcmp(buffer, "Hello", 5) == 0 &&
OFSocketAddressEqual(&address1, &address2) &&
OFSocketAddressHash(&address1) == OFSocketAddressHash(&address2))
objc_autoreleasePoolPop(pool);
}
@end
|
>
|
|
|
|
|
|
>
>
|
|
|
>
>
>
>
|
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
|
OFUNIXDatagramSocket *sock;
OFSocketAddress address1, address2;
char buffer[5];
path = [[OFSystemInfo temporaryDirectoryPath]
stringByAppendingPathComponent: [[OFUUID UUID] UUIDString]];
@try {
TEST(@"+[socket]", (sock = [OFUNIXDatagramSocket socket]))
TEST(@"-[bindToPath:]", R(address1 = [sock bindToPath: path]))
TEST(@"-[sendBuffer:length:receiver:]",
R([sock sendBuffer: "Hello" length: 5 receiver: &address1]))
TEST(@"-[receiveIntoBuffer:length:sender:]",
[sock receiveIntoBuffer: buffer
length: 5
sender: &address2] == 5 &&
memcmp(buffer, "Hello", 5) == 0 &&
OFSocketAddressEqual(&address1, &address2) &&
OFSocketAddressHash(&address1) ==
OFSocketAddressHash(&address2))
} @finally {
[[OFFileManager defaultManager] removeItemAtPath: path];
}
objc_autoreleasePoolPop(pool);
}
@end
|