2019-01-31 19:03:34 +01:00
|
|
|
package com.keylesspalace.tusky
|
|
|
|
|
|
|
|
import com.keylesspalace.tusky.util.isLessThan
|
2022-03-12 09:38:48 +01:00
|
|
|
import com.keylesspalace.tusky.util.isLessThanOrEqual
|
2021-06-28 21:13:24 +02:00
|
|
|
import org.junit.Assert.assertFalse
|
|
|
|
import org.junit.Assert.assertTrue
|
2019-01-31 19:03:34 +01:00
|
|
|
import org.junit.Test
|
|
|
|
|
|
|
|
class StringUtilsTest {
|
|
|
|
@Test
|
|
|
|
fun isLessThan() {
|
|
|
|
val lessList = listOf(
|
2021-06-28 21:13:24 +02:00
|
|
|
"abc" to "bcd",
|
|
|
|
"ab" to "abc",
|
|
|
|
"cb" to "abc",
|
|
|
|
"1" to "2"
|
2019-01-31 19:03:34 +01:00
|
|
|
)
|
|
|
|
lessList.forEach { (l, r) -> assertTrue("$l < $r", l.isLessThan(r)) }
|
|
|
|
val notLessList = lessList.map { (l, r) -> r to l } + listOf(
|
2021-06-28 21:13:24 +02:00
|
|
|
"abc" to "abc"
|
2019-01-31 19:03:34 +01:00
|
|
|
)
|
|
|
|
notLessList.forEach { (l, r) -> assertFalse("not $l < $r", l.isLessThan(r)) }
|
|
|
|
}
|
|
|
|
|
2022-03-12 09:38:48 +01:00
|
|
|
@Test
|
|
|
|
fun isLessThanOrEqual() {
|
|
|
|
val lessList = listOf(
|
|
|
|
"abc" to "bcd",
|
|
|
|
"ab" to "abc",
|
|
|
|
"cb" to "abc",
|
|
|
|
"1" to "2",
|
|
|
|
"abc" to "abc",
|
|
|
|
)
|
|
|
|
lessList.forEach { (l, r) -> assertTrue("$l < $r", l.isLessThanOrEqual(r)) }
|
|
|
|
val notLessList = lessList.filterNot { (l, r) -> l == r }.map { (l, r) -> r to l }
|
|
|
|
notLessList.forEach { (l, r) -> assertFalse("not $l < $r", l.isLessThanOrEqual(r)) }
|
|
|
|
}
|
2021-06-28 21:13:24 +02:00
|
|
|
}
|