Last active
March 26, 2017 00:31
-
-
Save BalestraPatrick/53a0727422a8659b4659a7abd172f9c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dictionary: [String: Any] = [ | |
"color": "blue", | |
"width": 5.0, | |
] | |
func XCTAssertEqual(_ l: [String: Any], _ r: [String: Any]) { | |
l.keys.forEach { key in | |
if let left = l[key] as? String, let right = r[key] as? String { | |
XCTAssertEqual(left, right) | |
} else if let left = l[key] as? CGFloat, let right = r[key] as? CGFloat { | |
XCTAssertEqual(left, right) | |
} else if let left = l[key] as? Bool, let right = r[key] as? Bool { | |
XCTAssertEqual(left, right) | |
} else { | |
XCTFail() | |
} | |
// And on and on with all your supported types... | |
} | |
} | |
XCTAssertEqual(dictionary, dictionary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AndreiVidrasco That should work but unfortunately it doesn't support nested objects, like I wrote before with
AnyHashable
.