Cleanup code with guard.

This commit is contained in:
Kare Morstol
2015-11-11 03:41:38 +01:00
parent 3554bb4ef8
commit b5448f485a
+5 -8
View File
@@ -6,18 +6,15 @@
// Copyright (c) 2014 NotTooBad Software. All rights reserved.
//
import SwiftShell
import XCTest
import Foundation
extension XCTestCase {
func pathForTestResource (filename: String, type: String) -> String {
let path = NSBundle(forClass: self.dynamicType).pathForResource(filename, ofType: type)
assert(path != nil, "resource \(filename).\(type) not found")
return path!
guard let path = NSBundle(forClass: self.dynamicType).pathForResource(filename, ofType: type) else {
preconditionFailure("resource \(filename).\(type) not found")
}
return path
}
}