Skip to content

Commit e27a5a1

Browse files
authored
Fix div in junit-jupiter-starter-gradle-kotlin (#751)
Just a minor detail not relevant for the unit tests at all, but the previous implementation of the div method would do integer division and then convert to double, e.g. div(1, 2) == 0.0, not 0.5 as expected
1 parent b3e5633 commit e27a5a1

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

  • junit-jupiter-starter-gradle-kotlin/src/main/kotlin/com/example/project

‎junit-jupiter-starter-gradle-kotlin/src/main/kotlin/com/example/project/Calculator.kt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Calculator {
1818

1919
fun div(a: Int, b: Int): Double {
2020
assert(b != 0) { "Division by Zero" }
21-
return a / b * 1.0
21+
return a.toDouble() / b
2222
}
23-
2423
}

0 commit comments

Comments
 (0)