Remaining code coverage

Can’t do coverage for Linux unfortunately.
This commit is contained in:
Max Howell
2019-01-31 13:08:54 -05:00
parent 7970c4d8a7
commit ec6c0113f9
3 changed files with 38 additions and 2 deletions

View File

@@ -164,6 +164,14 @@ class PathTests: XCTestCase {
XCTAssertEqual(a.Documents, Path.home/"foo/Documents") XCTAssertEqual(a.Documents, Path.home/"foo/Documents")
} }
func testCopyTo() throws {
try Path.mktemp { root in
try root.foo.touch().copy(to: root.bar)
XCTAssert(root.foo.isFile)
XCTAssert(root.bar.isFile)
}
}
func testCopyInto() throws { func testCopyInto() throws {
try Path.mktemp { root1 in try Path.mktemp { root1 in
let bar1 = try root1.join("bar").touch() let bar1 = try root1.join("bar").touch()
@@ -177,6 +185,14 @@ class PathTests: XCTestCase {
} }
} }
func testMoveTo() throws {
try Path.mktemp { root in
try root.foo.touch().move(to: root.bar)
XCTAssertFalse(root.foo.exists)
XCTAssert(root.bar.isFile)
}
}
func testMoveInto() throws { func testMoveInto() throws {
try Path.mktemp { root1 in try Path.mktemp { root1 in
let bar1 = try root1.join("bar").touch() let bar1 = try root1.join("bar").touch()
@@ -313,12 +329,28 @@ class PathTests: XCTestCase {
XCTAssertTrue(Bundle.main.path.isDirectory) XCTAssertTrue(Bundle.main.path.isDirectory)
XCTAssertTrue(Bundle.main.resources.isDirectory) XCTAssertTrue(Bundle.main.resources.isDirectory)
// doesnt exist in tests // dont exist in tests
_ = Bundle.main.path(forResource: "foo", ofType: "bar")
_ = Bundle.main.sharedFrameworks _ = Bundle.main.sharedFrameworks
} }
func testDataExentsions() throws {
let data = try Data(contentsOf: Path(#file)!)
try Path.mktemp { tmpdir in
_ = try data.write(to: tmpdir.foo)
}
}
func testStringExentsions() throws {
let string = try String(contentsOf: Path(#file)!)
try Path.mktemp { tmpdir in
_ = try string.write(to: tmpdir.foo)
}
}
func testFileHandleExtensions() throws { func testFileHandleExtensions() throws {
_ = try FileHandle(forReadingAt: Path(#file)!) _ = try FileHandle(forReadingAt: Path(#file)!)
_ = try FileHandle(forWritingAt: Path(#file)!) _ = try FileHandle(forWritingAt: Path(#file)!)
_ = try FileHandle(forUpdatingAt: Path(#file)!)
} }
} }

View File

@@ -8,6 +8,8 @@ extension PathTests {
("testCommonDirectories", testCommonDirectories), ("testCommonDirectories", testCommonDirectories),
("testConcatenation", testConcatenation), ("testConcatenation", testConcatenation),
("testCopyInto", testCopyInto), ("testCopyInto", testCopyInto),
("testCopyTo", testCopyTo),
("testDataExentsions", testDataExentsions),
("testDelete", testDelete), ("testDelete", testDelete),
("testDynamicMember", testDynamicMember), ("testDynamicMember", testDynamicMember),
("testEnumeration", testEnumeration), ("testEnumeration", testEnumeration),
@@ -21,11 +23,13 @@ extension PathTests {
("testMkpathIfExists", testMkpathIfExists), ("testMkpathIfExists", testMkpathIfExists),
("testMktemp", testMktemp), ("testMktemp", testMktemp),
("testMoveInto", testMoveInto), ("testMoveInto", testMoveInto),
("testMoveTo", testMoveTo),
("testRelativeCodable", testRelativeCodable), ("testRelativeCodable", testRelativeCodable),
("testRelativePathCodable", testRelativePathCodable), ("testRelativePathCodable", testRelativePathCodable),
("testRelativeTo", testRelativeTo), ("testRelativeTo", testRelativeTo),
("testRename", testRename), ("testRename", testRename),
("testStringConvertibles", testStringConvertibles), ("testStringConvertibles", testStringConvertibles),
("testStringExentsions", testStringExentsions),
("testTimes", testTimes), ("testTimes", testTimes),
] ]
} }