Spaces:
Paused
Paused
Download apps/macos/Tests/OpenClawIPCTests/FileHandleSafeReadTests.swift from nikhtu10/OpenClawBot: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/spaces/nikhtu10/OpenClawBot/resolve/main/apps/macos/Tests/OpenClawIPCTests/FileHandleSafeReadTests.swift
- Command line
-
hf download hf://spaces/nikhtu10/OpenClawBot/apps/macos/Tests/OpenClawIPCTests/FileHandleSafeReadTests.swift
-
curl -L -o FileHandleSafeReadTests.swift https://huggingface.co/spaces/nikhtu10/OpenClawBot/resolve/main/apps/macos/Tests/OpenClawIPCTests/FileHandleSafeReadTests.swift
1.47 kB
| import Foundation | |
| import Testing | |
| @testable import OpenClaw | |
| struct FileHandleSafeReadTests { | |
| func readToEndSafelyReturnsEmptyForClosedHandle() { | |
| let pipe = Pipe() | |
| let handle = pipe.fileHandleForReading | |
| try? handle.close() | |
| let data = handle.readToEndSafely() | |
| #expect(data.isEmpty) | |
| } | |
| func readSafelyUpToCountReturnsEmptyForClosedHandle() { | |
| let pipe = Pipe() | |
| let handle = pipe.fileHandleForReading | |
| try? handle.close() | |
| let data = handle.readSafely(upToCount: 16) | |
| #expect(data.isEmpty) | |
| } | |
| func readToEndSafelyReadsPipeContents() { | |
| let pipe = Pipe() | |
| let writeHandle = pipe.fileHandleForWriting | |
| writeHandle.write(Data("hello".utf8)) | |
| try? writeHandle.close() | |
| let data = pipe.fileHandleForReading.readToEndSafely() | |
| #expect(String(data: data, encoding: .utf8) == "hello") | |
| } | |
| func readSafelyUpToCountReadsIncrementally() { | |
| let pipe = Pipe() | |
| let writeHandle = pipe.fileHandleForWriting | |
| writeHandle.write(Data("hello world".utf8)) | |
| try? writeHandle.close() | |
| let readHandle = pipe.fileHandleForReading | |
| let first = readHandle.readSafely(upToCount: 5) | |
| let second = readHandle.readSafely(upToCount: 32) | |
| #expect(String(data: first, encoding: .utf8) == "hello") | |
| #expect(String(data: second, encoding: .utf8) == " world") | |
| } | |
| } | |