From b5448f485a27221daf30e25348dd3805ccb60586 Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Wed, 11 Nov 2015 03:41:38 +0100 Subject: [PATCH] Cleanup code with guard. --- SwiftShellTests/XCTestCase_Additions.swift | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/SwiftShellTests/XCTestCase_Additions.swift b/SwiftShellTests/XCTestCase_Additions.swift index e562fda..0954a60 100644 --- a/SwiftShellTests/XCTestCase_Additions.swift +++ b/SwiftShellTests/XCTestCase_Additions.swift @@ -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 } - } -