Created
October 4, 2019 22:32
-
-
Save erkekin/8b11941c203c71180819c2dc11a0f69e to your computer and use it in GitHub Desktop.
A quick generic fixture reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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