mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-25 19:48: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(
|
||||
other: Iterable<T>
|
||||
) = calculateDiff(other, true)
|
||||
) = calculateDiff(other, strictComparison = true)
|
||||
|
||||
/**
|
||||
* 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
|
||||
fun testThatSimpleAddWorks() {
|
||||
val oldList = (0 until 10).map { it.toString() }
|
||||
@ -40,10 +36,10 @@ class DiffUtilsTests {
|
||||
if (i + count > oldList.lastIndex) {
|
||||
continue
|
||||
}
|
||||
val addedSublist = oldList.subList(i, i + count)
|
||||
val addedSublist = oldList.subList(i, i + count).map { "added$it" }
|
||||
val mutable = oldList.toMutableList()
|
||||
mutable.addAll(i, oldList.subList(i, i + count).map { it.toCharArray().concatToString() })
|
||||
oldList.calculateStrictDiff(mutable).apply {
|
||||
mutable.addAll(i, addedSublist)
|
||||
oldList.calculateDiff(mutable).apply {
|
||||
assertEquals(
|
||||
addedSublist.mapIndexed { j, o -> IndexedValue(i + j, o) },
|
||||
added
|
||||
|
Loading…
Reference in New Issue
Block a user