Skip to content

Instantly share code, notes, and snippets.

@ChristianKienle
Created December 23, 2014 16:01
Show Gist options
  • Select an option

  • Save ChristianKienle/1f3c5c8f39936d4b2f4f to your computer and use it in GitHub Desktop.

Select an option

Save ChristianKienle/1f3c5c8f39936d4b2f4f to your computer and use it in GitHub Desktop.
public enum QueryResult {
case Success(ResultSet)
case Failure(SQLError)
}
func ==(a:QueryResult, b:QueryResult) -> Bool {
switch(a) {
case .Success(_):
switch (b) {
case .Success(_): return true
case .Failure(_): return false
}
case .Failure(_):
switch (b) {
case .Success(_): return false
case .Failure(_): return true
}
default: return false
}
}
func testSelect() {
var queryResult:QueryResult = self.database.executeQuery("SELECT * FROM PERSON", arguments:[])
XCTAssertTrue(queryResult == QueryResult.Success)
}
// Yields: Could not find an overload for '==' that accepts the supplied arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment