aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMPathTest.m
diff options
context:
space:
mode:
Diffstat (limited to 'Foundation/GTMPathTest.m')
-rw-r--r--Foundation/GTMPathTest.m62
1 files changed, 31 insertions, 31 deletions
diff --git a/Foundation/GTMPathTest.m b/Foundation/GTMPathTest.m
index 308cc73..54fa83b 100644
--- a/Foundation/GTMPathTest.m
+++ b/Foundation/GTMPathTest.m
@@ -35,9 +35,9 @@
- (void)setUp {
NSFileManager *mgr = [NSFileManager defaultManager];
- testDirectory_
+ testDirectory_
= [[mgr gtm_createTemporaryDirectoryBasedOn:@"GTMPathTestXXXXXX"] retain];
-
+
STAssertNotNil(testDirectory_, nil);
}
@@ -45,7 +45,7 @@
// Make sure it's safe to remove this directory before nuking it.
STAssertNotNil(testDirectory_, nil);
STAssertNotEqualObjects(testDirectory_, @"/", nil);
-#if GTM_MACOSX_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
+#if GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
[[NSFileManager defaultManager] removeFileAtPath:testDirectory_ handler:nil];
#else
[[NSFileManager defaultManager] removeItemAtPath:testDirectory_ error:NULL];
@@ -55,10 +55,10 @@
- (void)testBasicCreation {
GTMPath *path = nil;
-
+
path = [[[GTMPath alloc] init] autorelease];
STAssertNil(path, nil);
-
+
path = [GTMPath pathWithFullPath:@"/"];
STAssertNotNil(path, nil);
STAssertNil([path parent], nil);
@@ -70,16 +70,16 @@
- (void)testRecursiveInitialization {
GTMPath *path = nil;
-
+
path = [GTMPath pathWithFullPath:nil];
STAssertNil(path, nil);
-
+
path = [GTMPath pathWithFullPath:@""];
STAssertNil(path, nil);
-
+
path = [GTMPath pathWithFullPath:@"etc"];
STAssertNil(path, nil);
-
+
path = [GTMPath pathWithFullPath:@"/"];
STAssertNotNil(path, nil);
STAssertNil([path parent], nil);
@@ -87,7 +87,7 @@
STAssertTrue([path isDirectory], nil);
STAssertEqualObjects([path name], @"/", nil);
STAssertEqualObjects([path fullPath], @"/", nil);
-
+
path = [GTMPath pathWithFullPath:@"/etc"];
STAssertNotNil(path, nil);
STAssertEqualObjects([path name], @"etc", nil);
@@ -96,7 +96,7 @@
STAssertFalse([path isRoot], nil);
STAssertNotNil([path parent], nil);
STAssertTrue([[path parent] isRoot], nil);
-
+
path = [GTMPath pathWithFullPath:@"/etc/passwd"];
STAssertNotNil(path, nil);
STAssertEqualObjects([path name], @"passwd", nil);
@@ -107,22 +107,22 @@
STAssertFalse([[path parent] isRoot], nil);
STAssertTrue([[path parent] isDirectory], nil);
STAssertTrue([[[path parent] parent] isRoot], nil);
-
+
STAssertTrue([[path description] length] > 1, nil);
}
- (void)testCreationWithNonExistentPath {
GTMPath *path = nil;
-
+
path = [GTMPath pathWithFullPath:@" "];
STAssertNil(path, nil);
-
+
path = [GTMPath pathWithFullPath:@"/abcxyz"];
STAssertNil(path, nil);
-
+
path = [GTMPath pathWithFullPath:@"/etc/foo"];
STAssertNil(path, nil);
-
+
path = [GTMPath pathWithFullPath:@"/foo/bar/baz"];
STAssertNil(path, nil);
}
@@ -130,11 +130,11 @@
- (void)testDirectoryCreation {
GTMPath *tmp = [GTMPath pathWithFullPath:testDirectory_];
GTMPath *path = nil;
-
+
NSString *fooPath = [[tmp fullPath] stringByAppendingPathComponent:@"foo"];
path = [GTMPath pathWithFullPath:fooPath];
STAssertNil(path, nil);
-
+
path = [tmp createDirectoryName:@"foo" mode:0555];
STAssertNotNil(path, nil);
STAssertEqualObjects([path name], @"foo", nil);
@@ -144,11 +144,11 @@
@"got %o", (int)[[path attributes] filePosixPermissions]);
STAssertTrue([path isDirectory], nil);
STAssertFalse([path isRoot], nil);
-
+
// Trying to create a file where a dir already exists should fail
path = [tmp createFileName:@"foo" mode:0555];
STAssertNil(path, nil);
-
+
// Calling create again should succeed
path = [tmp createDirectoryName:@"foo" mode:0555];
STAssertNotNil(path, nil);
@@ -157,7 +157,7 @@
@"got %o", (int)[[path attributes] filePosixPermissions]);
STAssertTrue([path isDirectory], nil);
STAssertFalse([path isRoot], nil);
-
+
GTMPath *foo = [GTMPath pathWithFullPath:fooPath];
STAssertNotNil(foo, nil);
STAssertEqualObjects([path name], @"foo", nil);
@@ -170,22 +170,22 @@
- (void)testFileCreation {
GTMPath *tmp = [GTMPath pathWithFullPath:testDirectory_];
GTMPath *path = nil;
-
+
NSString *fooPath = [[tmp fullPath] stringByAppendingPathComponent:@"foo"];
path = [GTMPath pathWithFullPath:fooPath];
STAssertNil(path, nil);
-
+
path = [tmp createFileName:@"foo" mode:0555];
STAssertNotNil(path, nil);
STAssertEqualObjects([path name], @"foo", nil);
STAssertTrue([[path attributes] filePosixPermissions] == 0555, nil);
STAssertFalse([path isDirectory], nil);
STAssertFalse([path isRoot], nil);
-
+
// Trying to create a dir where a file already exists should fail.
path = [tmp createDirectoryName:@"foo" mode:0555];
STAssertNil(path, nil);
-
+
// Calling create again should succeed
path = [tmp createFileName:@"foo" mode:0555];
STAssertNotNil(path, nil);
@@ -193,14 +193,14 @@
STAssertTrue([[path attributes] filePosixPermissions] == 0555, nil);
STAssertFalse([path isDirectory], nil);
STAssertFalse([path isRoot], nil);
-
+
GTMPath *foo = [GTMPath pathWithFullPath:fooPath];
STAssertNotNil(foo, nil);
STAssertEqualObjects([path name], @"foo", nil);
STAssertTrue([[path attributes] filePosixPermissions] == 0555, nil);
STAssertFalse([path isDirectory], nil);
STAssertFalse([path isRoot], nil);
-
+
// Make sure we can't create a file/directory rooted off of |foo|, since it's
// not a directory.
path = [foo createFileName:@"bar" mode:0555];
@@ -214,21 +214,21 @@
NSString *fooPath = [[tmp fullPath] stringByAppendingPathComponent:@"foo"];
GTMPath *path = [GTMPath pathWithFullPath:fooPath];
STAssertNil(path, nil);
-
+
path = [[[tmp createDirectoryName:@"foo" mode:0755]
createDirectoryName:@"bar" mode:0756]
createDirectoryName:@"baz" mode:0757];
STAssertNotNil(path, nil);
-
+
// Check "baz"
STAssertEqualObjects([path name], @"baz", nil);
STAssertTrue([[path attributes] filePosixPermissions] == 0757, nil);
-
+
// Check "bar"
path = [path parent];
STAssertEqualObjects([path name], @"bar", nil);
STAssertTrue([[path attributes] filePosixPermissions] == 0756, nil);
-
+
// Check "foo"
path = [path parent];
STAssertEqualObjects([path name], @"foo", nil);