From 118e38fafa0047b622c9a61b7b3319629a79cb0d Mon Sep 17 00:00:00 2001 From: Tuomas Airaksinen Date: Wed, 21 Jun 2023 18:52:45 +0300 Subject: [PATCH] Add little test to make sure I understand try-catch-finally --- .../bible/service/common/CommonUtilsTest.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/net/bible/service/common/CommonUtilsTest.kt b/app/src/test/java/net/bible/service/common/CommonUtilsTest.kt index 7e6dcf275d..6b86b65517 100644 --- a/app/src/test/java/net/bible/service/common/CommonUtilsTest.kt +++ b/app/src/test/java/net/bible/service/common/CommonUtilsTest.kt @@ -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 @@ -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)) + } }