Skip to content

Instantly share code, notes, and snippets.

@uhooi
Last active May 18, 2020 00:22
Show Gist options
  • Save uhooi/0aa127154bc0c14cba3887c42eee1d87 to your computer and use it in GitHub Desktop.
Save uhooi/0aa127154bc0c14cba3887c42eee1d87 to your computer and use it in GitHub Desktop.
Unit testing sample: 1. Target method before refactoring
package packagename
class ExamLogic {
fun scoreExam(point: Int): String {
if (point < 0 || point > 100) {
return "変な値を送るな!"
}
if (point < 30) {
return "赤点です!"
}
if (point < 80) {
return "まあまあです!"
}
if (point < 100) {
return "やるじゃん!"
}
return "天才です!"
}
}
class ExamLogic {
func scoreExam(point: Int) -> String {
if point < 0 || point > 100 {
return "変な値を送るな!"
}
if point < 30 {
return "赤点です!"
}
if point < 80 {
return "まあまあです!"
}
if point < 100 {
return "やるじゃん!"
}
return "天才です!"
}
}
@uhooi
Copy link
Author

uhooi commented May 17, 2020

@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