mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-29 13:38:45 +00:00
fix add test for common diff utils
This commit is contained in:
parent
f0127b018e
commit
864d576e70
@ -148,7 +148,7 @@ inline fun <T> StrictDiff(old: Iterable<T>, new: Iterable<T>) = old.calculateDif
|
|||||||
*/
|
*/
|
||||||
inline fun <T> Iterable<T>.calculateStrictDiff(
|
inline fun <T> Iterable<T>.calculateStrictDiff(
|
||||||
other: Iterable<T>
|
other: Iterable<T>
|
||||||
) = calculateDiff(other, true)
|
) = calculateDiff(other, strictComparison = true)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare one-to-one
|
* Compare one-to-one
|
||||||
|
@ -26,10 +26,6 @@ class DiffUtilsTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* In this test was used [calculateDiff] parameter `strictComparison`. That is required to be sure that the same
|
|
||||||
* objects with different links will be used as different objects in `strictComparison` mode
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
fun testThatSimpleAddWorks() {
|
fun testThatSimpleAddWorks() {
|
||||||
val oldList = (0 until 10).map { it.toString() }
|
val oldList = (0 until 10).map { it.toString() }
|
||||||
@ -40,10 +36,10 @@ class DiffUtilsTests {
|
|||||||
if (i + count > oldList.lastIndex) {
|
if (i + count > oldList.lastIndex) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val addedSublist = oldList.subList(i, i + count)
|
val addedSublist = oldList.subList(i, i + count).map { "added$it" }
|
||||||
val mutable = oldList.toMutableList()
|
val mutable = oldList.toMutableList()
|
||||||
mutable.addAll(i, oldList.subList(i, i + count).map { it.toCharArray().concatToString() })
|
mutable.addAll(i, addedSublist)
|
||||||
oldList.calculateStrictDiff(mutable).apply {
|
oldList.calculateDiff(mutable).apply {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
addedSublist.mapIndexed { j, o -> IndexedValue(i + j, o) },
|
addedSublist.mapIndexed { j, o -> IndexedValue(i + j, o) },
|
||||||
added
|
added
|
||||||
|
Loading…
Reference in New Issue
Block a user