Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 96ce86e

Browse files
authored
Merge pull request #172 from maciejtrybilo/reflectionDecodable-on-url
Implement ReflectionDecodable on URL.
2 parents eb876a7 + 8622d05 commit 96ce86e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/Core/CodableReflection/ReflectionDecodable.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ extension Dictionary: ReflectionDecodable {
180180
}
181181
}
182182

183+
extension URL: ReflectionDecodable {
184+
/// See `ReflectionDecodable.reflectDecoded()` for more information.
185+
public static func reflectDecoded() throws -> (URL, URL) {
186+
let left = URL(string: "https://left.fake.url")!
187+
let right = URL(string: "https://right.fake.url")!
188+
return (left, right)
189+
}
190+
}
191+
183192
// MARK: Type Erased
184193

185194
/// Type-erased version of `ReflectionDecodable`

Tests/CoreTests/ReflectableTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,13 @@ class ReflectableTests: XCTestCase {
206206

207207
var dict: [String: String]
208208
var odict: [String: String]?
209+
210+
var url: URL
211+
var ourl: URL?
209212
}
210213

211214
let properties = try User.reflectProperties()
212-
XCTAssertEqual(properties.description, "[int: Int, oint: Optional<Int>, int8: Int8, oint8: Optional<Int8>, int16: Int16, oint16: Optional<Int16>, int32: Int32, oint32: Optional<Int32>, int64: Int64, oint64: Optional<Int64>, uint: UInt, uoint: Optional<UInt>, uint8: UInt8, uoint8: Optional<UInt8>, uint16: UInt16, uoint16: Optional<UInt16>, uint32: UInt32, uoint32: Optional<UInt32>, uint64: UInt64, uoint64: Optional<UInt64>, uuid: UUID, ouuid: Optional<UUID>, date: Date, odate: Optional<Date>, float: Float, ofloat: Optional<Float>, double: Double, odouble: Optional<Double>, string: String, ostring: Optional<String>, bool: Bool, obool: Optional<Bool>, array: Array<String>, oarray: Optional<Array<String>>, dict: Dictionary<String, String>, odict: Optional<Dictionary<String, String>>]")
215+
XCTAssertEqual(properties.description, "[int: Int, oint: Optional<Int>, int8: Int8, oint8: Optional<Int8>, int16: Int16, oint16: Optional<Int16>, int32: Int32, oint32: Optional<Int32>, int64: Int64, oint64: Optional<Int64>, uint: UInt, uoint: Optional<UInt>, uint8: UInt8, uoint8: Optional<UInt8>, uint16: UInt16, uoint16: Optional<UInt16>, uint32: UInt32, uoint32: Optional<UInt32>, uint64: UInt64, uoint64: Optional<UInt64>, uuid: UUID, ouuid: Optional<UUID>, date: Date, odate: Optional<Date>, float: Float, ofloat: Optional<Float>, double: Double, odouble: Optional<Double>, string: String, ostring: Optional<String>, bool: Bool, obool: Optional<Bool>, array: Array<String>, oarray: Optional<Array<String>>, dict: Dictionary<String, String>, odict: Optional<Dictionary<String, String>>, url: URL, ourl: Optional<URL>]")
213216
}
214217

215218
func testPropertyDepth() throws {

0 commit comments

Comments
 (0)