Repository: apple/swift-nio
File: Tests/NIOFileSystemTests/FileSystemErrorTests.swift (Swift)

Code before:
            .sendfile(errno: errno, from: "src", to: "dst", location: .fixed)
        }
    }

    func testErrnoMapping_resize() {
        self.testErrnoToErrorCode(
            expected: [
                .badFileDescriptor: .closed,
                .fileTooLarge: .invalidArgument,
                .invalidArgument: .invalidArgument,
            ]
        ) { errno in
            .ftruncate(error: errno, path: "", location: .fixed)
        }
    }

    func testErrnoMapping_futimens() {
        self.testErrnoToErrorCode(
            expected: [
                .permissionDenied: .permissionDenied,
                .notPermitted: .permissionDenied,
                .readOnlyFileSystem: .unsupported,
                .badFileDescriptor: .closed,
            ]
        ) { errno in
                .futimens(errno: errno, path: "", lastAccessTime: nil, lastDataModificationTime: nil, location: .fixed)
        }
    }

    private func testErrnoToErrorCode(
        expected mapping: [Errno: FileSystemError.Code],
        _ makeError: (Errno) -> FileSystemError
    ) {
        for (errno, code) in mapping {
            let error = makeError(errno)
            XCTAssertEqual(error.code, code, "\(error)")
        }

        let errno = Errno(rawValue: -1)
        let error = makeError(errno)
        XCTAssertEqual(error.code, .unknown, "\(error)")
    }
}

private func assertCauseIsSyscall(
    _ name: String,
    _ location: FileSystemError.SourceLocation,
    _ buildError: () -> FileSystemError
) {
    let error = buildError()


Review comment (suggestion):
nit: intendtation

```suggestion
            .futimens(errno: errno, path: "", lastAccessTime: nil, lastDataModificationTime: nil, location: .fixed)
```

Code after:
            .sendfile(errno: errno, from: "src", to: "dst", location: .fixed)
        }
    }

    func testErrnoMapping_resize() {
        self.testErrnoToErrorCode(
            expected: [
                .badFileDescriptor: .closed,
                .fileTooLarge: .invalidArgument,
                .invalidArgument: .invalidArgument,
            ]
        ) { errno in
            .ftruncate(error: errno, path: "", location: .fixed)
        }
    }

    func testErrnoMapping_futimens() {
        self.testErrnoToErrorCode(
            expected: [
                .permissionDenied: .permissionDenied,
                .notPermitted: .permissionDenied,
                .readOnlyFileSystem: .unsupported,
                .badFileDescriptor: .closed,
            ]
        ) { errno in
            .futimens(errno: errno, path: "", lastAccessTime: nil, lastDataModificationTime: nil, location: .fixed)
        }
    }

    private func testErrnoToErrorCode(
        expected mapping: [Errno: FileSystemError.Code],
        _ makeError: (Errno) -> FileSystemError
    ) {
        for (errno, code) in mapping {
            let error = makeError(errno)
            XCTAssertEqual(error.code, code, "\(error)")
        }

        let errno = Errno(rawValue: -1)
        let error = makeError(errno)
        XCTAssertEqual(error.code, .unknown, "\(error)")
    }
}

private func assertCauseIsSyscall(
    _ name: String,
    _ location: FileSystemError.SourceLocation,
    _ buildError: () -> FileSystemError
) {
    let error = buildError()