diff --git a/.swift-version b/.swift-version
new file mode 100644
index 00000000..389f7740
--- /dev/null
+++ b/.swift-version
@@ -0,0 +1 @@
+4.0
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 339188af..4514d9c1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
language: objective-c
-osx_image: xcode8.3
+osx_image: xcode9
before_install:
- brew update
- brew install carthage || brew outdated carthage || brew upgrade carthage
@@ -10,4 +10,4 @@ branches:
- master
- feature/swift-3
script:
- - set -o pipefail && xcodebuild build test -workspace Haneke.xcworkspace -scheme Haneke-iOS -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.3' | xcpretty --color
+ - set -o pipefail && xcodebuild build test -workspace Haneke.xcworkspace -scheme Haneke-iOS -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.3.1' | xcpretty --color
diff --git a/Haneke.xcodeproj/project.pbxproj b/Haneke.xcodeproj/project.pbxproj
index cf5ad6f8..b0671517 100644
--- a/Haneke.xcodeproj/project.pbxproj
+++ b/Haneke.xcodeproj/project.pbxproj
@@ -481,7 +481,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
- LastUpgradeCheck = 0830;
+ LastUpgradeCheck = 0920;
ORGANIZATIONNAME = Haneke;
TargetAttributes = {
6393C5DA1C3B229200EB1FD8 = {
@@ -726,7 +726,7 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
@@ -749,7 +749,7 @@
PRODUCT_NAME = Haneke;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
@@ -767,7 +767,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.haneke.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -779,7 +779,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.haneke.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -791,14 +791,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -841,14 +847,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -893,7 +905,7 @@
PRODUCT_NAME = Haneke;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -913,7 +925,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.haneke.Haneke;
PRODUCT_NAME = Haneke;
SKIP_INSTALL = YES;
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -936,7 +948,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "HanekeTests/HanekeTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -954,7 +966,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.haneke.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "HanekeTests/HanekeTests-Bridging-Header.h";
- SWIFT_VERSION = 3.0;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/Haneke/DiskCache.swift b/Haneke/DiskCache.swift
index e7cf0608..78875038 100644
--- a/Haneke/DiskCache.swift
+++ b/Haneke/DiskCache.swift
@@ -123,7 +123,7 @@ open class DiskCache {
open func path(forKey key: String) -> String {
let escapedFilename = key.escapedFilename()
- let filename = escapedFilename.characters.count < Int(NAME_MAX) ? escapedFilename : key.MD5Filename()
+ let filename = escapedFilename.count < Int(NAME_MAX) ? escapedFilename : key.MD5Filename()
let keyPath = (self.path as NSString).appendingPathComponent(filename)
return keyPath
}
diff --git a/Haneke/Info-iOS.plist b/Haneke/Info-iOS.plist
index 78122054..df285b24 100644
--- a/Haneke/Info-iOS.plist
+++ b/Haneke/Info-iOS.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.0
+ 1.1
CFBundleSignature
????
CFBundleVersion
diff --git a/Haneke/Info-tvOS.plist b/Haneke/Info-tvOS.plist
index 78122054..df285b24 100644
--- a/Haneke/Info-tvOS.plist
+++ b/Haneke/Info-tvOS.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.0
+ 1.1
CFBundleSignature
????
CFBundleVersion
diff --git a/Haneke/String+Haneke.swift b/Haneke/String+Haneke.swift
index 8b7ee217..b3188bef 100644
--- a/Haneke/String+Haneke.swift
+++ b/Haneke/String+Haneke.swift
@@ -39,7 +39,7 @@ extension String {
// NSString.pathExtension alone could return a query string, which can lead to very long filenames.
let pathExtension = URL(string: self)?.pathExtension ?? (self as NSString).pathExtension
- if pathExtension.characters.count > 0 {
+ if pathExtension.count > 0 {
return (MD5String as NSString).appendingPathExtension(pathExtension) ?? MD5String
} else {
return MD5String
diff --git a/HanekeDemo/Info.plist b/HanekeDemo/Info.plist
index 113f3f52..40289384 100644
--- a/HanekeDemo/Info.plist
+++ b/HanekeDemo/Info.plist
@@ -15,13 +15,18 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.0
+ 1.1
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
@@ -43,10 +48,5 @@
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
- NSAppTransportSecurity
-
- NSAllowsArbitraryLoads
-
-
diff --git a/HanekeSwift.podspec b/HanekeSwift.podspec
index 76623a51..e8aa1d36 100644
--- a/HanekeSwift.podspec
+++ b/HanekeSwift.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'HanekeSwift'
s.module_name = 'Haneke'
- s.version = '0.10.1'
+ s.version = '1.1'
s.license = 'Apache'
s.summary = 'A lightweight generic cache for iOS written in Swift with extra love for images.'
s.homepage = 'https://github.com/Haneke/HanekeSwift'
diff --git a/HanekeTests/CacheTests.swift b/HanekeTests/CacheTests.swift
index d0843692..838b7d4a 100644
--- a/HanekeTests/CacheTests.swift
+++ b/HanekeTests/CacheTests.swift
@@ -17,7 +17,7 @@ class CacheTests: XCTestCase {
override func setUp() {
super.setUp()
- sut = Cache(name: self.name!)
+ sut = Cache(name: self.name)
}
override func tearDown() {
@@ -41,7 +41,7 @@ class CacheTests: XCTestCase {
}
func testDeinit() {
- weak var _ = Cache(name: self.name!)
+ weak var _ = Cache(name: self.name)
}
// MARK: CachePath
@@ -54,7 +54,7 @@ class CacheTests: XCTestCase {
// MARK: formatPath
func testFormatPath() {
- let formatName = self.name!
+ let formatName = self.name
let expectedFormatPath = (sut.cachePath as NSString).appendingPathComponent(formatName)
let formatPath = sut.formatPath(withFormatName: formatName)
@@ -74,7 +74,7 @@ class CacheTests: XCTestCase {
// MARK: addFormat
func testAddFormat() {
- let format = Format(name: self.name!)
+ let format = Format(name: self.name)
sut.addFormat(format)
}
@@ -84,11 +84,11 @@ class CacheTests: XCTestCase {
func testSize_WithOneFormat() {
let data = Data.dataWithLength(6)
let key = self.name
- let format = Format(name: self.name!)
+ let format = Format(name: self.name)
sut.addFormat(format)
var finished = false
- sut.set(value: data, key: key!, formatName : format.name, success: { _ in
+ sut.set(value: data, key: key, formatName : format.name, success: { _ in
finished = true
})
@@ -99,7 +99,7 @@ class CacheTests: XCTestCase {
func testSize_WithTwoFormats() {
let lengths = [4, 7]
let formats = (0.. Format in
- let formatName = self.name! + String(index)
+ let formatName = self.name + String(index)
return Format(name: formatName)
}
formats.forEach(sut.addFormat)
@@ -110,7 +110,7 @@ class CacheTests: XCTestCase {
let key = self.name
var finished = false
- sut.set(value: data, key: key!, formatName : format.name, success: { _ in
+ sut.set(value: data, key: key, formatName : format.name, success: { _ in
finished = true
})
@@ -123,10 +123,10 @@ class CacheTests: XCTestCase {
// MARK: set
func testSet_WithIdentityFormat_ExpectSyncSuccess() {
- let sut = Cache(name: self.name!)
+ let sut = Cache(name: self.name)
let data = Data.dataWithLength(5)
- let key = self.name!
- let expectation = self.expectation(description: self.name!)
+ let key = self.name
+ let expectation = self.expectation(description: self.name)
sut.set(value: data, key: key, success: {
XCTAssertEqual($0, data)
@@ -139,10 +139,10 @@ class CacheTests: XCTestCase {
func testSet_WithCustomFormat_ExpectAsyncSuccess () {
let data = Data.dataWithLength(6)
let expectedData = Data.dataWithLength(7)
- let key = self.name!
- let format = Format(name: self.name!, transform: { _ in return expectedData })
+ let key = self.name
+ let format = Format(name: self.name, transform: { _ in return expectedData })
sut.addFormat(format)
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
var finished = false
sut.set(value: data, key: key, formatName : format.name, success: {
@@ -169,7 +169,7 @@ class CacheTests: XCTestCase {
func testFetchOnSuccess_AfterSet_WithKey_ExpectSyncSuccess () {
let data = Data.dataWithLength(8)
- let key = self.name!
+ let key = self.name
let expectation = self.expectation(description: key)
sut.set(value: data, key: key)
@@ -184,7 +184,7 @@ class CacheTests: XCTestCase {
}
func testFetchOnFailure_WithKey_ExpectAsyncFailure () {
- let key = self.name!
+ let key = self.name
let expectation = self.expectation(description: key)
let fetch = sut.fetch(key: key).onFailure { error in
@@ -206,7 +206,7 @@ class CacheTests: XCTestCase {
func testFetch_AfterClearingMemoryCache_WithKey_ExpectAsyncSuccess () {
let data = Data.dataWithLength(9)
- let key = self.name!
+ let key = self.name
let expectation = self.expectation(description: key)
sut.set(value: data, key: key)
self.clearMemoryCache()
@@ -227,7 +227,7 @@ class CacheTests: XCTestCase {
}
func testFetch_WithKeyAndExistingFormat_ExpectAsyncFailure () {
- let key = self.name!
+ let key = self.name
let expectation = self.expectation(description: key)
let fetch = sut.fetch(key: key, failure : { error in
@@ -253,7 +253,7 @@ class CacheTests: XCTestCase {
}
func testFetch_WithKeyAndInexistingFormat_ExpectSyncFailure () {
- let key = self.name!
+ let key = self.name
let expectation = self.expectation(description: key)
let fetch = sut.fetch(key: key, formatName: key, failure : { error in
@@ -277,7 +277,7 @@ class CacheTests: XCTestCase {
}
func testFetch_AfterClearingMemoryCache_WithKeyAndFormatWithoutDiskCapacity_ExpectFailure() {
- let key = self.name!
+ let key = self.name
let data = Data.dataWithLength(8)
let format = Format(name: key, diskCapacity: 0)
sut.addFormat(format)
@@ -296,7 +296,7 @@ class CacheTests: XCTestCase {
}
func testFetch_AfterClearingMemoryCache_WithKeyAndFormatWithDiskCapacity_ExpectSuccess() {
- let key = self.name!
+ let key = self.name
let data = Data.dataWithLength(9)
let format = Format(name: key)
sut.addFormat(format)
@@ -316,8 +316,8 @@ class CacheTests: XCTestCase {
func testFetchOnSuccess_WithSyncFetcher_ExpectAsyncSuccess () {
let data = Data.dataWithLength(10)
- let fetcher = SimpleFetcher(key: self.name!, value: data)
- let expectation = self.expectation(description: self.name!)
+ let fetcher = SimpleFetcher(key: self.name, value: data)
+ let expectation = self.expectation(description: self.name)
let fetch = sut.fetch(fetcher: fetcher).onSuccess {
XCTAssertEqual($0, data)
@@ -333,9 +333,9 @@ class CacheTests: XCTestCase {
func testFetchOnFailure_WithSyncFailingFetcher_ExpectAsyncFailure() {
- let fetcher = FailFetcher(key: self.name!)
+ let fetcher = FailFetcher(key: self.name)
fetcher.error = NSError(domain: "test", code: 376, userInfo: nil)
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
let fetch = sut.fetch(fetcher: fetcher).onFailure { error in
guard let error = error as NSError? else {
@@ -356,7 +356,7 @@ class CacheTests: XCTestCase {
func testFetch_AfterSet_WithFetcher_ExpectSyncSuccess () {
let data = Data.dataWithLength(10)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: data)
let expectation = self.expectation(description: key)
sut.set(value: data, key: key)
@@ -373,7 +373,7 @@ class CacheTests: XCTestCase {
func testFetch_AfterSetAndClearingMemoryCache_WithFetcher_ExpectAsyncSuccess () {
let data = Data.dataWithLength(10)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: data)
let expectation = self.expectation(description: key)
sut.set(value: data, key: key)
@@ -392,7 +392,7 @@ class CacheTests: XCTestCase {
}
func testFetch_WithSyncFetcher_ExpectAsyncSuccess () {
- let key = self.name!
+ let key = self.name
let data = Data.dataWithLength(11)
let fetcher = SimpleFetcher(key: key, value: data)
let expectation = self.expectation(description: key)
@@ -413,7 +413,7 @@ class CacheTests: XCTestCase {
}
func testFetch_WithFetcherAndCustomFormat_ExpectAsyncSuccess () {
- let key = self.name!
+ let key = self.name
let data = Data.dataWithLength(12)
let formattedData = Data.dataWithLength(13)
let fetcher = SimpleFetcher(key: key, value: data)
@@ -439,11 +439,11 @@ class CacheTests: XCTestCase {
}
func testFetch_WithFetcherAndInexistingFormat_ExpectSyncFailure () {
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
let data = Data.dataWithLength(14)
- let fetcher = SimpleFetcher(key: self.name!, value: data)
+ let fetcher = SimpleFetcher(key: self.name, value: data)
- let fetch = sut.fetch(fetcher: fetcher, formatName: self.name!, failure : { error in
+ let fetch = sut.fetch(fetcher: fetcher, formatName: self.name, failure : { error in
guard let error = error as NSError? else {
XCTFail("expected non-nil error");
expectation.fulfill()
@@ -466,7 +466,7 @@ class CacheTests: XCTestCase {
// MARK: remove
func testRemove_WithExistingKey() {
- let key = self.name!
+ let key = self.name
sut.set(value: Data.dataWithLength(14), key: key)
let expectation = self.expectation(description: "fetch")
@@ -482,8 +482,8 @@ class CacheTests: XCTestCase {
}
func testRemove_WithExistingKeyInFormat() {
- let key = self.name!
- let format = Format(name: self.name!)
+ let key = self.name
+ let format = Format(name: self.name)
sut.addFormat(format)
sut.set(value: Data.dataWithLength(15), key: key, formatName: format.name)
let expectation = self.expectation(description: "fetch")
@@ -500,7 +500,7 @@ class CacheTests: XCTestCase {
}
func testRemove_WithExistingKeyInAnotherFormat() {
- let key = self.name!
+ let key = self.name
let format = Format(name: key)
sut.addFormat(format)
sut.set(value: Data.dataWithLength(16), key: key)
@@ -518,7 +518,7 @@ class CacheTests: XCTestCase {
}
func testRemove_WithExistingKeyAndInexistingFormat() {
- let key = self.name!
+ let key = self.name
sut.set(value: Data.dataWithLength(17), key: key)
let expectation = self.expectation(description: "fetch")
@@ -534,13 +534,13 @@ class CacheTests: XCTestCase {
}
func testRemove_WithInexistingKey() {
- sut.remove(key: self.name!)
+ sut.remove(key: self.name)
}
// MARK: removeAll
func testRemoveAll_AfterOne() {
- let key = self.name!
+ let key = self.name
sut.set(value: Data.dataWithLength(18), key: key)
let expectation = self.expectation(description: "fetch")
@@ -556,7 +556,7 @@ class CacheTests: XCTestCase {
}
func testRemoveAll_Completion() {
- let key = self.name!
+ let key = self.name
sut.set(value: Data.dataWithLength(18), key: key)
let expectation = self.expectation(description: "removeAll")
var completed = false
@@ -589,7 +589,7 @@ class CacheTests: XCTestCase {
}
func testOnMemoryWarning() {
- let key = self.name!
+ let key = self.name
let data = Data.dataWithLength(18)
sut.set(value: data, key: key)
let expectation = self.expectation(description: "fetch")
@@ -609,7 +609,7 @@ class CacheTests: XCTestCase {
func testUIApplicationDidReceiveMemoryWarningNotification() {
let expectation = self.expectation(description: "onMemoryWarning")
- let sut = CacheMock(name: self.name!)
+ let sut = CacheMock(name: self.name)
sut.expectation = expectation // XCode crashes if we use the original expectation directly
NotificationCenter.default.post(name: NSNotification.Name.UIApplicationDidReceiveMemoryWarning, object: nil)
@@ -630,7 +630,7 @@ class ImageCacheTests: XCTestCase {
override func setUp() {
super.setUp()
- sut = Cache(name: self.name!)
+ sut = Cache(name: self.name)
}
override func tearDown() {
@@ -639,7 +639,7 @@ class ImageCacheTests: XCTestCase {
}
func testSet_ExpectAsyncDecompressedImage() {
- let key = self.name!
+ let key = self.name
sut = Cache(name: key)
let image = UIImage.imageWithColor(UIColor.green)
let expectation = self.expectation(description: key)
@@ -658,7 +658,7 @@ class ImageCacheTests: XCTestCase {
func testFetchOnSuccess_AfterSet_WithKey_ExpectSyncDecompressedImage () {
let image = UIImage.imageWithColor(UIColor.cyan)
- let key = self.name!
+ let key = self.name
let expectation = self.expectation(description: key)
sut.set(value: image, key: key, success: { decompressedImage in
diff --git a/HanekeTests/DataTests.swift b/HanekeTests/DataTests.swift
index 9716bad4..d733fe87 100644
--- a/HanekeTests/DataTests.swift
+++ b/HanekeTests/DataTests.swift
@@ -35,7 +35,7 @@ class ImageDataTests: XCTestCase {
class StringDataTests: XCTestCase {
func testConvertFromData() {
- let string = self.name!
+ let string = self.name
let data = string.data(using: String.Encoding.utf8)!
let result = String.convertFromData(data)
@@ -44,7 +44,7 @@ class StringDataTests: XCTestCase {
}
func testAsData() {
- let string = self.name!
+ let string = self.name
let data = string.data(using: String.Encoding.utf8)!
let result = string.asData()
@@ -77,7 +77,7 @@ class DataDataTests: XCTestCase {
class JSONDataTests: XCTestCase {
func testConvertFromData_WithArrayData() {
- let json = [self.name!]
+ let json = [self.name]
let data = try! JSONSerialization.data(withJSONObject: json, options: JSONSerialization.WritingOptions())
let result = JSON.convertFromData(data)!
@@ -92,7 +92,7 @@ class JSONDataTests: XCTestCase {
}
func testConvertFromData_WithDictionaryData() {
- let json = ["test": self.name!]
+ let json = ["test": self.name]
let data = try! JSONSerialization.data(withJSONObject: json, options: JSONSerialization.WritingOptions())
let result = JSON.convertFromData(data)!
@@ -114,7 +114,7 @@ class JSONDataTests: XCTestCase {
}
func testAsData_Array() {
- let object = [self.name!]
+ let object = [self.name]
let json = JSON.Array(object as [AnyObject])
let result = json.asData()
@@ -124,7 +124,7 @@ class JSONDataTests: XCTestCase {
}
func testAsData_Dictionary() {
- let object = ["test": self.name!]
+ let object = ["test": self.name]
let json = JSON.Dictionary(object as [String : AnyObject])
let result = json.asData()
@@ -143,7 +143,7 @@ class JSONDataTests: XCTestCase {
}
func testArray_Array() {
- let object = [self.name!]
+ let object = [self.name]
let json = JSON.Array(object as [AnyObject])
let result = json.array
@@ -152,7 +152,7 @@ class JSONDataTests: XCTestCase {
}
func testArray_Dictionary() {
- let object = ["test": self.name!]
+ let object = ["test": self.name]
let json = JSON.Dictionary(object as [String : AnyObject])
let result = json.array
@@ -161,7 +161,7 @@ class JSONDataTests: XCTestCase {
}
func testDictionary_Array() {
- let object = [self.name!]
+ let object = [self.name]
let json = JSON.Array(object as [AnyObject])
let result = json.dictionary
@@ -170,7 +170,7 @@ class JSONDataTests: XCTestCase {
}
func testDictionary_Dictionary() {
- let object = ["test": self.name!]
+ let object = ["test": self.name]
let json = JSON.Dictionary(object as [String : AnyObject])
let result = json.dictionary
diff --git a/HanekeTests/DiskCacheTests.swift b/HanekeTests/DiskCacheTests.swift
index a32eb003..ba0994fc 100644
--- a/HanekeTests/DiskCacheTests.swift
+++ b/HanekeTests/DiskCacheTests.swift
@@ -15,7 +15,7 @@ class DiskCacheTests: XCTestCase {
var sut : DiskCache!
lazy var diskCachePath: String = {
- let diskCachePath = (DiskCache.basePath() as NSString).appendingPathComponent(self.name!)
+ let diskCachePath = (DiskCache.basePath() as NSString).appendingPathComponent(self.name)
try! FileManager.default.createDirectory(atPath: diskCachePath, withIntermediateDirectories: true, attributes: nil)
return diskCachePath
}()
@@ -125,7 +125,7 @@ class DiskCacheTests: XCTestCase {
}
func testSetCapacity() {
- sut.setData(Data.dataWithLength(1), key: self.name!)
+ sut.setData(Data.dataWithLength(1), key: self.name)
sut.capacity = 0
@@ -136,7 +136,7 @@ class DiskCacheTests: XCTestCase {
func testSetData() {
let data = UIImagePNGRepresentation(UIImage.imageWithColor(UIColor.red))!
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
sut.setData(data, key: key)
@@ -199,7 +199,7 @@ class DiskCacheTests: XCTestCase {
func testSetDataReplace() {
let originalData = Data.dataWithLength(5)
let data = Data.dataWithLength(14)
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
sut.setData(originalData, key: key)
@@ -215,7 +215,7 @@ class DiskCacheTests: XCTestCase {
}
func testSetDataNil() {
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
sut.setData({ return nil }(), key: key)
@@ -229,7 +229,7 @@ class DiskCacheTests: XCTestCase {
func testSetDataControlCapacity() {
let sut = DiskCache(path: diskCachePath, capacity:0)
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
sut.setData(Data.dataWithLength(1), key: key)
@@ -243,7 +243,7 @@ class DiskCacheTests: XCTestCase {
func testFetchData() {
let data = Data.dataWithLength(14)
- let key = self.name!
+ let key = self.name
sut.setData(data, key : key)
let expectation = self.expectation(description: key)
@@ -258,7 +258,7 @@ class DiskCacheTests: XCTestCase {
}
func testFetchData_Inexisting() {
- let key = self.name!
+ let key = self.name
let expectation = self.expectation(description: key)
sut.fetchData(key: key, failure : { error in
@@ -279,7 +279,7 @@ class DiskCacheTests: XCTestCase {
}
func testFetchData_Inexisting_NilFailureBlock() {
- let key = self.name!
+ let key = self.name
sut.fetchData(key: key, success: { _ in
XCTFail("Expected failure")
@@ -291,7 +291,7 @@ class DiskCacheTests: XCTestCase {
func testFetchData_UpdateAccessDate() {
let now = Date()
let data = Data.dataWithLength(19)
- let key = self.name!
+ let key = self.name
sut.setData(data, key : key)
let path = sut.path(forKey: key)
let fileManager = FileManager.default
@@ -324,7 +324,7 @@ class DiskCacheTests: XCTestCase {
func testUpdateAccessDateFileInDisk() {
let now = Date()
let data = Data.dataWithLength(10)
- let key = self.name!
+ let key = self.name
sut.setData(data, key : key)
let path = sut.path(forKey: key)
let fileManager = FileManager.default
@@ -352,7 +352,7 @@ class DiskCacheTests: XCTestCase {
func testUpdateAccessDateFileNotInDisk() {
let image = UIImage.imageWithColor(UIColor.red)
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
let fileManager = FileManager.default
@@ -385,7 +385,7 @@ class DiskCacheTests: XCTestCase {
}
func testRemoveDataExisting() {
- let key = self.name!
+ let key = self.name
let data = UIImagePNGRepresentation(UIImage.imageWithColor(UIColor.red))
let path = sut.path(forKey: key)
sut.setData(data, key: key)
@@ -400,7 +400,7 @@ class DiskCacheTests: XCTestCase {
}
func testRemoveDataInexisting() {
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
let fileManager = FileManager.default
@@ -411,7 +411,7 @@ class DiskCacheTests: XCTestCase {
}
func testRemoveAllData_Filled() {
- let key = self.name!
+ let key = self.name
let data = Data.dataWithLength(12)
let path = sut.path(forKey: key)
sut.setData(data, key: key)
@@ -426,7 +426,7 @@ class DiskCacheTests: XCTestCase {
}
func testRemoveAllData_Completion_Filled() {
- let key = self.name!
+ let key = self.name
let data = Data.dataWithLength(12)
sut.setData(data, key: key)
let expectation = self.expectation(description: key)
@@ -442,7 +442,7 @@ class DiskCacheTests: XCTestCase {
}
func testRemoveAllData_Empty() {
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
let fileManager = FileManager.default
@@ -453,7 +453,7 @@ class DiskCacheTests: XCTestCase {
}
func testRemoveAllData_ThenSetData() {
- let key = self.name!
+ let key = self.name
let path = sut.path(forKey: key)
let data = Data.dataWithLength(12)
diff --git a/HanekeTests/DiskFetcherTests.swift b/HanekeTests/DiskFetcherTests.swift
index 2620825f..bebb662e 100644
--- a/HanekeTests/DiskFetcherTests.swift
+++ b/HanekeTests/DiskFetcherTests.swift
@@ -34,7 +34,7 @@ class DiskFetcherTests: DiskTestCase {
let data = UIImagePNGRepresentation(image)!
try? data.write(to: URL(fileURLWithPath: sut.path), options: [.atomic])
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.fetch(failure: { _ in
XCTFail("Expected to succeed")
@@ -49,7 +49,7 @@ class DiskFetcherTests: DiskTestCase {
}
func testFetchImage_Failure_NSFileReadNoSuchFileError() {
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.fetch(failure: {
guard let error = $0 as NSError? else {
@@ -72,7 +72,7 @@ class DiskFetcherTests: DiskTestCase {
let data = Data()
try? data.write(to: URL(fileURLWithPath: sut.path), options: [.atomic])
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.fetch(failure: {
guard let error = $0 as NSError? else {
@@ -120,8 +120,8 @@ class DiskFetcherTests: DiskTestCase {
func testCacheFetch_Success() {
let data = Data.dataWithLength(1)
let path = self.writeData(data)
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
_ = cache.fetch(path: path, failure: {_ in
XCTFail("expected success")
@@ -137,9 +137,9 @@ class DiskFetcherTests: DiskTestCase {
}
func testCacheFetch_Failure() {
- let path = (self.directoryPath as NSString).appendingPathComponent(self.name!)
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
+ let path = (self.directoryPath as NSString).appendingPathComponent(self.name)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
_ = cache.fetch(path: path, failure: {_ in
expectation.fulfill()
@@ -156,9 +156,9 @@ class DiskFetcherTests: DiskTestCase {
func testCacheFetch_WithFormat() {
let data = Data.dataWithLength(1)
let path = self.writeData(data)
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
- let format = Format(name: self.name!)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
+ let format = Format(name: self.name)
cache.addFormat(format)
_ = cache.fetch(path: path, formatName: format.name, failure: {_ in
diff --git a/HanekeTests/DiskTestCase.swift b/HanekeTests/DiskTestCase.swift
index 9bdf9d4e..d1f82bd1 100644
--- a/HanekeTests/DiskTestCase.swift
+++ b/HanekeTests/DiskTestCase.swift
@@ -12,7 +12,7 @@ class DiskTestCase : XCTestCase {
lazy var directoryPath: String = {
let documentsPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)[0]
- let directoryPath = (documentsPath as NSString).appendingPathComponent(self.name!)
+ let directoryPath = (documentsPath as NSString).appendingPathComponent(self.name)
return directoryPath
}()
diff --git a/HanekeTests/FetchTests.swift b/HanekeTests/FetchTests.swift
index 764ca2f9..98b0e95a 100644
--- a/HanekeTests/FetchTests.swift
+++ b/HanekeTests/FetchTests.swift
@@ -20,7 +20,7 @@ class FetchTests : XCTestCase {
}
func testHasSucceded_True() {
- sut.succeed(self.name!)
+ sut.succeed(self.name)
XCTAssertTrue(sut.hasSucceeded)
}
@@ -46,17 +46,17 @@ class FetchTests : XCTestCase {
}
func testHasSucceded_AfterSucceed_False() {
- sut.succeed(self.name!)
+ sut.succeed(self.name)
XCTAssertFalse(sut.hasFailed)
}
func testSucceed() {
- sut.succeed(self.name!)
+ sut.succeed(self.name)
}
func testSucceed_AfterOnSuccess() {
- let value = self.name!
+ let value = self.name
let expectation = self.expectation(description: value)
sut.onSuccess {
XCTAssertEqual($0, value)
@@ -73,8 +73,8 @@ class FetchTests : XCTestCase {
}
func testFail_AfterOnFailure() {
- let error = NSError(domain: self.name!, code: 10, userInfo: nil)
- let expectation = self.expectation(description: self.name!)
+ let error = NSError(domain: self.name, code: 10, userInfo: nil)
+ let expectation = self.expectation(description: self.name)
sut.onFailure {
XCTAssertEqual($0!.localizedDescription, error.localizedDescription)
expectation.fulfill()
@@ -92,7 +92,7 @@ class FetchTests : XCTestCase {
}
func testOnSuccess_AfterSucceed() {
- let value = self.name!
+ let value = self.name
sut.succeed(value)
let expectation = self.expectation(description: value)
@@ -111,9 +111,9 @@ class FetchTests : XCTestCase {
}
func testOnFailure_AfterFail() {
- let error = NSError(domain: self.name!, code: 10, userInfo: nil)
+ let error = NSError(domain: self.name, code: 10, userInfo: nil)
sut.fail(error)
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.onFailure {
XCTAssertEqual($0!.localizedDescription, error.localizedDescription)
diff --git a/HanekeTests/FetcherTests.swift b/HanekeTests/FetcherTests.swift
index 96bfeeb3..e5a2cc8e 100644
--- a/HanekeTests/FetcherTests.swift
+++ b/HanekeTests/FetcherTests.swift
@@ -13,7 +13,7 @@ import XCTest
class FetcherTests: XCTestCase {
func testSimpleFetcherInit() {
- let key = self.name!
+ let key = self.name
let image = UIImage.imageWithColor(UIColor.green)
let fetcher = SimpleFetcher(key: key, value: image)
@@ -23,7 +23,7 @@ class FetcherTests: XCTestCase {
}
func testSimpleFetcherFetch() {
- let key = self.name!
+ let key = self.name
let image = UIImage.imageWithColor(UIColor.green)
let fetcher = SimpleFetcher(key: key, value: image)
let expectation = self.expectation(description: key)
@@ -40,10 +40,10 @@ class FetcherTests: XCTestCase {
func testCacheFetch() {
let data = Data.dataWithLength(1)
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
- cache.fetch(key: self.name!, value: data) {
+ cache.fetch(key: self.name, value: data) {
XCTAssertEqual($0, data)
expectation.fulfill()
}
@@ -55,12 +55,12 @@ class FetcherTests: XCTestCase {
func testCacheFetch_WithFormat() {
let data = Data.dataWithLength(1)
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
- let format = Format(name: self.name!)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
+ let format = Format(name: self.name)
cache.addFormat(format)
- cache.fetch(key: self.name!, value: data, formatName: format.name) {
+ cache.fetch(key: self.name, value: data, formatName: format.name) {
XCTAssertEqual($0, data)
expectation.fulfill()
}
diff --git a/HanekeTests/FormatTests.swift b/HanekeTests/FormatTests.swift
index 19b4ad18..6ee42152 100644
--- a/HanekeTests/FormatTests.swift
+++ b/HanekeTests/FormatTests.swift
@@ -13,7 +13,7 @@ import XCTest
class FormatTests: XCTestCase {
func testDefaultInit() {
- let name = self.name!
+ let name = self.name
let sut = Format(name: name)
XCTAssertEqual(sut.name, name)
@@ -22,13 +22,13 @@ class FormatTests: XCTestCase {
}
func testIsIdentity_WithoutTransform_ExpectTrue() {
- let sut = Format(name: self.name!)
+ let sut = Format(name: self.name)
XCTAssertTrue(sut.isIdentity)
}
func testIsIdentity_WithTransform_ExpectFalse() {
- let sut = Format(name: self.name!, transform: { return $0 })
+ let sut = Format(name: self.name, transform: { return $0 })
XCTAssertFalse(sut.isIdentity)
}
diff --git a/HanekeTests/HanekeTests.swift b/HanekeTests/HanekeTests.swift
index 0b9db7bf..bff1e6e6 100644
--- a/HanekeTests/HanekeTests.swift
+++ b/HanekeTests/HanekeTests.swift
@@ -14,7 +14,7 @@ class HanekeTests: XCTestCase {
func testErrorWithCode() {
let code = 200
let description = self.name
- let error = errorWithCode(code, description:description!)
+ let error = errorWithCode(code, description: description)
XCTAssertEqual(error._domain, HanekeGlobals.Domain)
XCTAssertEqual(error._code, code)
diff --git a/HanekeTests/NetworkFetcherTests.swift b/HanekeTests/NetworkFetcherTests.swift
index 5117983c..a74def9a 100644
--- a/HanekeTests/NetworkFetcherTests.swift
+++ b/HanekeTests/NetworkFetcherTests.swift
@@ -42,7 +42,7 @@ class NetworkFetcherTests: XCTestCase {
let data = UIImagePNGRepresentation(image)
return OHHTTPStubsResponse(data: data!, statusCode: 200, headers:nil)
})
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.fetch(failure: { _ in
XCTFail("expected success")
@@ -87,7 +87,7 @@ class NetworkFetcherTests: XCTestCase {
let data = Data()
return OHHTTPStubsResponse(data: data, statusCode: 200, headers:nil)
})
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.fetch(failure: {
XCTAssertEqual($0!._domain, HanekeGlobals.Domain)
@@ -109,7 +109,7 @@ class NetworkFetcherTests: XCTestCase {
let data = Data.dataWithLength(100)
return OHHTTPStubsResponse(data: data, statusCode: 200, headers:["Content-Length":String(data.count * 2)])
})
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.fetch(failure: {
XCTAssertEqual($0!._domain, HanekeGlobals.Domain)
@@ -161,7 +161,7 @@ class NetworkFetcherTests: XCTestCase {
let data = UIImagePNGRepresentation(image)
return OHHTTPStubsResponse(data: data!, statusCode: statusCode, headers:nil)
})
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.cancelFetch()
sut.fetch(failure: { _ in
@@ -183,7 +183,7 @@ class NetworkFetcherTests: XCTestCase {
let data = Data.dataWithLength(100)
return OHHTTPStubsResponse(data: data, statusCode: statusCode, headers:nil)
})
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.fetch(failure: {
XCTAssertEqual($0!._domain, HanekeGlobals.Domain)
@@ -207,8 +207,8 @@ class NetworkFetcherTests: XCTestCase {
}, withStubResponse: { _ in
return OHHTTPStubsResponse(data: data, statusCode: 200, headers:nil)
})
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
cache.fetch(URL: URL, failure: {_ in
XCTFail("expected success")
@@ -230,8 +230,8 @@ class NetworkFetcherTests: XCTestCase {
}, withStubResponse: { _ in
return OHHTTPStubsResponse(data: data, statusCode: 404, headers:nil)
})
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
cache.fetch(URL: URL, failure: {_ in
expectation.fulfill()
@@ -252,9 +252,9 @@ class NetworkFetcherTests: XCTestCase {
}, withStubResponse: { _ in
return OHHTTPStubsResponse(data: data, statusCode: 404, headers:nil)
})
- let expectation = self.expectation(description: self.name!)
- let cache = Cache(name: self.name!)
- let format = Format(name: self.name!)
+ let expectation = self.expectation(description: self.name)
+ let cache = Cache(name: self.name)
+ let format = Format(name: self.name)
cache.addFormat(format)
cache.fetch(URL: URL, formatName: format.name, failure: {_ in
diff --git a/HanekeTests/UIButton+HanekeTests.swift b/HanekeTests/UIButton+HanekeTests.swift
index fb8d9e38..c821d24f 100644
--- a/HanekeTests/UIButton+HanekeTests.swift
+++ b/HanekeTests/UIButton+HanekeTests.swift
@@ -47,7 +47,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImage_MemoryMiss_UIControlStateNormal() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.hnk_setImage(image, key: key)
@@ -57,7 +57,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImage_MemoryHit_UIControlStateSelected() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let expectedImage = setImage(image, key: key, format: sut.hnk_imageFormat)
sut.hnk_setImage(image, key: key, state: .selected)
@@ -69,7 +69,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImage_UsingPlaceholder_MemoryMiss_UIControlStateDisabled() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.hnk_setImage(image, key: key, state: .disabled, placeholder: placeholder)
@@ -80,7 +80,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImage_UsingPlaceholder_MemoryHit_UIControlStateNormal() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let expectedImage = setImage(image, key: key, format: sut.hnk_imageFormat)
sut.hnk_setImage(image, key: key, placeholder: placeholder)
@@ -92,9 +92,9 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImage_UsingFormat_UIControlStateHighlighted() {
let image = UIImage.imageWithColor(UIColor.red)
let expectedImage = UIImage.imageWithColor(UIColor.green)
- let format = Format(name: self.name!, diskCapacity: 0) { _ in return expectedImage }
- let key = self.name!
- let expectation = self.expectation(description: self.name!)
+ let format = Format(name: self.name, diskCapacity: 0) { _ in return expectedImage }
+ let key = self.name
+ let expectation = self.expectation(description: self.name)
sut.hnk_setImage(image, key: key, state: .highlighted, format: format, success:{resultImage in
XCTAssertTrue(resultImage.isEqualPixelByPixel(expectedImage))
@@ -188,7 +188,7 @@ class UIButton_HanekeTests: DiskTestCase {
})
let URL = Foundation.URL(string: "http://haneke.io")!
let fetcher = NetworkFetcher(URL: URL)
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setImageFromURL(URL, failure:{error in
XCTAssertEqual(error!._domain, HanekeGlobals.Domain)
@@ -203,7 +203,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImageFromURL_UsingFormat() {
let image = UIImage.imageWithColor(UIColor.red)
let expectedImage = UIImage.imageWithColor(UIColor.green)
- let format = Format(name: self.name!, diskCapacity: 0) { _ in return expectedImage }
+ let format = Format(name: self.name, diskCapacity: 0) { _ in return expectedImage }
OHHTTPStubs.stubRequests(passingTest: { _ in
return true
}, withStubResponse: { _ in
@@ -211,7 +211,7 @@ class UIButton_HanekeTests: DiskTestCase {
return OHHTTPStubsResponse(data: data!, statusCode: 200, headers:nil)
})
let URL = Foundation.URL(string: "http://haneke.io")!
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setImageFromURL(URL, format: format, success:{resultImage in
XCTAssertTrue(resultImage.isEqualPixelByPixel(expectedImage))
@@ -225,7 +225,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_Hit_Animated_UIControlStateSelected() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = AsyncFetcher(key: key, value: image)
let expectedImage = sut.hnk_imageFormat.apply(image)
@@ -243,7 +243,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_MemoryMiss_UIControlStateSelected() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
sut.hnk_setImageFromFetcher(fetcher, state: .selected)
@@ -254,7 +254,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_MemoryHit_UIControlStateNormal() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
let expectedImage = setImage(image, key: key, format: sut.hnk_imageFormat)
@@ -266,7 +266,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetImageFromFetcherSuccessFailure_MemoryHit_UIControlStateNormal() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
let cache = Shared.imageCache
let format = sut.hnk_imageFormat
@@ -333,7 +333,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImage_MemoryMiss_UIControlStateNormal() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.hnk_setBackgroundImage(image, key: key)
@@ -343,7 +343,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImage_MemoryHit_UIControlStateSelected() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let expectedImage = setImage(image, key: key, format: sut.hnk_backgroundImageFormat)
sut.hnk_setBackgroundImage(image, key: key, state: .selected)
@@ -356,7 +356,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImage_UsingPlaceholder_MemoryMiss_UIControlStateDisabled() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.hnk_setBackgroundImage(image, key: key, state: .disabled, placeholder: placeholder)
@@ -367,7 +367,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImage_UsingPlaceholder_MemoryHit_UIControlStateNormal() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let expectedImage = setImage(image, key: key, format: sut.hnk_backgroundImageFormat)
sut.hnk_setBackgroundImage(image, key: key, placeholder: placeholder)
@@ -380,7 +380,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImage_UsingFormat_UIControlStateHighlighted() {
let image = UIImage.imageWithColor(UIColor.red)
let expectedImage = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let format = Format(name: key, diskCapacity: 0) { _ in return expectedImage }
let expectation = self.expectation(description: key)
@@ -478,7 +478,7 @@ class UIButton_HanekeTests: DiskTestCase {
})
let URL = Foundation.URL(string: "http://haneke.io")!
let fetcher = NetworkFetcher(URL: URL)
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setBackgroundImageFromURL(URL, failure:{error in
XCTAssertEqual(error!._domain, HanekeGlobals.Domain)
@@ -493,7 +493,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImageFromURL_UsingFormat() {
let image = UIImage.imageWithColor(UIColor.red)
let expectedImage = UIImage.imageWithColor(UIColor.green)
- let format = Format(name: self.name!, diskCapacity: 0) { _ in return expectedImage }
+ let format = Format(name: self.name, diskCapacity: 0) { _ in return expectedImage }
OHHTTPStubs.stubRequests(passingTest: { _ in
return true
}, withStubResponse: { _ in
@@ -501,7 +501,7 @@ class UIButton_HanekeTests: DiskTestCase {
return OHHTTPStubsResponse(data: data!, statusCode: 200, headers:nil)
})
let URL = Foundation.URL(string: "http://haneke.io")!
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setBackgroundImageFromURL(URL, format: format, success:{resultImage in
XCTAssertTrue(resultImage.isEqualPixelByPixel(expectedImage))
@@ -515,7 +515,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImageFromFetcher_Hit_Animated_UIControlStateSelected() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = AsyncFetcher(key: key, value: image)
let expectedImage = sut.hnk_backgroundImageFormat.apply(image)
@@ -533,7 +533,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImageFromFetcher_MemoryMiss_UIControlStateSelected() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
sut.hnk_setBackgroundImageFromFetcher(fetcher, state: .selected)
@@ -544,7 +544,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImageFromFetcher_MemoryHit_UIControlStateNormal() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
let expectedImage = setImage(image, key: key, format: sut.hnk_backgroundImageFormat)
@@ -557,7 +557,7 @@ class UIButton_HanekeTests: DiskTestCase {
func testSetBackgroundImageFromFetcherSuccessFailure_MemoryHit_UIControlStateNormal() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
let cache = Shared.imageCache
let format = sut.hnk_backgroundImageFormat
diff --git a/HanekeTests/UIImage+HanekeTests.swift b/HanekeTests/UIImage+HanekeTests.swift
index 169d4493..ab81dd56 100644
--- a/HanekeTests/UIImage+HanekeTests.swift
+++ b/HanekeTests/UIImage+HanekeTests.swift
@@ -172,7 +172,7 @@ class UIImage_HanekeTests: XCTestCase {
let decompressedImage = image.hnk_decompressedImage()
XCTAssertNotEqual(image, decompressedImage)
- XCTAssertTrue((decompressedImage?.isEqualPixelByPixel(image))!, self.name!)
+ XCTAssertTrue((decompressedImage?.isEqualPixelByPixel(image))!, self.name)
}
func _testDecompressedImageWithOrientation(_ orientation : ExifOrientation) {
@@ -191,7 +191,7 @@ class UIImage_HanekeTests: XCTestCase {
let decompressedImage = image.hnk_decompressedImage()
XCTAssertNotEqual(image, decompressedImage)
- XCTAssertTrue((decompressedImage?.isEqualPixelByPixel(image))!, self.name!)
+ XCTAssertTrue((decompressedImage?.isEqualPixelByPixel(image))!, self.name)
}
}
diff --git a/HanekeTests/UIImageView+HanekeTests.swift b/HanekeTests/UIImageView+HanekeTests.swift
index 0c2bc985..8bf69058 100644
--- a/HanekeTests/UIImageView+HanekeTests.swift
+++ b/HanekeTests/UIImageView+HanekeTests.swift
@@ -125,7 +125,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImage_MemoryMiss() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.hnk_setImage(image, key: key)
@@ -135,7 +135,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImage_MemoryHit() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let expectedImage = setImage(image, key: key)
sut.hnk_setImage(image, key: key)
@@ -147,7 +147,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImage_ImageSet_MemoryMiss() {
let previousImage = UIImage.imageWithColor(UIColor.red)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.image = previousImage
sut.hnk_setImage(image, key: key)
@@ -159,7 +159,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImage_UsingPlaceholder_MemoryMiss() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.hnk_setImage(image, key: key, placeholder: placeholder)
@@ -170,7 +170,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImage_UsingPlaceholder_MemoryHit() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let expectedImage = setImage(image, key: key)
sut.hnk_setImage(image, key: key, placeholder: placeholder)
@@ -181,7 +181,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImage_Success() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
sut.contentMode = .center // No resizing
let expectation = self.expectation(description: key)
@@ -198,7 +198,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImage_UsingFormat() {
let image = UIImage.imageWithColor(UIColor.red)
let expectedImage = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let format = Format(name: key, diskCapacity: 0) { _ in return expectedImage }
let expectation = self.expectation(description: key)
@@ -214,7 +214,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_MemoryMiss() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
sut.hnk_setImage(fromFetcher: fetcher)
@@ -225,7 +225,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_MemoryHit() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
let expectedImage = setImage(image, key: key)
@@ -237,7 +237,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_Hit_Animated() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = AsyncFetcher(key: key, value: image)
let expectedImage = sut.hnk_format.apply(image)
@@ -256,7 +256,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_ImageSet_MemoryMiss() {
let previousImage = UIImage.imageWithColor(UIColor.red)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
sut.image = previousImage
@@ -269,7 +269,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_UsingPlaceholder_MemoryMiss() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
sut.hnk_setImage(fromFetcher: fetcher, placeholder:placeholder)
@@ -281,7 +281,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_UsingPlaceholder_MemoryHit() {
let placeholder = UIImage.imageWithColor(UIColor.yellow)
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
let expectedImage = setImage(image, key: key)
@@ -293,7 +293,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_Success() {
let image = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let fetcher = SimpleFetcher(key: key, value: image)
sut.contentMode = .center // No resizing
let expectation = self.expectation(description: key)
@@ -309,7 +309,7 @@ class UIImageView_HanekeTests: DiskTestCase {
}
func testSetImageFromFetcher_Failure() {
- let key = self.name!
+ let key = self.name
let fetcher = MockFetcher(key: key)
let expectation = self.expectation(description: key)
@@ -326,7 +326,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromFetcher_UsingFormat() {
let image = UIImage.imageWithColor(UIColor.red)
let expectedImage = UIImage.imageWithColor(UIColor.green)
- let key = self.name!
+ let key = self.name
let format = Format(name: key, diskCapacity: 0) { _ in return expectedImage }
let fetcher = SimpleFetcher(key: key, value: image)
let expectation = self.expectation(description: key)
@@ -443,7 +443,7 @@ class UIImageView_HanekeTests: DiskTestCase {
let URL = Foundation.URL(string: "http://haneke.io")!
let fetcher = NetworkFetcher(URL: URL)
sut.contentMode = .center // No resizing
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setImageFromURL(URL, success:{resultImage in
XCTAssertTrue(resultImage.isEqualPixelByPixel(image))
@@ -472,7 +472,7 @@ class UIImageView_HanekeTests: DiskTestCase {
})
let URL2 = URL(string: "http://haneke.io/2.png")!
let fetcher2 = NetworkFetcher(URL: URL2)
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setImageFromURL(URL2, success:{resultImage in
XCTAssertTrue(resultImage.isEqualPixelByPixel(image))
@@ -493,7 +493,7 @@ class UIImageView_HanekeTests: DiskTestCase {
})
let URL = Foundation.URL(string: "http://haneke.io")!
let fetcher = NetworkFetcher(URL: URL)
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setImageFromURL(URL, failure:{error in
XCTAssertEqual(error!._domain, HanekeGlobals.Domain)
@@ -508,7 +508,7 @@ class UIImageView_HanekeTests: DiskTestCase {
func testSetImageFromURL_UsingFormat() {
let image = UIImage.imageWithColor(UIColor.red)
let expectedImage = UIImage.imageWithColor(UIColor.green)
- let format = Format(name: self.name!, diskCapacity: 0) { _ in return expectedImage }
+ let format = Format(name: self.name, diskCapacity: 0) { _ in return expectedImage }
OHHTTPStubs.stubRequests(passingTest: { _ in
return true
}, withStubResponse: { _ in
@@ -516,7 +516,7 @@ class UIImageView_HanekeTests: DiskTestCase {
return OHHTTPStubsResponse(data: data!, statusCode: 200, headers:nil)
})
let URL = Foundation.URL(string: "http://haneke.io")!
- let expectation = self.expectation(description: self.name!)
+ let expectation = self.expectation(description: self.name)
sut.hnk_setImageFromURL(URL, format: format, success:{resultImage in
XCTAssertTrue(resultImage.isEqualPixelByPixel(expectedImage))