ObjFW  Check-in [4e06901c84]

Overview
Comment:Migrate OFUDPSocketTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 4e06901c8408d80ea245f3a9fa166c0d4218a8f561879be1009979c560a23d37
User & Date: js on 2024-02-13 23:12:52
Other Links: branch diff | manifest | tags
Context
2024-02-13
23:41
ObjFWTest: Add OTSkip() check-in: f45bd96383 user: js tags: objfwtest
23:12
Migrate OFUDPSocketTests to ObjFWTest check-in: 4e06901c84 user: js tags: objfwtest
23:02
Migrate OFTCPSocketTests to ObjFWTest check-in: d3b3fd8845 user: js tags: objfwtest
Changes

Modified new_tests/Makefile from [39562aeab7] to [56338b20e7].

45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m
SRCS_SOCKETS = OFDNSResolverTests.m	\
	       OFSocketTests.m		\
	       OFTCPSocketTests.m

SRCS_SUBPROCESSES = OFSubprocessTests.m
SRCS_THREADS = OFThreadTests.m

include ../buildsys.mk

testfile_bin.m: testfile.bin
	${SHELL} ../utils/objfw-embed testfile.bin testfile.bin $@







|
>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m
SRCS_SOCKETS = OFDNSResolverTests.m	\
	       OFSocketTests.m		\
	       OFTCPSocketTests.m	\
	       OFUDPSocketTests.m
SRCS_SUBPROCESSES = OFSubprocessTests.m
SRCS_THREADS = OFThreadTests.m

include ../buildsys.mk

testfile_bin.m: testfile.bin
	${SHELL} ../utils/objfw-embed testfile.bin testfile.bin $@

Modified new_tests/OFSocketTests.m from [b6fe3d8b77] to [a25ea91bad].

224
225
226
227
228
229
230





















231
	OTAssertEqualObjects(OFSocketAddressString(&address),
	    @"::5566:7788:99aa:bbcc:0:0");

	address.sockaddr.in6.sin6_scope_id = 123;
	OTAssertEqualObjects(OFSocketAddressString(&address),
	    @"::5566:7788:99aa:bbcc:0:0%123");
}





















@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
	OTAssertEqualObjects(OFSocketAddressString(&address),
	    @"::5566:7788:99aa:bbcc:0:0");

	address.sockaddr.in6.sin6_scope_id = 123;
	OTAssertEqualObjects(OFSocketAddressString(&address),
	    @"::5566:7788:99aa:bbcc:0:0%123");
}

- (void)testAddressEqual
{
	OFSocketAddress addr1 = OFSocketAddressParseIP(@"127.0.0.1", 1234);
	OFSocketAddress addr2 = OFSocketAddressParseIP(@"127.0.0.1", 1234);
	OFSocketAddress addr3 = OFSocketAddressParseIP(@"127.0.0.1", 1235);

	OTAssertTrue(OFSocketAddressEqual(&addr1, &addr2));
	OTAssertFalse(OFSocketAddressEqual(&addr1, &addr3));
}

- (void)testAddressHash
{
	OFSocketAddress addr1 = OFSocketAddressParseIP(@"127.0.0.1", 1234);
	OFSocketAddress addr2 = OFSocketAddressParseIP(@"127.0.0.1", 1234);
	OFSocketAddress addr3 = OFSocketAddressParseIP(@"127.0.0.1", 1235);

	OTAssertEqual(OFSocketAddressHash(&addr1), OFSocketAddressHash(&addr2));
	OTAssertNotEqual(OFSocketAddressHash(&addr1),
	    OFSocketAddressHash(&addr3));
}
@end

Renamed and modified tests/OFUDPSocketTests.m [9c08c02308] to new_tests/OFUDPSocketTests.m [b806dc5c9a].

13
14
15
16
17
18
19
20

21
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
 * file.
 */

#include "config.h"

#include <string.h>

#import "TestsAppDelegate.h"


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







|
>

|
>

|
|

<
|
|
|

|

<
|
>

<
|

<
|
|
|
|
<
<
|
|
<
<
<
<
<
<
<
<
<
<

13
14
15
16
17
18
19
20
21
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
 * file.
 */

#include "config.h"

#include <string.h>

#import "ObjFW.h"
#import "ObjFWTest.h"

@interface OFUDPSocketTests: OTTestCase
@end

