mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
import testsuite
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32187 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
48cc36811f
commit
b179b29898
374 changed files with 20864 additions and 0 deletions
50
Tests/base/NSURLConnection/basic.m
Normal file
50
Tests/base/NSURLConnection/basic.m
Normal file
|
@ -0,0 +1,50 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "Testing.h"
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSMutableURLRequest *mutable;
|
||||
NSURLConnection *connection;
|
||||
NSURLResponse *response;
|
||||
NSError *error;
|
||||
NSData *data;
|
||||
NSURL *httpURL;
|
||||
NSString *path;
|
||||
|
||||
httpURL = [NSURL URLWithString: @"http://www.gnustep.org"];
|
||||
|
||||
TEST_FOR_CLASS(@"NSURLConnection", [NSURLConnection alloc],
|
||||
"NSURLConnection +alloc returns an NSURLConnection");
|
||||
|
||||
mutable = [NSMutableURLRequest requestWithURL: httpURL];
|
||||
PASS([NSURLConnection canHandleRequest: mutable],
|
||||
"NSURLConnection can handle an valid HTTP request (GET)");
|
||||
[mutable setHTTPMethod: @"WRONGMETHOD"];
|
||||
PASS([NSURLConnection canHandleRequest: mutable],
|
||||
"NSURLConnection can handle an invalid HTTP request (WRONGMETHOD)");
|
||||
|
||||
[mutable setHTTPMethod: @"GET"];
|
||||
connection = [NSURLConnection connectionWithRequest: mutable delegate: nil];
|
||||
PASS(connection != nil,
|
||||
"NSURLConnection +connectionWithRequest: delegate: with nil as delegate returns a instance");
|
||||
|
||||
data = [NSURLConnection sendSynchronousRequest: mutable
|
||||
returningResponse: &response
|
||||
error: &error];
|
||||
PASS(data != nil && [data length] > 0,
|
||||
"NSURLConnection synchronously load data from an http URL");
|
||||
|
||||
path = [[NSFileManager defaultManager] currentDirectoryPath];
|
||||
path = [path stringByAppendingPathComponent: @"basic.m"];
|
||||
[mutable setURL: [NSURL fileURLWithPath: path]];
|
||||
data = [NSURLConnection sendSynchronousRequest: mutable
|
||||
returningResponse: &response
|
||||
error: &error];
|
||||
PASS(data != nil && [data length] > 0,
|
||||
"NSURLConnection synchronously load data from a local file");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue