@@ -539,11 +539,16 @@ TEST(@"-[stringByPrependingString:]", [[C(@"foo") stringByPrependingString: @"bar"] isEqual: @"barfoo"]) #ifdef OF_HAVE_FILES -# if defined(OF_WINDOWS) || defined(OF_MSDOS) +# if defined(OF_WINDOWS) + TEST(@"-[isAbsolutePath]", + [C(@"C:\\foo") isAbsolutePath] && [C(@"a:/foo") isAbsolutePath] && + ![C(@"foo") isAbsolutePath] && ![C(@"b:foo") isAbsolutePath] && + [C(@"\\\\foo") isAbsolutePath]) +# elif defined(OF_MSDOS) TEST(@"-[isAbsolutePath]", [C(@"C:\\foo") isAbsolutePath] && [C(@"a:/foo") isAbsolutePath] && ![C(@"foo") isAbsolutePath] && ![C(@"b:foo") isAbsolutePath]) # elif defined(OF_AMIGAOS) TEST(@"-[isAbsolutePath]", @@ -636,11 +641,27 @@ [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"] && [a count] == i) #ifdef OF_HAVE_FILES -# if defined(OF_WINDOWS) || defined(OF_MSDOS) +# if defined(OF_WINDOWS) + TEST(@"+[pathWithComponents:]", + [[stringClass pathWithComponents: [OFArray arrayWithObjects: + @"foo", @"bar", @"baz", nil]] isEqual: @"foo\\bar\\baz"] && + [[stringClass pathWithComponents: [OFArray arrayWithObjects: + @"c:", @"foo", @"bar", @"baz", nil]] + isEqual: @"c:\\foo\\bar\\baz"] && + [[stringClass pathWithComponents: [OFArray arrayWithObjects: + @"foo/", @"bar\\", @"", @"baz", @"\\", nil]] + isEqual: @"foo/bar\\baz"] && + [[stringClass pathWithComponents: [OFArray arrayWithObjects: + @"foo", nil]] isEqual: @"foo"] && + [[stringClass pathWithComponents: [OFArray arrayWithObject: @"c:"]] + isEqual: @"c:\\"] && + [[stringClass pathWithComponents: [OFArray arrayWithObjects: + @"\\\\", @"foo", @"bar", nil]] isEqual: @"\\\\foo\\bar"]) +# elif defined(OF_MSDOS) TEST(@"+[pathWithComponents:]", [[stringClass pathWithComponents: [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]] isEqual: @"foo\\bar\\baz"] && [[stringClass pathWithComponents: [OFArray arrayWithObjects: @"c:", @"foo", @"bar", @"baz", nil]] @@ -689,11 +710,42 @@ isEqual: @"foo/bar/baz"] && [[stringClass pathWithComponents: [OFArray arrayWithObjects: @"foo", nil]] isEqual: @"foo"]) # endif -# if defined(OF_WINDOWS) || defined(OF_MSDOS) +# if defined(OF_WINDOWS) + TEST(@"-[pathComponents]", + /* c:/tmp */ + (a = [C(@"c:/tmp") pathComponents]) && [a count] == 2 && + [[a objectAtIndex: 0] isEqual: @"c:"] && + [[a objectAtIndex: 1] isEqual: @"tmp"] && + /* c:\tmp\ */ + (a = [C(@"c:\\tmp\\") pathComponents]) && [a count] == 2 && + [[a objectAtIndex: 0] isEqual: @"c:"] && + [[a objectAtIndex: 1] isEqual: @"tmp"] && + /* c:/ */ + (a = [C(@"c:/") pathComponents]) && [a count] == 1 && + [[a objectAtIndex: 0] isEqual: @"c:"] && + /* foo\bar */ + (a = [C(@"foo\\bar") pathComponents]) && [a count] == 2 && + [[a objectAtIndex: 0] isEqual: @"foo"] && + [[a objectAtIndex: 1] isEqual: @"bar"] && + /* foo\bar/baz/ */ + (a = [C(@"foo\\bar/baz/") pathComponents]) && [a count] == 3 && + [[a objectAtIndex: 0] isEqual: @"foo"] && + [[a objectAtIndex: 1] isEqual: @"bar"] && + [[a objectAtIndex: 2] isEqual: @"baz"] && + /* foo\/ */ + (a = [C(@"foo\\/") pathComponents]) && [a count] == 1 && + [[a objectAtIndex: 0] isEqual: @"foo"] && + [[C(@"") pathComponents] count] == 0 && + /* \\foo\bar */ + (a = [C(@"\\\\foo\\bar") pathComponents]) && [a count] == 3 && + [[a objectAtIndex: 0] isEqual: @"\\\\"] && + [[a objectAtIndex: 1] isEqual: @"foo"] && + [[a objectAtIndex: 2] isEqual: @"bar"]) +# elif defined(OF_MSDOS) TEST(@"-[pathComponents]", /* c:/tmp */ (a = [C(@"c:/tmp") pathComponents]) && [a count] == 2 && [[a objectAtIndex: 0] isEqual: @"c:"] && [[a objectAtIndex: 1] isEqual: @"tmp"] && @@ -793,11 +845,23 @@ (a = [C(@"foo//") pathComponents]) && [a count] == 1 && [[a objectAtIndex: 0] isEqual: @"foo"] && [[C(@"") pathComponents] count] == 0) # endif -# if defined(OF_WINDOWS) || defined(OF_MSDOS) +# if defined(OF_WINDOWS) + TEST(@"-[lastPathComponent]", + [[C(@"c:/tmp") lastPathComponent] isEqual: @"tmp"] && + [[C(@"c:\\tmp\\") lastPathComponent] isEqual: @"tmp"] && + [[C(@"c:\\") lastPathComponent] isEqual: @"c:\\"] && + [[C(@"c:/") lastPathComponent] isEqual: @"c:/"] && + [[C(@"\\") lastPathComponent] isEqual: @""] && + [[C(@"foo") lastPathComponent] isEqual: @"foo"] && + [[C(@"foo\\bar") lastPathComponent] isEqual: @"bar"] && + [[C(@"foo/bar/baz/") lastPathComponent] isEqual: @"baz"] && + [[C(@"\\\\foo\\bar") lastPathComponent] isEqual: @"bar"] && + [[C(@"\\\\") lastPathComponent] isEqual: @"\\\\"]) +# elif defined(OF_MSDOS) TEST(@"-[lastPathComponent]", [[C(@"c:/tmp") lastPathComponent] isEqual: @"tmp"] && [[C(@"c:\\tmp\\") lastPathComponent] isEqual: @"tmp"] && [[C(@"c:\\") lastPathComponent] isEqual: @"c:\\"] && [[C(@"c:/") lastPathComponent] isEqual: @"c:/"] && @@ -837,11 +901,28 @@ [[C(@"foo.bar") pathExtension] isEqual: @"bar"] && [[C(@"foo/.bar") pathExtension] isEqual: @""] && [[C(@"foo/.bar.baz") pathExtension] isEqual: @"baz"] && [[C(@"foo/bar.baz/") pathExtension] isEqual: @"baz"]) -# if defined(OF_WINDOWS) || defined(OF_MSDOS) +# if defined(OF_WINDOWS) + TEST(@"-[stringByDeletingLastPathComponent]", + [[C(@"\\tmp") stringByDeletingLastPathComponent] isEqual: @""] && + [[C(@"/tmp/") stringByDeletingLastPathComponent] isEqual: @""] && + [[C(@"c:\\") stringByDeletingLastPathComponent] isEqual: @"c:\\"] && + [[C(@"c:/") stringByDeletingLastPathComponent] isEqual: @"c:/"] && + [[C(@"c:\\tmp/foo/") stringByDeletingLastPathComponent] + isEqual: @"c:\\tmp"] && + [[C(@"foo\\bar") stringByDeletingLastPathComponent] + isEqual: @"foo"] && + [[C(@"\\") stringByDeletingLastPathComponent] isEqual: @""] && + [[C(@"foo") stringByDeletingLastPathComponent] isEqual: @"."] && + [[C(@"\\\\foo\\bar") stringByDeletingLastPathComponent] + isEqual: @"\\\\foo"] && + [[C(@"\\\\foo") stringByDeletingLastPathComponent] + isEqual: @"\\\\"] && + [[C(@"\\\\") stringByDeletingLastPathComponent] isEqual: @"\\\\"]) +# elif defined(OF_MSDOS) TEST(@"-[stringByDeletingLastPathComponent]", [[C(@"\\tmp") stringByDeletingLastPathComponent] isEqual: @""] && [[C(@"/tmp/") stringByDeletingLastPathComponent] isEqual: @""] && [[C(@"c:\\") stringByDeletingLastPathComponent] isEqual: @"c:\\"] && [[C(@"c:/") stringByDeletingLastPathComponent] isEqual: @"c:/"] && @@ -937,10 +1018,17 @@ [[C(@".foo") stringByDeletingPathExtension] isEqual: @".foo"] && [[C(@".foo\\bar") stringByDeletingPathExtension] isEqual: @".foo\\bar"] && [[C(@".foo.bar") stringByDeletingPathExtension] isEqual: @".foo"]) # endif + +# ifdef OF_WINDOWS + /* TODO: Add more tests */ + TEST(@"-[stringByStandardizingPath]", + [[C(@"\\\\foo\\..\\bar\\qux") stringByStandardizingPath] + isEqual: @"\\\\bar\\qux"]) +# endif #endif TEST(@"-[decimalValue]", [C(@"1234") decimalValue] == 1234 && [C(@"\r\n+123 ") decimalValue] == 123 &&