2001-06-21 04:52:12 +00:00
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
#include <stdio.h>
|
1996-05-28 18:33:00 +00:00
|
|
|
|
2000-09-22 13:45:58 +00:00
|
|
|
|
2001-06-21 04:52:12 +00:00
|
|
|
#if 1
|
2002-08-24 06:00:44 +00:00
|
|
|
|
|
|
|
static void test1(void)
|
|
|
|
{
|
|
|
|
NSURL *baseURL = [NSURL fileURLWithPath:@"/usr/local/bin"];
|
|
|
|
NSURL *url = [NSURL URLWithString:@"filename" relativeToURL:baseURL];
|
|
|
|
NSString *result = [url absoluteString];
|
|
|
|
NSString *expected = @"file:/usr/local/bin/filename";
|
|
|
|
|
|
|
|
if ([result isEqualToString:expected])
|
|
|
|
NSLog(@"test 1 ok");
|
|
|
|
else
|
|
|
|
NSLog(@"-[NSURL absoluteString] returned \"%@\", expected \"%@\"", result, expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test2(void)
|
|
|
|
{
|
|
|
|
NSURL *url = [NSURL fileURLWithPath:@"/tmp/foo"];
|
|
|
|
NSString *result = [url path];
|
|
|
|
NSString *expected = @"/tmp/foo";
|
|
|
|
|
|
|
|
if ([result isEqualToString:expected])
|
|
|
|
NSLog(@"Test 2 ok");
|
|
|
|
else
|
|
|
|
NSLog(@"-[NSURL path] returned \"%@\", expected \"%@\"", result, expected);
|
|
|
|
}
|
|
|
|
|
2001-06-21 04:52:12 +00:00
|
|
|
int main ()
|
1996-05-28 18:33:00 +00:00
|
|
|
{
|
2001-06-21 04:52:12 +00:00
|
|
|
id pool = [NSAutoreleasePool new];
|
2001-07-07 04:36:01 +00:00
|
|
|
id o = [NSObject new];
|
2002-04-05 16:26:47 +00:00
|
|
|
NSArray *a = [NSArray arrayWithObjects: @"a", @"b", nil];
|
|
|
|
|
2002-08-24 06:00:44 +00:00
|
|
|
|
|
|
|
test1();
|
|
|
|
test2();
|
|
|
|
|
2001-06-21 04:52:12 +00:00
|
|
|
printf ("Hello from object at 0x%x\n", (unsigned)[o self]);
|
2001-07-07 04:36:01 +00:00
|
|
|
|
2002-04-05 16:26:47 +00:00
|
|
|
NSLog(@"Value for foo is %@", [a valueForKey: @"foo"]);
|
|
|
|
|
2002-03-27 09:55:57 +00:00
|
|
|
[o release];
|
2001-07-07 04:36:01 +00:00
|
|
|
o = [NSString stringWithFormat: @"/proc/%d/status", getpid()];
|
|
|
|
NSLog(@"'%@'", o);
|
|
|
|
o = [NSString stringWithContentsOfFile: o];
|
|
|
|
NSLog(@"'%@'", o);
|
|
|
|
|
2001-06-21 04:52:12 +00:00
|
|
|
exit (0);
|
1996-05-28 18:33:00 +00:00
|
|
|
}
|
2001-06-21 04:52:12 +00:00
|
|
|
#else
|
|
|
|
int main (int argc, char **argv)
|
2000-09-20 13:48:49 +00:00
|
|
|
{
|
2001-06-21 04:52:12 +00:00
|
|
|
NSString *string;
|
|
|
|
id pool = [NSAutoreleasePool new];
|
|
|
|
NSProcessInfo *info = [NSProcessInfo processInfo];
|
|
|
|
NSUserDefaults *defaults;
|
|
|
|
|
|
|
|
NSLog(@"Temporary directory - %@", NSTemporaryDirectory());
|
|
|
|
[info setProcessName: @"TestProcess"];
|
|
|
|
defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSLog(@"%@", [defaults dictionaryRepresentation]);
|
|
|
|
return 0;
|
2000-09-20 13:48:49 +00:00
|
|
|
}
|
2001-06-21 04:52:12 +00:00
|
|
|
#endif
|