Created
January 15, 2020 09:24
-
-
Save bannzai/c5d62f927fa521a7fae076eac1156418 to your computer and use it in GitHub Desktop.
ロマンが無い書き方
This file contains hidden or 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
typealias InputAndExpected = [String: String] | |
let x: InputAndExpected = [ | |
"11": "11.0", | |
"11.0": "11.0", | |
"11.01": "11.01", | |
"11.1": "11.1", | |
"11.10": "11.10", | |
"11.11": "11.11" | |
] | |
func convert(input: String) -> String { | |
input.contains(".") ? input : input + ".0" | |
} | |
func isValid(input: String) -> Bool { | |
Float(input) != nil | |
} | |
for (key, value) in x { | |
let v = convert(input: key) | |
if value != v { | |
fatalError("failure \(key), value: \(value), v: \(v)") | |
} | |
if !isValid(input: v) { | |
fatalError("failure \(key), value: \(value), v: \(v)") | |
} | |
} | |
print("Finish") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment