Last active
May 18, 2020 02:00
-
-
Save uhooi/b1f5404668022ad9ab10d39e0ee187d8 to your computer and use it in GitHub Desktop.
Unit testing sample: 3. Target method after refactoring
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
package packagename | |
class ExamLogic { | |
fun scoreExam(point: Int): String = | |
when (point) { | |
in 0..29 -> "赤点です!" | |
in 30..79 -> "まあまあです!" | |
in 80..99 -> "やるじゃん!" | |
100 -> "天才です!" | |
else -> "変な値を送るな!" | |
} | |
} |
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
class ExamLogic { | |
func scoreExam(point: Int) -> String { | |
switch point { | |
case 0...29: | |
return "赤点です!" | |
case 30...79: | |
return "まあまあです!" | |
case 80...99: | |
return "やるじゃん!" | |
case 100: | |
return "天才です!" | |
default: | |
return "変な値を送るな!" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ref: https://twitter.com/the_uhooi/status/1261934636466241536?s=20