mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
add simple tests for create/reading/remove empty file
This commit is contained in:
parent
87fc1f5e2e
commit
01573cb25e
1 changed files with 27 additions and 12 deletions
|
@ -53,18 +53,20 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSString *dir = @"NSFileManagerTestDir";
|
||||
MyHandler *handler = [MyHandler new];
|
||||
NSDictionary *attr;
|
||||
NSString *dirInDir;
|
||||
NSString *str1,*str2;
|
||||
NSString *tmp;
|
||||
NSError *err;
|
||||
NSDictionary *errInfo;
|
||||
BOOL exists;
|
||||
BOOL isDir;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSString *dir = @"NSFileManagerTestDir";
|
||||
MyHandler *handler = [MyHandler new];
|
||||
NSDictionary *attr;
|
||||
NSString *dirInDir;
|
||||
NSString *str1;
|
||||
NSString *str2;
|
||||
NSMutableString *mstr;
|
||||
NSString *tmp;
|
||||
NSError *err;
|
||||
NSDictionary *errInfo;
|
||||
BOOL exists;
|
||||
BOOL isDir;
|
||||
|
||||
dirInDir = [dir stringByAppendingPathComponent: @"WithinDirectory"];
|
||||
|
||||
|
@ -127,6 +129,19 @@ int main()
|
|||
"NSFileManager can get current dir");
|
||||
}
|
||||
|
||||
PASS([mgr createFileAtPath: @"NSFMFile"
|
||||
contents: [NSData data]
|
||||
attributes: nil],
|
||||
"NSFileManager creates an empty file")
|
||||
PASS([mgr fileExistsAtPath: @"NSFMFile"],"-fileExistsAtPath: agrees")
|
||||
str1 = [NSString stringWithContentsOfFile: @"NSFMFile"];
|
||||
PASS_EQUAL(str1, @"", "empty file produces empty string")
|
||||
mstr = [NSMutableString stringWithContentsOfFile: @"NSFMFile"];
|
||||
PASS([mstr isKindOfClass: [NSMutableString class]] && [mstr isEqual: @""],
|
||||
"empty file produces empty mutable string")
|
||||
PASS([mgr removeFileAtPath: @"NSFMFile" handler: handler],
|
||||
"NSFileManager removes an empty file")
|
||||
|
||||
str1 = @"A string";
|
||||
PASS([mgr createFileAtPath: @"NSFMFile"
|
||||
contents: [str1 dataUsingEncoding: 1]
|
||||
|
|
Loading…
Reference in a new issue