import XCTest @testable import LCEssentials private struct OnlyDecodable: Decodable, Sendable, Equatable { let id: Int let name: String } final class JSONDecoderDecodeTests: XCTestCase { func testDecodesTypeThatIsDecodableAndSendableButNotEncodable() throws { let data = Data(#"{"id":7,"name":"loverde"}"#.utf8) let value: OnlyDecodable = try JSONDecoder.decode(data: data) XCTAssertEqual(value, OnlyDecodable(id: 7, name: "loverde")) } func testDecodeFromStringOverload() throws { let value: OnlyDecodable = try JSONDecoder.decode(#"{"id":1,"name":"a"}"#) XCTAssertEqual(value, OnlyDecodable(id: 1, name: "a")) } func testDecodeFromURLThrowsInsteadOfCrashingOnMissingFile() { let missing = URL(fileURLWithPath: "/tmp/does-not-exist-\(UUID().uuidString).json") XCTAssertThrowsError(try JSONDecoder.decode(fromURL: missing) as OnlyDecodable) } }