Skip to content

Commit

Permalink
Equatable and Hashable revision (#141)
Browse files Browse the repository at this point in the history
* Removed supported 'Hashable' and 'Equatable' conformance implementation

* ServerTrustEvaluator.PinningPolicy has custom Equatable conformance

* Added Equatable to Route.Component.Key

* Removed unnecessary `Equatable` conformance and placed manual `hashValue` on PinningPolicy

* Reset changes on `ServerTrustEvaluator+Configuration.swift`
  • Loading branch information
ivopintodasilva authored Jun 1, 2018
1 parent 2f0e93c commit cf86fde
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 43 deletions.
23 changes: 1 addition & 22 deletions Sources/DeepLinking/Route+Component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public extension Route {

// MARK: Key

public enum Key {
public enum Key: Hashable {
case empty
case constant(String)
case variable
Expand Down Expand Up @@ -124,27 +124,6 @@ extension Route.Component: CustomStringConvertible, CustomDebugStringConvertible
}
}

extension Route.Component.Key: Hashable {

// MARK: Hashable

public var hashValue: Int {
switch self {
case .empty: return "\(type(of: self).empty)".hashValue
case let .constant(value): return value.hashValue
case .variable: return "\(type(of: self).variable)".hashValue
}
}

public static func == (lhs: Route.Component.Key, rhs: Route.Component.Key) -> Bool {
switch (lhs, rhs) {
case (.empty, .empty), (.variable, .variable): return true
case let (.constant(lhsString), .constant(rhsString)): return lhsString == rhsString
default: return false
}
}
}

extension Route.Component.Key: CustomStringConvertible, CustomDebugStringConvertible {

// MARK: CustomStringConvertible
Expand Down
8 changes: 1 addition & 7 deletions Tests/AlicerceTests/Network/JSONTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ class JSONTests: XCTestCase {
}
}

private struct MockMappableObject {
private struct MockMappableObject: Equatable {
let keyA: String
let keyB: Int
}
Expand All @@ -1985,9 +1985,3 @@ extension MockMappableObject: Mappable {
fatalError("💥 not implemented")
}
}

extension MockMappableObject: Equatable {
static func == (lhs: MockMappableObject, rhs: MockMappableObject) -> Bool {
return lhs.keyA == rhs.keyA && lhs.keyB == rhs.keyB
}
}
8 changes: 1 addition & 7 deletions Tests/AlicerceTests/Network/MappableModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
@testable import Alicerce

struct MappableModel {
struct MappableModel: Equatable {
let data: String
}

Expand All @@ -30,9 +30,3 @@ extension MappableModel: Mappable {
return ["data" : self.data]
}
}

extension MappableModel: Equatable {
static func ==(lhs: MappableModel, rhs: MappableModel) -> Bool {
return lhs.data == lhs.data
}
}
8 changes: 1 addition & 7 deletions Tests/AlicerceTests/UIKit/MockReusableViewModelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import Foundation

@testable import Alicerce

struct MockReusableViewModelView {
struct MockReusableViewModelView: Equatable {
let testProperty = "😎"
}

extension MockReusableViewModelView: Equatable {
static func ==(lhs: MockReusableViewModelView, rhs: MockReusableViewModelView) -> Bool {
return lhs.testProperty == rhs.testProperty
}
}

0 comments on commit cf86fde

Please sign in to comment.