mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +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/NSURLRequest/basic.m
Normal file
50
Tests/base/NSURLRequest/basic.m
Normal file
|
@ -0,0 +1,50 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "Testing.h"
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSURLRequest *request;
|
||||
NSMutableURLRequest *mutable;
|
||||
NSURL *httpURL, *foobarURL;
|
||||
|
||||
httpURL = [NSURL URLWithString: @"http://www.gnustep.org"];
|
||||
foobarURL = [NSURL URLWithString: @"foobar://localhost/madeupscheme"];
|
||||
|
||||
TEST_FOR_CLASS(@"NSURLRequest", [NSURLRequest alloc],
|
||||
"NSURLRequest +alloc returns an NSURLRequest");
|
||||
|
||||
request = [NSURLRequest requestWithURL: httpURL];
|
||||
PASS(request != nil,
|
||||
"NSURLRequest +requestWithURL returns a request from a valid URL");
|
||||
PASS_EQUAL([[request URL] absoluteString], [httpURL absoluteString],
|
||||
"Request URL is equal to the URL used for creation");
|
||||
PASS_EQUAL([request HTTPMethod], @"GET",
|
||||
"Request is initialized with a GET method");
|
||||
|
||||
request = [NSURLRequest requestWithURL: foobarURL];
|
||||
PASS(request != nil,
|
||||
"NSURLRequest +requestWithURL returns a request from an invalid URL (unknown scheme)");
|
||||
|
||||
mutable = [request mutableCopy];
|
||||
PASS(mutable != nil && [mutable isKindOfClass:[NSMutableURLRequest class]],
|
||||
"NSURLRequest -mutableCopy returns a mutable request");
|
||||
[mutable setHTTPMethod: @"POST"];
|
||||
PASS_EQUAL([mutable HTTPMethod], @"POST",
|
||||
"Can setHTTPMethod of a mutable request (POST)");
|
||||
[mutable setHTTPMethod: @"NONHTTPMETHOD"];
|
||||
PASS_EQUAL([mutable HTTPMethod], @"NONHTTPMETHOD",
|
||||
"Can setHTTPMethod of a mutable request (non existant NONHTTPMETHOD)");
|
||||
|
||||
[mutable addValue: @"value1" forHTTPHeaderField: @"gnustep"];
|
||||
PASS_EQUAL([mutable valueForHTTPHeaderField: @"gnustep"], @"value1",
|
||||
"Can set and get a value for an HTTP header field");
|
||||
[mutable addValue: @"value2" forHTTPHeaderField: @"gnustep"];
|
||||
PASS([mutable valueForHTTPHeaderField: @"gnustep"], @"value1,value2",
|
||||
"Handle multiple values for an HTTP header field");
|
||||
[mutable release];
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue