Skip to content

Instantly share code, notes, and snippets.

@erkekin
Created October 4, 2019 22:32
Show Gist options
  • Save erkekin/8b11941c203c71180819c2dc11a0f69e to your computer and use it in GitHub Desktop.
Save erkekin/8b11941c203c71180819c2dc11a0f69e to your computer and use it in GitHub Desktop.
A quick generic fixture reader
import Foundation
import XCTest
struct Fixture<T: Decodable & Equatable> {
let value : T
init(url: URL) throws {
let actualData = try Data(contentsOf: url)
self.value = try JSONDecoder().decode(T.self, from: actualData)
}
func assert(_ t:T) {
XCTAssertEqual(t, value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment