Differences From Artifact [435a3297c3]:
- File
tests/OFUDPSocketTests.m
— part of check-in
[a54730b88f]
at
2022-10-22 18:41:45
on branch trunk
— OFSocket: Don't combine port for IP and IPX
While it works for those two protocols, it's a bad precedent as other
protocols have different types for ports. (user: js, size: 1908) [annotate] [blame] [check-ins using] [more...]
To Artifact [8fc77398a2]:
- File tests/OFUDPSocketTests.m — part of check-in [65154c2576] at 2023-05-21 10:04:22 on branch trunk — OFUDPSocket: Return socket address bound to (user: js, size: 1776) [annotate] [blame] [check-ins using] [more...]
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * |
︙ | ︙ | |||
22 23 24 25 26 27 28 | static OFString *const module = @"OFUDPSocket"; @implementation TestsAppDelegate (OFUDPSocketTests) - (void)UDPSocketTests { void *pool = objc_autoreleasePoolPush(); OFUDPSocket *sock; | < | < < | | > < < < < | 22 23 24 25 26 27 28 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 | static OFString *const module = @"OFUDPSocket"; @implementation TestsAppDelegate (OFUDPSocketTests) - (void)UDPSocketTests { void *pool = objc_autoreleasePoolPush(); OFUDPSocket *sock; OFSocketAddress addr1, addr2, addr3; char buf[6]; TEST(@"+[socket]", (sock = [OFUDPSocket socket])) TEST(@"-[bindToHost:port:]", R(addr1 = [sock bindToHost: @"127.0.0.1" port: 0])) TEST(@"-[sendBuffer:length:receiver:]", R([sock sendBuffer: "Hello" length: 6 receiver: &addr1])) TEST(@"-[receiveIntoBuffer:length:sender:]", [sock receiveIntoBuffer: buf length: 6 sender: &addr2] == 6 && !memcmp(buf, "Hello", 6) && [OFSocketAddressString(&addr2) isEqual: @"127.0.0.1"] && OFSocketAddressIPPort(&addr2) == OFSocketAddressIPPort(&addr1)) addr3 = OFSocketAddressParseIP(@"127.0.0.1", OFSocketAddressIPPort(&addr1) + 1); TEST(@"OFSocketAddressEqual()", OFSocketAddressEqual(&addr1, &addr2) && !OFSocketAddressEqual(&addr1, &addr3)) TEST(@"OFSocketAddressHash()", OFSocketAddressHash(&addr1) == OFSocketAddressHash(&addr2) && OFSocketAddressHash(&addr1) != OFSocketAddressHash(&addr3)) objc_autoreleasePoolPop(pool); } @end |