Refine the exception type of EmptyRange.random()
Make it the same type as in case of an empty collection, so that `emptyRange.random()` throws the same exception as `emptyRange.toList().random()`. #KT-15539
This commit is contained in:
@@ -388,4 +388,12 @@ public class RangeTest {
|
||||
assertFailsWithIllegalArgument { UIntProgression.fromClosedRange(0u, 1u, Int.MIN_VALUE) }
|
||||
assertFailsWithIllegalArgument { ULongProgression.fromClosedRange(0u, 1u, Long.MIN_VALUE) }
|
||||
}
|
||||
|
||||
@Test fun randomInEmptyRange() {
|
||||
assertFailsWith<NoSuchElementException> { IntRange.EMPTY.random() }
|
||||
assertFailsWith<NoSuchElementException> { LongRange.EMPTY.random() }
|
||||
assertFailsWith<NoSuchElementException> { CharRange.EMPTY.random() }
|
||||
assertFailsWith<NoSuchElementException> { UIntRange.EMPTY.random() }
|
||||
assertFailsWith<NoSuchElementException> { ULongRange.EMPTY.random() }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user