@@ -170,20 +170,10 @@ TEST(@"-[appendFormat:]", R(([s[0] appendFormat: @"%02X", 15])) && [s[0] isEqual: @"test:1230F"]) - TEST(@"+[stringWithPath:]", - (s[0] = [OFString stringWithPath: @"foo", @"bar", @"baz", nil]) && -#ifndef _WIN32 - [s[0] isEqual: @"foo/bar/baz"] && -#else - [s[0] isEqual: @"foo\\bar\\baz"] && -#endif - (s[0] = [OFString stringWithPath: @"foo", nil]) && - [s[0] isEqual: @"foo"]) - TEST(@"-[indexOfFirstOccurrenceOfString:]", [@"π„žΓΆΓΆ" indexOfFirstOccurrenceOfString: @"ΓΆΓΆ"] == 1 && [@"π„žΓΆΓΆ" indexOfFirstOccurrenceOfString: @"ΓΆ"] == 1 && [@"π„žΓΆΓΆ" indexOfFirstOccurrenceOfString: @"π„ž"] == 0 && [@"π„žΓΆΓΆ" indexOfFirstOccurrenceOfString: @"x"] == SIZE_MAX) @@ -231,10 +221,64 @@ [[a objectAtIndex: i++] isEqual: @""] && [[a objectAtIndex: i++] isEqual: @"baz"] && [[a objectAtIndex: i++] isEqual: @""] && [[a objectAtIndex: i++] isEqual: @""]) + TEST(@"+[stringWithPath:]", + (s[0] = [OFString stringWithPath: @"foo", @"bar", @"baz", nil]) && +#ifndef _WIN32 + [s[0] isEqual: @"foo/bar/baz"] && +#else + [s[0] isEqual: @"foo\\bar\\baz"] && +#endif + (s[0] = [OFString stringWithPath: @"foo", nil]) && + [s[0] isEqual: @"foo"]) + + TEST(@"-[pathComponents]", + /* /tmp */ + (a = [@"/tmp" pathComponents]) && [a count] == 2 && + [[a objectAtIndex: 0] isEqual: @""] && + [[a objectAtIndex: 1] isEqual: @"tmp"] && + /* /tmp/ */ + (a = [@"/tmp/" pathComponents]) && [a count] == 2 && + [[a objectAtIndex: 0] isEqual: @""] && + [[a objectAtIndex: 1] isEqual: @"tmp"] && + /* / */ + (a = [@"/" pathComponents]) && [a count] == 1 && + [[a objectAtIndex: 0] isEqual: @""] && + /* foo/bar */ + (a = [@"foo/bar" pathComponents]) && [a count] == 2 && + [[a objectAtIndex: 0] isEqual: @"foo"] && + [[a objectAtIndex: 1] isEqual: @"bar"] && + /* foo/bar/baz/ */ + (a = [@"foo/bar/baz" pathComponents]) && [a count] == 3 && + [[a objectAtIndex: 0] isEqual: @"foo"] && + [[a objectAtIndex: 1] isEqual: @"bar"] && + [[a objectAtIndex: 2] isEqual: @"baz"] && + /* foo// */ + (a = [@"foo//" pathComponents]) && [a count] == 2 && + [[a objectAtIndex: 0] isEqual: @"foo"] && + [[a objectAtIndex: 1] isEqual: @""] && + [[@"" pathComponents] count] == 0) + + TEST(@"-[lastPathComponent]", + [[@"/tmp" lastPathComponent] isEqual: @"tmp"] && + [[@"/tmp/" lastPathComponent] isEqual: @"tmp"] && + [[@"/" lastPathComponent] isEqual: @""] && + [[@"foo" lastPathComponent] isEqual: @"foo"] && + [[@"foo/bar" lastPathComponent] isEqual: @"bar"] && + [[@"foo/bar/baz/" lastPathComponent] isEqual: @"baz"]) + + TEST(@"-[stringByDeletingLastPathComponent]", + [[@"/tmp" stringByDeletingLastPathComponent] isEqual: @"/"] && + [[@"/tmp/" stringByDeletingLastPathComponent] isEqual: @"/"] && + [[@"/tmp/foo/" stringByDeletingLastPathComponent] + isEqual: @"/tmp"] && + [[@"foo/bar" stringByDeletingLastPathComponent] isEqual: @"foo"] && + [[@"/" stringByDeletingLastPathComponent] isEqual: @"/"] && + [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."]) + TEST(@"-[decimalValue]", [@"1234" decimalValue] == 1234 && [@"+123" decimalValue] == 123 && [@"-500" decimalValue] == -500 && [@"" decimalValue] == 0)