Last active
October 30, 2015 00:20
-
-
Save alexpersian/2dd2a14f8003f11e8272 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
//TODO: Write a test for the hex string -> UIColor conversion | |
func checkHexStringForDateString(dateString: String) { | |
// given | |
let changes: [String: String] = [ | |
"1" : "A", | |
"2" : "B", | |
"3" : "C", | |
"4" : "D", | |
"5" : "E", | |
"6" : "F" | |
] | |
var components = dateString.componentsSeparatedByString(" : ") | |
for i in 0...(components.count - 1) { | |
for (key, obj) in changes { | |
components[i] = components[i].stringByReplacingOccurrencesOfString(key, withString: obj) | |
} | |
} | |
let expected = "#".stringByAppendingString(components.joinWithSeparator(" : ")) | |
// when | |
let result = model.hexStringFromDateString(dateString) | |
// then | |
XCTAssertEqual(result, expected) | |
} | |
func testHexStringForDateString_shouldReturnAppropriateHexString() { | |
checkHexStringForDateString("#012345") | |
checkHexStringForDateString("#FDE283") | |
checkHexStringForDateString("#426ABC") | |
checkHexStringForDateString("#5F3A9D") | |
checkHexStringForDateString("#76CD92") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment