diff --git a/MTMR.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme b/MTMR.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme index 402b474..f5739de 100644 --- a/MTMR.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme +++ b/MTMR.xcodeproj/xcshareddata/xcschemes/UnitTests.xcscheme @@ -11,7 +11,8 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" language = "" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift index 9bb37ab..4cfe593 100644 --- a/MTMR/ItemsParsing.swift +++ b/MTMR/ItemsParsing.swift @@ -332,59 +332,6 @@ enum LongActionType: Decodable { } } -extension ItemType: Equatable {} -func ==(lhs: ItemType, rhs: ItemType) -> Bool { - switch (lhs, rhs) { - case let (.staticButton(a), .staticButton(b)): - return a == b - case let (.appleScriptTitledButton(a, b), .appleScriptTitledButton(c, d)): - return a == c && b == d - - default: - return false - } -} - -extension ActionType: Equatable {} -func ==(lhs: ActionType, rhs: ActionType) -> Bool { - switch (lhs, rhs) { - case (.none, .none): - return true - case let (.hidKey(a), .hidKey(b)): - return a == b - case let (.keyPress(a), .keyPress(b)): - return a == b - case let (.appleSctipt(a), .appleSctipt(b)): - return a == b - case let (.shellScript(a, b), .shellScript(c, d)): - return a == c && b == d - case let (.openUrl(a), .openUrl(b)): - return a == b - default: - return false - } -} - - -extension LongActionType: Equatable {} -func ==(lhs: LongActionType, rhs: LongActionType) -> Bool { - switch (lhs, rhs) { - case (.none, .none): - return true - case let (.hidKey(a), .hidKey(b)): - return a == b - case let (.keyPress(a), .keyPress(b)): - return a == b - case let (.appleSctipt(a), .appleSctipt(b)): - return a == b - case let (.shellScript(a, b), .shellScript(c, d)): - return a == c && b == d - case let (.openUrl(a), .openUrl(b)): - return a == b - default: - return false - } -} enum GeneralParameter { case width(_: CGFloat) @@ -470,10 +417,6 @@ extension NSImage: SourceProtocol { return self } } -extension SourceProtocol where Self: Equatable {} -func ==(left: SourceProtocol, right: SourceProtocol) -> Bool { - return left.data == right.data -} extension String { var base64Data: Data? { diff --git a/MTMRTests/ParseConfigTests.swift b/MTMRTests/ParseConfigTests.swift index 1c95dca..f5e4221 100644 --- a/MTMRTests/ParseConfigTests.swift +++ b/MTMRTests/ParseConfigTests.swift @@ -7,8 +7,14 @@ class ParseConfig: XCTestCase { [ { "type": "staticButton", "title": "Pew" } ] """.data(using: .utf8)! let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture) - XCTAssertEqual(result?.first?.type, .staticButton(title: "Pew")) - XCTAssertEqual(result?.first?.action, .some(.none)) + guard case .staticButton("Pew")? = result?.first?.type else { + XCTFail() + return + } + guard case .none? = result?.first?.action else { + XCTFail() + return + } } func testButtonKeyCodeAction() { @@ -16,8 +22,14 @@ class ParseConfig: XCTestCase { [ { "type": "staticButton", "title": "Pew", "action": "hidKey", "keycode": 123} ] """.data(using: .utf8)! let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonKeycodeFixture) - XCTAssertEqual(result?.first?.type, .staticButton(title: "Pew")) - XCTAssertEqual(result?.first?.action, .hidKey(keycode: 123)) + guard case .staticButton("Pew")? = result?.first?.type else { + XCTFail() + return + } + guard case .hidKey(keycode: 123)? = result?.first?.action else { + XCTFail() + return + } } func testPredefinedItem() { @@ -25,8 +37,14 @@ class ParseConfig: XCTestCase { [ { "type": "escape" } ] """.data(using: .utf8)! let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonKeycodeFixture) - XCTAssertEqual(result?.first?.type, .staticButton(title: "esc")) - XCTAssertEqual(result?.first?.action, .keyPress(keycode: 53)) + guard case .staticButton("esc")? = result?.first?.type else { + XCTFail() + return + } + guard case .keyPress(keycode: 53)? = result?.first?.action else { + XCTFail() + return + } } func testExtendedWidthForPredefinedItem() { @@ -34,8 +52,18 @@ class ParseConfig: XCTestCase { [ { "type": "escape", "width": 110}, ] """.data(using: .utf8)! let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonKeycodeFixture) - XCTAssertEqual(result?.first?.type, .staticButton(title: "esc")) - XCTAssertEqual(result?.first?.action, .keyPress(keycode: 53)) + guard case .staticButton("esc")? = result?.first?.type else { + XCTFail() + return + } + guard case .keyPress(keycode: 53)? = result?.first?.action else { + XCTFail() + return + } + guard case .width(110)? = result?.first?.additionalParameters[.width] else { + XCTFail() + return + } } }