mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Correct Comparable interface used for isOrderedAndUnique()
This commit is contained in:
parent
8f1329b03f
commit
65a03efc55
@ -13,7 +13,6 @@ import rx.Observable
|
||||
import rx.subjects.UnicastSubject
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.InputStream
|
||||
import java.lang.Comparable
|
||||
import java.math.BigDecimal
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.LinkOption
|
||||
@ -293,7 +292,7 @@ fun <T, I: Comparable<I>> Iterable<T>.isOrderedAndUnique(extractId: T.() -> I):
|
||||
if (lastLast == null) {
|
||||
true
|
||||
} else {
|
||||
lastLast.compareTo(extractId(it)) < 0
|
||||
lastLast < extractId(it)
|
||||
}
|
||||
}
|
||||
}
|
24
core/src/test/kotlin/com/r3corda/core/UtilsTest.kt
Normal file
24
core/src/test/kotlin/com/r3corda/core/UtilsTest.kt
Normal file
@ -0,0 +1,24 @@
|
||||
package com.r3corda.core
|
||||
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class UtilsTest {
|
||||
fun `ordered and unique basic`() {
|
||||
val basic = listOf(1, 2, 3, 5, 8)
|
||||
assertTrue(basic.isOrderedAndUnique { this })
|
||||
|
||||
val negative = listOf(-1, 2, 5)
|
||||
assertTrue(negative.isOrderedAndUnique { this })
|
||||
}
|
||||
|
||||
fun `ordered and unique duplicate`() {
|
||||
val duplicated = listOf(1, 2, 2, 3, 5, 8)
|
||||
assertFalse(duplicated.isOrderedAndUnique { this })
|
||||
}
|
||||
|
||||
fun `ordered and unique out of sequence`() {
|
||||
val mixed = listOf(3, 1, 2, 8, 5)
|
||||
assertFalse(mixed.isOrderedAndUnique { this })
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user