Moved to new module
This commit is contained in:
parent
8a76711fb5
commit
8d6257111a
|
@ -75,6 +75,11 @@ class ExceptionHandling {
|
||||||
else return message.length
|
else return message.length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun throwExpression(): Int? {
|
||||||
|
val message: String? = null
|
||||||
|
return message?.length ?: throw IllegalArgumentException("String is null")
|
||||||
|
}
|
||||||
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun throwsAnnotation(): String?{
|
fun throwsAnnotation(): String?{
|
||||||
val filePath = null
|
val filePath = null
|
|
@ -39,6 +39,11 @@ class ExceptionHandlingUnitTest {
|
||||||
assertThrows<IllegalArgumentException> { classUnderTest.throwKeyword() }
|
assertThrows<IllegalArgumentException> { classUnderTest.throwKeyword() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenIllegalArgument_whenElvisExpressionUsed_thenThrowsException(){
|
||||||
|
assertThrows<IllegalArgumentException> { classUnderTest.throwExpression() }
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun whenAnnotationUsed_thenThrowsException(){
|
fun whenAnnotationUsed_thenThrowsException(){
|
||||||
assertThrows<IOException> { classUnderTest.throwsAnnotation() }
|
assertThrows<IOException> { classUnderTest.throwsAnnotation() }
|
Loading…
Reference in New Issue