Add test for -[NSFileManager contentsOfDirectoryAtURL:...]

This commit is contained in:
Frederik Seiffert 2023-04-26 11:48:07 +02:00 committed by Frederik Seiffert
parent a2f63bfec0
commit df743e6d52

View file

@ -142,6 +142,31 @@ int main()
"-contentsOfDirectoryAtPath: agrees");
}
{
NSArray *a;
NSString *dir1 = [mgr currentDirectoryPath];
[mgr changeCurrentDirectoryPath: [dir1 stringByDeletingLastPathComponent]];
a = [mgr contentsOfDirectoryAtPath: dir error: 0];
PASS(1 == [a count] && [[a lastObject] isEqual: @"NSFMFile"],
"-contentsOfDirectoryAtPath: agrees with different current directory");
[mgr changeCurrentDirectoryPath: dir1];
}
{
NSArray *a;
NSString *dir1 = [mgr currentDirectoryPath];
NSURL *dirURL = [NSURL fileURLWithPath: dir1];
NSURL *fileURL = [dirURL URLByAppendingPathComponent: @"NSFMFile"];
[mgr changeCurrentDirectoryPath: [dir1 stringByDeletingLastPathComponent]];
a = [mgr contentsOfDirectoryAtURL: dirURL includingPropertiesForKeys: nil
options: 0 error: NULL];
PASS(1 == [a count] && [[a lastObject] isEqual: fileURL],
"-contentsOfDirectoryAtURL: agrees with different current directory");
[mgr changeCurrentDirectoryPath: dir];
}
{
NSData *dat1 = [mgr contentsAtPath: @"NSFMFile"];
str2 = [[NSString alloc] initWithData: dat1 encoding: 1];