Skip to content

Instantly share code, notes, and snippets.

@uhooi
Last active May 18, 2020 02:00
Show Gist options
  • Save uhooi/b1f5404668022ad9ab10d39e0ee187d8 to your computer and use it in GitHub Desktop.
Save uhooi/b1f5404668022ad9ab10d39e0ee187d8 to your computer and use it in GitHub Desktop.
Unit testing sample: 3. Target method after refactoring
package packagename
class ExamLogic {
fun scoreExam(point: Int): String =
when (point) {
in 0..29 -> "赤点です!"
in 30..79 -> "まあまあです!"
in 80..99 -> "やるじゃん!"
100 -> "天才です!"
else -> "変な値を送るな!"
}
}
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 "変な値を送るな!"
}
}
}
@uhooi
Copy link
Author

uhooi commented May 18, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment