fix add test for common diff utils

This commit is contained in:
InsanusMokrassar 2020-11-02 00:19:23 +06:00
parent f0127b018e
commit 864d576e70
2 changed files with 4 additions and 8 deletions

View File

@ -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

View File

@ -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