Overview
Comment: | Add tests for OFHTTPRequest. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3c4ae255a26715f1409ddee66b5dcdb2 |
User & Date: | js on 2011-03-07 16:03:43 |
Other Links: | manifest | tags |
Context
2011-03-10
| ||
19:54 | Call C++ constructors and destructors. check-in: 894658f979 user: js tags: trunk | |
2011-03-07
| ||
16:03 | Add tests for OFHTTPRequest. check-in: 3c4ae255a2 user: js tags: trunk | |
16:00 | Add class OFCondition. check-in: 615eb3e46b user: js tags: trunk | |
Changes
Modified tests/Makefile from [7f9ad25f85] to [2fa4a9dc0e].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFArrayTests.m \ ${OFBLOCKTESTS_M} \ OFDataArrayTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFFileTests.m \ OFListTests.m \ OFMD5HashTests.m \ OFNumberTests.m \ OFObjectTests.m \ ${OFPLUGINTESTS_M} \ OFSHA1HashTests.m \ OFStreamTests.m \ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFArrayTests.m \ ${OFBLOCKTESTS_M} \ OFDataArrayTests.m \ OFDateTests.m \ OFDictionaryTests.m \ OFFileTests.m \ OFHTTPRequestTests.m \ OFListTests.m \ OFMD5HashTests.m \ OFNumberTests.m \ OFObjectTests.m \ ${OFPLUGINTESTS_M} \ OFSHA1HashTests.m \ OFStreamTests.m \ |
︙ | ︙ |
Added tests/OFHTTPRequestTests.m version [c6dc023c7c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 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 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 | /* * Copyright (c) 2008, 2009, 2010, 2011 * Jonathan Schleifer <js@webkeks.org> * * 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. * * Alternatively, it may be distributed under the terms of the GNU General * 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" #include <stdlib.h> #include <string.h> #include <time.h> #include <assert.h> #import "OFHTTPRequest.h" #import "OFString.h" #import "OFThread.h" #import "OFTCPSocket.h" #import "OFURL.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" static OFString *module = @"OFHTTPRequest"; static OFCondition *cond; @interface OFHTTPRequestTestsServer: OFThread { @public uint16_t port; } @end @implementation OFHTTPRequestTestsServer - main { OFTCPSocket *listener, *client; [cond lock]; listener = [OFTCPSocket socket]; [listener bindToPort: port onHost: @"127.0.0.1"]; [listener listen]; [cond signal]; [cond unlock]; client = [listener accept]; if (![[client readLine] isEqual: @"GET /foo HTTP/1.0"]) assert(0); if (![[client readLine] isEqual: [OFString stringWithFormat: @"Host: 127.0.0.1:%" @PRIu16, port]]) assert(0); if (![[client readLine] hasPrefix: @"User-Agent:"]) assert(0); if (![[client readLine] isEqual: @""]) assert(0); [client writeString: @"HTTP/1.0 200 OK\r\n" @"Content-Length: 7\r\n" @"\r\n" @"foo\n" @"bar"]; [client close]; return nil; } @end @implementation TestsAppDelegate (OFHTTPRequesTests) - (void)HTTPRequestTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFHTTPRequestTestsServer *server; OFURL *url; OFHTTPRequest *req; OFHTTPRequestResult *res; cond = [OFCondition condition]; [cond lock]; server = [[[OFHTTPRequestTestsServer alloc] init] autorelease]; /* srand(time(NULL)) was already called by OFTCPSocket */ server->port = (uint16_t)rand(); if (server->port < 1024) server->port += 1024; [server start]; url = [OFURL URLWithString: [OFString stringWithFormat: @"http://127.0.0.1:%" @PRIu16 "/foo", server->port]]; TEST(@"+[request]", (req = [OFHTTPRequest request])) TEST(@"-[setURL:]", R([req setURL: url])) [cond wait]; [cond unlock]; TEST(@"-[perform]", (res = [req perform])) [server join]; [pool drain]; } @end |
Modified tests/TestsAppDelegate.h from [a04c79d77f] to [fc5dd537d5].
︙ | ︙ | |||
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | @interface TestsAppDelegate (OFDictionaryTests) - (void)dictionaryTests; @end @interface TestsAppDelegate (OFFileTests) - (void)fileTests; @end @interface TestsAppDelegate (OFListTests) - (void)listTests; @end @interface TestsAppDelegate (OFMD5HashTests) - (void)MD5HashTests; | > > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | @interface TestsAppDelegate (OFDictionaryTests) - (void)dictionaryTests; @end @interface TestsAppDelegate (OFFileTests) - (void)fileTests; @end @interface TestsAppDelegate (OFHTTPRequestTests) - (void)HTTPRequestTests; @end @interface TestsAppDelegate (OFListTests) - (void)listTests; @end @interface TestsAppDelegate (OFMD5HashTests) - (void)MD5HashTests; |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [a3fd31c5d3] to [43bd7328ba].
︙ | ︙ | |||
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | [self numberTests]; [self streamTests]; [self TCPSocketTests]; #ifdef OF_THREADS [self threadTests]; #endif [self URLTests]; [self XMLElementTests]; [self XMLParserTests]; [self XMLElementBuilderTests]; #ifdef OF_PLUGINS [self pluginTests]; #endif #ifdef OF_HAVE_PROPERTIES | > > > | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | [self numberTests]; [self streamTests]; [self TCPSocketTests]; #ifdef OF_THREADS [self threadTests]; #endif [self URLTests]; #ifdef OF_THREADS [self HTTPRequestTests]; #endif [self XMLElementTests]; [self XMLParserTests]; [self XMLElementBuilderTests]; #ifdef OF_PLUGINS [self pluginTests]; #endif #ifdef OF_HAVE_PROPERTIES |
︙ | ︙ |