Add samples for coerceIn
#KT-20357
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package samples.comparisons
|
||||
|
||||
import samples.*
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
class ComparableOps {
|
||||
|
||||
@@ -31,4 +32,15 @@ class ComparableOps {
|
||||
assertPrints(10.coerceAtMost(5), "5")
|
||||
assertPrints(10.coerceAtMost(20), "10")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun coerceIn() {
|
||||
assertPrints(10.coerceIn(1, 100), "10")
|
||||
assertPrints(10.coerceIn(1..100), "10")
|
||||
assertPrints(0.coerceIn(1, 100), "1")
|
||||
assertPrints(500.coerceIn(1, 100), "100")
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
10.coerceIn(100, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user