File: basic.m

package info (click to toggle)
gnustep-base 1.31.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,580 kB
  • sloc: objc: 239,446; ansic: 36,519; cpp: 122; sh: 112; makefile: 100; xml: 32
file content (46 lines) | stat: -rw-r--r-- 1,420 bytes parent folder | download | duplicates (2)
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
#import <Foundation/Foundation.h>
#import "Testing.h"
#import "ObjectTesting.h"

@interface DummyHandle : NSURLHandle
@end
@implementation DummyHandle
@end

int main()
{
  NSAutoreleasePool   *arp = [NSAutoreleasePool new];
  Class cls;
  NSURL *httpURL, *foobarURL;
  id handle1, handle2;


  httpURL = [NSURL URLWithString: @"http://www.gnustep.org"];
  foobarURL = [NSURL URLWithString: @"foobar://localhost/madeupscheme"];

  TEST_FOR_CLASS(@"NSURLHandle", AUTORELEASE([NSURLHandle alloc]),
    "NSURLHandle +alloc returns an NSURLHandle");

  PASS_EXCEPTION([DummyHandle cachedHandleForURL: httpURL];,
    NSInvalidArgumentException,
    "NSURLHandle subclass must implement +cachedHandleForURL:");

  cls = [NSURLHandle URLHandleClassForURL: httpURL];

  PASS([cls canInitWithURL: httpURL] == YES,
    "Appropriate subclass found for +URLHandleClassForURL:");
  handle1 = AUTORELEASE([[cls alloc] initWithURL: httpURL cached: YES]);
  handle2 = [NSURLHandle cachedHandleForURL: httpURL];

  PASS(handle2 != nil, "Available handle returned from cache");

#if	!defined(GNUSTEP_BASE_LIBRARY)
  PASS(NO, "URLHandleClassForURL: seems to hang on MacOS-X when given an unknown URL scheme ... you may want to check to see if it has been fixed");
#else
  cls = [NSURLHandle URLHandleClassForURL: foobarURL];
  PASS(cls == Nil, "Nil class returned for unknown URL scheme");
#endif

  [arp release]; arp = nil;
  return 0;
}