@implementation OFUDPSocketTests
- (void)testUDPSocket
{

	OFUDPSocket *sock = [OFUDPSocket socket];
	OFSocketAddress addr1, addr2;
	char buffer[6];

	sock = [OFUDPSocket socket];


	addr1 = [sock bindToHost: @"127.0.0.1" port: 0];
	OTAssertEqualObjects(OFSocketAddressString(&addr1), @"127.0.0.1");


	[sock sendBuffer: "Hello" length: 6 receiver: &addr1];


	[sock receiveIntoBuffer: buffer length: 6 sender: &addr2];
	OTAssertEqual(memcmp(buffer, "Hello", 6), 0);
	OTAssertEqualObjects(OFSocketAddressString(&addr2), @"127.0.0.1");
	OTAssertEqual(OFSocketAddressIPPort(&addr2),


	    OFSocketAddressIPPort(&addr1));
}










@end

Modified tests/Makefile from [04f2449df8] to [f4cad188bb].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_WINDOWS}
SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M}	\
	       OFHTTPCookieTests.m		\
	       OFHTTPCookieManagerTests.m	\
	       OFKernelEventObserverTests.m	\
	       OFUDPSocketTests.m		\
	       ${USE_SRCS_APPLETALK}		\
	       ${USE_SRCS_IPX}			\
	       ${USE_SRCS_UNIX_SOCKETS}
SRCS_APPLETALK = OFDDPSocketTests.m
SRCS_IPX = OFIPXSocketTests.m		\
	   OFSPXSocketTests.m		\
	   OFSPXStreamSocketTests.m







<







30
31
32
33
34
35
36

37
38
39
40
41
42
43
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_WINDOWS}
SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M}	\
	       OFHTTPCookieTests.m		\
	       OFHTTPCookieManagerTests.m	\
	       OFKernelEventObserverTests.m	\

	       ${USE_SRCS_APPLETALK}		\
	       ${USE_SRCS_IPX}			\
	       ${USE_SRCS_UNIX_SOCKETS}
SRCS_APPLETALK = OFDDPSocketTests.m
SRCS_IPX = OFIPXSocketTests.m		\
	   OFSPXSocketTests.m		\
	   OFSPXStreamSocketTests.m

Modified tests/TestsAppDelegate.h from [982bac2ab3] to [748439022d].

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
- (void)streamTests;
@end

@interface TestsAppDelegate (OFStringTests)
- (void)stringTests;
@end

@interface TestsAppDelegate (OFUDPSocketTests)
- (void)UDPSocketTests;
@end

@interface TestsAppDelegate (OFUNIXDatagramSocketTests)
- (void)UNIXDatagramSocketTests;
@end

@interface TestsAppDelegate (OFUNIXStreamSocketTests)
- (void)UNIXStreamSocketTests;
@end







<
<
<
<







123
124
125
126
127
128
129




130
131
132
133
134
135
136
- (void)streamTests;
@end

@interface TestsAppDelegate (OFStringTests)
- (void)stringTests;
@end





@interface TestsAppDelegate (OFUNIXDatagramSocketTests)
- (void)UNIXDatagramSocketTests;
@end

@interface TestsAppDelegate (OFUNIXStreamSocketTests)
- (void)UNIXStreamSocketTests;
@end

Modified tests/TestsAppDelegate.m from [9816b74668] to [bf28d3b6ff].

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
	[self dictionaryTests];
	[self listTests];
	[self valueTests];
	[self streamTests];
	[self memoryStreamTests];
	[self notificationCenterTests];
#ifdef OF_HAVE_SOCKETS
	[self UDPSocketTests];
# ifdef OF_HAVE_UNIX_SOCKETS
	[self UNIXDatagramSocketTests];
	[self UNIXStreamSocketTests];
# endif
# ifdef OF_HAVE_IPX
	[self IPXSocketTests];
	[self SPXSocketTests];







<







379
380
381
382
383
384
385

386
387
388
389
390
391
392
	[self dictionaryTests];
	[self listTests];
	[self valueTests];
	[self streamTests];
	[self memoryStreamTests];
	[self notificationCenterTests];
#ifdef OF_HAVE_SOCKETS

# ifdef OF_HAVE_UNIX_SOCKETS
	[self UNIXDatagramSocketTests];
	[self UNIXStreamSocketTests];
# endif
# ifdef OF_HAVE_IPX
	[self IPXSocketTests];
	[self SPXSocketTests];