mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
add tests for abbreviation of home directory with tilde
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36429 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
acf7b640fc
commit
15f378e72a
1 changed files with 53 additions and 0 deletions
53
Tests/base/NSString/tilde.m
Normal file
53
Tests/base/NSString/tilde.m
Normal file
|
@ -0,0 +1,53 @@
|
|||
#import "Testing.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
START_SET("tilde")
|
||||
NSString *home = NSHomeDirectory();
|
||||
NSString *tmp;
|
||||
|
||||
PASS_EQUAL([home stringByAbbreviatingWithTildeInPath], @"~",
|
||||
"home directory becomes tilde");
|
||||
|
||||
tmp = [home stringByAppendingPathComponent: @"Documents"];
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents",
|
||||
"the Documents subdirectory becomes ~/Documents");
|
||||
|
||||
tmp = [home stringByAppendingString: @"/Documents"];
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents",
|
||||
"trailing slash removed");
|
||||
|
||||
tmp = [home stringByAppendingString: @"//Documents///"];
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents",
|
||||
"multiple slashes removed");
|
||||
|
||||
tmp = [home stringByAppendingString: @"/Documents//.."];
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents/..",
|
||||
"upper directory reference retained");
|
||||
|
||||
tmp = [home stringByAppendingString: @"/Documents/./.."];
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents/./..",
|
||||
"dot directory reference retained");
|
||||
|
||||
tmp = NSHomeDirectoryForUser(@"root");
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], tmp,
|
||||
"tilde does nothing for root's home");
|
||||
|
||||
tmp = [NSString stringWithFormat: @"////%@//Documents///", home];
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents",
|
||||
"multiple slashes removed");
|
||||
|
||||
PASS_EQUAL([@"//////Documents///" stringByAbbreviatingWithTildeInPath],
|
||||
@"/Documents",
|
||||
"multiple slashes removed without tilde replacement");
|
||||
|
||||
PASS_EQUAL([@".//////Documents///" stringByAbbreviatingWithTildeInPath],
|
||||
@"./Documents",
|
||||
"multiple slashes removed without tilde replacement");
|
||||
|
||||
END_SET("tilde")
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue