1 package net.pterodactylus.sone.utils
3 import org.hamcrest.MatcherAssert.assertThat
4 import org.hamcrest.Matchers.*
8 * Unit test for Object utils.
13 fun `non-null value is turned into a list with one element`() {
14 assertThat(5.asList(), contains(5))
18 fun `null value is turned into empty list`() {
19 assertThat(null.asList(), empty())
22 @Test(expected = IllegalArgumentException::class)
23 fun `exception is thrown for null and true condition`() {
24 null.throwOnNullIf(true) { IllegalArgumentException() }
28 fun `exception is not thrown for null and false condition`() {
29 assertThat(null.throwOnNullIf(false) { IllegalArgumentException() }, nullValue())
33 fun `exception is not thrown for any and true condition`() {
35 assertThat(any.throwOnNullIf(true) { IllegalArgumentException() }, equalTo(any))
39 fun `exception is not thrown for any and false condition`() {
41 assertThat(any.throwOnNullIf(false) { IllegalArgumentException() }, equalTo(any))