Skip to content

Instantly share code, notes, and snippets.

@ininmm
Created October 14, 2019 09:54
Show Gist options
  • Save ininmm/3fa95f4d878a69b3f10d67a3c193e1ca to your computer and use it in GitHub Desktop.
Save ininmm/3fa95f4d878a69b3f10d67a3c193e1ca to your computer and use it in GitHub Desktop.
a test for choosing the max value
fun chooseTheMaxValue(first: Int, second: Int, third: Int): Int {
// 從三個數中找出最大數
// 假設了一個故意錯誤的邏輯
if (second > third) {
return third
}
if (first > third) {
return third
}
......
return 正確的最大數
}
......
@Test
fun testSumAndDivide() {
assertThat(chooseTheMaxValue(6, 2, 1), `is`(6))
assertThat(chooseTheMaxValue(1, 6, 2), `is`(6))
assertThat(chooseTheMaxValue(1, 2, 6), `is`(6))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment