🔀 Merge next
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / utils / BooleansTest.kt
index 56627c3..a1b6da7 100644 (file)
@@ -1,9 +1,8 @@
 package net.pterodactylus.sone.utils
 
-import org.hamcrest.MatcherAssert.assertThat
-import org.hamcrest.Matchers.equalTo
-import org.hamcrest.Matchers.nullValue
-import org.junit.Test
+import org.hamcrest.MatcherAssert.*
+import org.hamcrest.Matchers.*
+import kotlin.test.*
 
 /**
  * Unit test for [Booleans].
@@ -30,4 +29,24 @@ class BooleansTest {
                assertThat(true.ifFalse { true }, nullValue())
        }
 
+       @Test
+       fun `onFalse returns true on true`() {
+               assertThat(true.onFalse {}, equalTo(true))
+       }
+
+       @Test
+       fun `onFalse returns false on false`() {
+               assertThat(false.onFalse {}, equalTo(false))
+       }
+
+       @Test
+       fun `onFalse is not executed on true`() {
+               assertThat(true.onFalse { throw RuntimeException() }, equalTo(true))
+       }
+
+       @Test(expected = RuntimeException::class)
+       fun `onFalse is executed on false`() {
+               false.onFalse { throw RuntimeException() }
+       }
+
 }