From df743e6d52865f482f8a2bca16dc646b2c16f658 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Wed, 26 Apr 2023 11:48:07 +0200 Subject: [PATCH] Add test for -[NSFileManager contentsOfDirectoryAtURL:...] --- Tests/base/NSFileManager/general.m | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Tests/base/NSFileManager/general.m b/Tests/base/NSFileManager/general.m index f8d2ab66b..93121d438 100644 --- a/Tests/base/NSFileManager/general.m +++ b/Tests/base/NSFileManager/general.m @@ -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];