Skip to content

Instantly share code, notes, and snippets.

@alexpersian
Last active October 30, 2015 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpersian/2dd2a14f8003f11e8272 to your computer and use it in GitHub Desktop.
Save alexpersian/2dd2a14f8003f11e8272 to your computer and use it in GitHub Desktop.
//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