Added lastOrEmpty() extension function.

This commit is contained in:
Erik C. Thauvin 2021-11-28 23:24:14 -08:00
parent 10f1ee8518
commit 97a9fd1597
3 changed files with 15 additions and 16 deletions

View file

@ -46,6 +46,7 @@ import net.thauvin.erik.mobibot.Utils.encodeUrl
import net.thauvin.erik.mobibot.Utils.getIntProperty
import net.thauvin.erik.mobibot.Utils.green
import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.Utils.lastOrEmpty
import net.thauvin.erik.mobibot.Utils.obfuscate
import net.thauvin.erik.mobibot.Utils.plural
import net.thauvin.erik.mobibot.Utils.red
@ -187,6 +188,14 @@ class UtilsTest {
assertThat(localDateTime.toIsoLocalDate(), "isoLocalDate(localDate)").isEqualTo("1952-02-17")
}
@Test
fun testLastOrEmpty() {
val two = listOf("1", "2")
assertThat(two.lastOrEmpty(), "two").isEqualTo("2")
val one = listOf("1")
assertThat(one.lastOrEmpty(), "one").isEqualTo("")
}
@Test
fun testObfuscate() {
assertThat(ascii.obfuscate(), "obfuscate()").all {