Overview
Comment: | Add OFFileManagerTests |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ccace0f0e0e3d228dd03a569c5fffe52 |
User & Date: | js on 2024-03-16 19:48:28 |
Other Links: | manifest | tags |
References
2024-03-17
| ||
09:45 | • Fixed ticket [3e6dc8e381]: Tests for OFFileIRIHandler plus 4 other changes artifact: d470775856 user: js | |
Context
2024-03-16
| ||
22:14 | Fix OFFileManagerTests on macOS check-in: 897aa8244d user: js tags: trunk | |
19:48 | Add OFFileManagerTests check-in: ccace0f0e0 user: js tags: trunk | |
2024-03-10
| ||
23:33 | OFZIPArchive: Write correct number of disks check-in: 9f7c0669b0 user: js tags: trunk | |
Changes
Modified tests/Makefile from [42ad185b91] to [aac9ffbef2].
︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ OFZIPArchiveTests.m \ OFZooArchiveTests.m \ ${RUNTIME_ARC_TESTS_M} \ RuntimeTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_SUBPROCESSES} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} \ testfile_bin.m \ testfile_ini.m SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFDNSResolverTests.m \ ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieManagerTests.m \ OFHTTPCookieTests.m \ OFKernelEventObserverTests.m \ OFSocketTests.m \ | > > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ OFZIPArchiveTests.m \ OFZooArchiveTests.m \ ${RUNTIME_ARC_TESTS_M} \ RuntimeTests.m \ ${USE_SRCS_FILES} \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ ${USE_SRCS_SUBPROCESSES} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} \ testfile_bin.m \ testfile_ini.m SRCS_FILES = OFFileManagerTests.m SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFDNSResolverTests.m \ ${OF_HTTP_CLIENT_TESTS_M} \ OFHTTPCookieManagerTests.m \ OFHTTPCookieTests.m \ OFKernelEventObserverTests.m \ OFSocketTests.m \ |
︙ | ︙ |
Added tests/OFFileManagerTests.m version [739f4f2baa].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "ObjFW.h" #import "ObjFWTest.h" @interface OFFileManagerTests: OTTestCase { OFFileManager *_fileManager; OFIRI *_testsDirectoryIRI, *_testFileIRI; } @end @implementation OFFileManagerTests - (void)setUp { _fileManager = [[OFFileManager defaultManager] retain]; _testsDirectoryIRI = [[[OFSystemInfo temporaryDirectoryIRI] IRIByAppendingPathComponent: @"objfw-tests"] retain]; _testFileIRI = [[_testsDirectoryIRI IRIByAppendingPathComponent: @"test.txt"] retain]; /* In case a previous test run failed and left things. */ if ([_fileManager directoryExistsAtIRI: _testsDirectoryIRI]) [_fileManager removeItemAtIRI: _testsDirectoryIRI]; [_fileManager createDirectoryAtIRI: _testsDirectoryIRI]; [@"test" writeToIRI: _testFileIRI]; } - (void)tearDown { [_fileManager removeItemAtIRI: _testsDirectoryIRI]; } - (void)dealloc { [_fileManager release]; [_testsDirectoryIRI release]; [_testFileIRI release]; [super dealloc]; } - (void)testCurrentDirectoryPath { OTAssertEqualObjects( _fileManager.currentDirectoryPath.lastPathComponent, @"tests"); } - (void)testAttributesOfItemAtPath { OFFileAttributes attributes; attributes = [_fileManager attributesOfItemAtPath: _testsDirectoryIRI.fileSystemRepresentation]; OTAssertEqual(attributes.fileType, OFFileTypeDirectory); attributes = [_fileManager attributesOfItemAtPath: _testFileIRI.fileSystemRepresentation]; OTAssertEqual(attributes.fileType, OFFileTypeRegular); OTAssertEqual(attributes.fileSize, 4); } - (void)testSetAttributesOfItemAtPath { OFDate *date = [OFDate dateWithTimeIntervalSince1970: 946681200]; OFFileAttributes attributes; attributes = [OFDictionary dictionaryWithObject: date forKey: OFFileModificationDate]; [_fileManager setAttributes: attributes ofItemAtPath: _testFileIRI.fileSystemRepresentation]; attributes = [_fileManager attributesOfItemAtPath: _testFileIRI.fileSystemRepresentation]; OTAssertEqual(attributes.fileType, OFFileTypeRegular); OTAssertEqual(attributes.fileSize, 4); OTAssertEqualObjects(attributes.fileModificationDate, date); } - (void)testFileExistsAtPath { OTAssertTrue([_fileManager fileExistsAtPath: _testsDirectoryIRI.fileSystemRepresentation]); OTAssertTrue([_fileManager fileExistsAtPath: _testFileIRI.fileSystemRepresentation]); } - (void)testDirectoryExistsAtPath { OTAssertTrue([_fileManager directoryExistsAtPath: _testsDirectoryIRI.fileSystemRepresentation]); OTAssertFalse([_fileManager directoryExistsAtPath: _testFileIRI.fileSystemRepresentation]); } - (void)testDirectoryAtPathCreateParents { OFIRI *nestedDirectoryIRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"0/1/2/3/4/5"]; [_fileManager createDirectoryAtPath: nestedDirectoryIRI.fileSystemRepresentation createParents: true]; OTAssertTrue([_fileManager directoryExistsAtPath: nestedDirectoryIRI.fileSystemRepresentation]); } - (void)testContentsOfDirectoryAtPath { OFIRI *file1IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"1.txt"]; OFIRI *file2IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"2.txt"]; [@"1" writeToIRI: file1IRI]; [@"2" writeToIRI: file2IRI]; OTAssertEqualObjects([_fileManager contentsOfDirectoryAtPath: _testsDirectoryIRI.fileSystemRepresentation].sortedArray, ([OFArray arrayWithObjects: @"1.txt", @"2.txt", @"test.txt", nil])); } - (void)testSubpathsOfDirectoryAtPath { OFIRI *subdirectory1IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"a"]; OFIRI *subdirectory2IRI = [_testsDirectoryIRI IRIByAppendingPathComponent: @"b"]; OFIRI *file1IRI = [subdirectory1IRI IRIByAppendingPathComponent: @"1.txt"]; OFIRI *file2IRI = [subdirectory2IRI IRIByAppendingPathComponent: @"2.txt"]; [_fileManager createDirectoryAtIRI: subdirectory1IRI]; [_fileManager createDirectoryAtIRI: subdirectory2IRI]; [@"1" writeToIRI: file1IRI]; [@"2" writeToIRI: file2IRI]; OTAssertEqualObjects([_fileManager subpathsOfDirectoryAtPath: _testsDirectoryIRI.fileSystemRepresentation].sortedArray, ([OFArray arrayWithObjects: _testsDirectoryIRI.fileSystemRepresentation, subdirectory1IRI.fileSystemRepresentation, file1IRI.fileSystemRepresentation, subdirectory2IRI.fileSystemRepresentation, file2IRI.fileSystemRepresentation, _testFileIRI.fileSystemRepresentation, nil])); } - (void)testChangeCurrentDirectoryPath { OFString *oldDirectoryPath = _fileManager.currentDirectoryPath; [_fileManager changeCurrentDirectoryPath: _testsDirectoryIRI.fileSystemRepresentation]; OTAssertEqualObjects(_fileManager.currentDirectoryPath, _testsDirectoryIRI.fileSystemRepresentation); [_fileManager changeCurrentDirectoryPath: oldDirectoryPath]; } @end |