Skip to content

Commit

Permalink
Add little test to make sure I understand try-catch-finally
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Jun 21, 2023
1 parent 1ac9133 commit 118e38f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions app/src/test/java/net/bible/service/common/CommonUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package net.bible.service.common

import net.bible.service.common.CommonUtils.getKeyDescription
import org.crosswire.jsword.versification.Versification
import org.crosswire.jsword.versification.system.Versifications
import org.crosswire.jsword.versification.BibleBook
import net.bible.service.common.CommonUtils
import org.crosswire.jsword.passage.Verse
import org.hamcrest.CoreMatchers
import org.hamcrest.MatcherAssert
import org.hamcrest.core.IsEqual
import org.junit.Assert
import org.junit.Test

Expand All @@ -37,4 +37,21 @@ class CommonUtilsTest {
val gen1_10 = Verse(kjv, BibleBook.GEN, 1, 10)
Assert.assertThat(getKeyDescription(gen1_10), CoreMatchers.equalTo("Genesis 1:10"))
}

@Test
fun tryCatchFinallyIsRunAlways() {
var v = 0
try {
try {
throw Exception()
} catch (e: Exception) {
throw e
} finally {
v = 1
}
} catch (e: Exception) {

}
MatcherAssert.assertThat(v, IsEqual.equalTo(1))
}
}

0 comments on commit 118e38f

Please sign in to comment.