Moved to new module

This commit is contained in:
Anirban Chatterjee 2020-07-18 12:54:29 +02:00
parent 8a76711fb5
commit 8d6257111a
2 changed files with 10 additions and 0 deletions

View File

@ -75,6 +75,11 @@ class ExceptionHandling {
else return message.length
}
fun throwExpression(): Int? {
val message: String? = null
return message?.length ?: throw IllegalArgumentException("String is null")
}
@Throws(IOException::class)
fun throwsAnnotation(): String?{
val filePath = null

View File

@ -39,6 +39,11 @@ class ExceptionHandlingUnitTest {
assertThrows<IllegalArgumentException> { classUnderTest.throwKeyword() }
}
@Test
fun givenIllegalArgument_whenElvisExpressionUsed_thenThrowsException(){
assertThrows<IllegalArgumentException> { classUnderTest.throwExpression() }
}
@Test
fun whenAnnotationUsed_thenThrowsException(){
assertThrows<IOException> { classUnderTest.throwsAnnotation() }