Overview
Comment: | Migrate OFSocketTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
10ece67a08c4a083f83dc5e2e467be9d |
User & Date: | js on 2024-02-11 16:23:00 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-11
| ||
17:13 | Migrate OFJSONTests to ObjFWTest check-in: ce1f7a4088 user: js tags: objfwtest | |
16:23 | Migrate OFSocketTests to ObjFWTest check-in: 10ece67a08 user: js tags: objfwtest | |
15:49 | Migrate OFMatrix4x4Tests to ObjFWTest check-in: 6d64cca782 user: js tags: objfwtest | |
Changes
Modified new_tests/Makefile from [056044a35b] to [d64542647f].
︙ | ︙ | |||
9 10 11 12 13 14 15 | OFInvocationTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ | | > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | OFInvocationTests.m \ OFMatrix4x4Tests.m \ OFMethodSignatureTests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFSocketTests.m include ../buildsys.mk .PHONY: run run-on-ios run-on-android run: rm -f libobjfw.so.${OBJFW_LIB_MAJOR} rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} |
︙ | ︙ |
Renamed and modified tests/OFSocketTests.m [2289bf230f] to new_tests/OFSocketTests.m [b6fe3d8b77].
︙ | ︙ | |||
11 12 13 14 15 16 17 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" | | > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFSocketTests: OTTestCase @end #define COMPARE_V6(a, a0, a1, a2, a3, a4, a5, a6, a7) \ (a.sockaddr.in6.sin6_addr.s6_addr[0] == (a0 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[1] == (a0 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[2] == (a1 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[3] == (a1 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[4] == (a2 >> 8) && \ |
︙ | ︙ | |||
48 49 50 51 52 53 54 | a.sockaddr.in6.sin6_addr.s6_addr[10] = a5 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[11] = a5 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[12] = a6 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[13] = a6 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[14] = a7 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[15] = a7 & 0xFF; | < < | | < | < < | > | | | > > | > < | > < | > < | > > | > | > | | > > | | | | > > > > | | | > > > > | | | | | < | | | < | | | < | | | < | | | < | | | | < | | | < | | | | | > > | > < | > < | > < | > < | > > | < < | > < | > > | > | > | | > > | | | | > | > | < | | < | | < | | < | | > | < | | | < | | > | < | | | < | | | < > | | < | | < > > > | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | a.sockaddr.in6.sin6_addr.s6_addr[10] = a5 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[11] = a5 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[12] = a6 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[13] = a6 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[14] = a7 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[15] = a7 & 0xFF; @implementation OFSocketTests - (void)testParseIPv4 { OFSocketAddress address = OFSocketAddressParseIP(@"127.0.0.1", 1234); OTAssertEqual(OFFromBigEndian32(address.sockaddr.in.sin_addr.s_addr), 0x7F000001); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in.sin_port), 1234); } - (void)testParseRejectsInvalidIPv4 { OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.0.0.1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.0.256", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.0. 1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@" 127.0.0.1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0.a.1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"127.0..1", 1234), OFInvalidFormatException); } - (void)testPortForIPv4 { OFSocketAddress address = OFSocketAddressParseIP(@"127.0.0.1", 1234); OTAssertEqual(OFSocketAddressIPPort(&address), 1234); } - (void)testStringForIPv4 { OFSocketAddress address = OFSocketAddressParseIP(@"127.0.0.1", 1234); OTAssertEqualObjects(OFSocketAddressString(&address), @"127.0.0.1"); } - (void)testParseIPv6 { OFSocketAddress address; address = OFSocketAddressParseIP( @"1122:3344:5566:7788:99aa:bbCc:ddee:ff00", 1234); OTAssert(COMPARE_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"::", 1234); OTAssert(COMPARE_V6(address, 0, 0, 0, 0, 0, 0, 0, 0)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"aaAa::bBbb", 1234); OTAssert(COMPARE_V6(address, 0xAAAA, 0, 0, 0, 0, 0, 0, 0xBBBB)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"aaAa::", 1234); OTAssert(COMPARE_V6(address, 0xAAAA, 0, 0, 0, 0, 0, 0, 0)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"::aaAa", 1234); OTAssert(COMPARE_V6(address, 0, 0, 0, 0, 0, 0, 0, 0xAAAA)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"fd00::1%123", 1234); OTAssert(COMPARE_V6(address, 0xFD00, 0, 0, 0, 0, 0, 0, 1)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); OTAssertEqual(address.sockaddr.in6.sin6_scope_id, 123); address = OFSocketAddressParseIP(@"::ffff:127.0.0.1", 1234); OTAssert(COMPARE_V6(address, 0, 0, 0, 0, 0, 0xFFFF, 0x7F00, 1)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); address = OFSocketAddressParseIP(@"64:ff9b::127.0.0.1", 1234); OTAssert(COMPARE_V6(address, 0x64, 0xFF9B, 0, 0, 0, 0, 0x7F00, 1)); OTAssertEqual(OFFromBigEndian16(address.sockaddr.in6.sin6_port), 1234); } - (void)testParseRejectsInvalidIPv6 { OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:::2", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1: ::2", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:: :2", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1::2::3", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"10000::1", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"::10000", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"::1::", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:2:3:4:5:6:7:", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:2:3:4:5:6:7::", 1234), OFInvalidFormatException); OTAssertThrowsSpecific(OFSocketAddressParseIP(@"1:2", 1234), OFInvalidFormatException); } - (void)testPortForIPv6 { OFSocketAddress address = OFSocketAddressParseIP(@"::", 1234); OTAssertEqual(OFSocketAddressIPPort(&address), 1234); } - (void)testStringForIPv6 { OFSocketAddress address = OFSocketAddressParseIP(@"::", 1234); OTAssertEqualObjects(OFSocketAddressString(&address), @"::"); SET_V6(address, 0, 0, 0, 0, 0, 0, 0, 1) OTAssertEqualObjects(OFSocketAddressString(&address), @"::1"); SET_V6(address, 1, 0, 0, 0, 0, 0, 0, 0) OTAssertEqualObjects(OFSocketAddressString(&address), @"1::"); SET_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"1122:3344:5566:7788:99aa:bbcc:ddee:ff00"); SET_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0) OTAssertEqualObjects(OFSocketAddressString(&address), @"1122:3344:5566:7788:99aa:bbcc:ddee:0"); SET_V6(address, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0, 0) OTAssertEqualObjects(OFSocketAddressString(&address), @"1122:3344:5566:7788:99aa:bbcc::"); SET_V6(address, 0, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"0:3344:5566:7788:99aa:bbcc:ddee:ff00"); SET_V6(address, 0, 0, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"::5566:7788:99aa:bbcc:ddee:ff00"); SET_V6(address, 0, 0, 0x5566, 0, 0, 0, 0xDDEE, 0xFF00) OTAssertEqualObjects(OFSocketAddressString(&address), @"0:0:5566::ddee:ff00"); SET_V6(address, 0, 0, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0, 0) 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 |
Modified tests/Makefile from [7a75fde9e9] to [f5a669cb71].
︙ | ︙ | |||
56 57 58 59 60 61 62 | testfile_bin.m \ testfile_ini.m SRCS_SOCKETS = OFDNSResolverTests.m \ ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieTests.m \ OFHTTPCookieManagerTests.m \ OFKernelEventObserverTests.m \ | < | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | testfile_bin.m \ testfile_ini.m SRCS_SOCKETS = OFDNSResolverTests.m \ ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieTests.m \ OFHTTPCookieManagerTests.m \ OFKernelEventObserverTests.m \ OFTCPSocketTests.m \ OFUDPSocketTests.m \ ${USE_SRCS_APPLETALK} \ ${USE_SRCS_IPX} \ ${USE_SRCS_UNIX_SOCKETS} SRCS_APPLETALK = OFDDPSocketTests.m SRCS_IPX = OFIPXSocketTests.m \ |
︙ | ︙ |
Modified tests/TestsAppDelegate.h from [62b9475833] to [05e2d95af6].
︙ | ︙ | |||
191 192 193 194 195 196 197 | - (void)setTests; @end @interface TestsAppDelegate (OFSystemInfoTests) - (void)systemInfoTests; @end | < < < < | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | - (void)setTests; @end @interface TestsAppDelegate (OFSystemInfoTests) - (void)systemInfoTests; @end @interface TestsAppDelegate (OFStreamTests) - (void)streamTests; @end @interface TestsAppDelegate (OFStringTests) - (void)stringTests; @end |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [3a33bc9fe5] to [632436b2c9].
︙ | ︙ | |||
398 399 400 401 402 403 404 | [self SHA384HashTests]; [self SHA512HashTests]; [self HMACTests]; #ifdef HAVE_CODEPAGE_437 [self INIFileTests]; #endif #ifdef OF_HAVE_SOCKETS | < | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | [self SHA384HashTests]; [self SHA512HashTests]; [self HMACTests]; #ifdef HAVE_CODEPAGE_437 [self INIFileTests]; #endif #ifdef OF_HAVE_SOCKETS [self TCPSocketTests]; [self UDPSocketTests]; # ifdef OF_HAVE_UNIX_SOCKETS [self UNIXDatagramSocketTests]; [self UNIXStreamSocketTests]; # endif # ifdef OF_HAVE_IPX |
︙ | ︙ |