From 864d576e70cc748e2709c265be485ae750d260de Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 2 Nov 2020 00:19:23 +0600 Subject: [PATCH] fix add test for common diff utils --- .../kotlin/dev/inmo/micro_utils/common/DiffUtils.kt | 2 +- .../dev/inmo/micro_utils/common/DiffUtilsTests.kt | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt index 39477a272d2..7033edcfb6f 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/DiffUtils.kt @@ -148,7 +148,7 @@ inline fun StrictDiff(old: Iterable, new: Iterable) = old.calculateDif */ inline fun Iterable.calculateStrictDiff( other: Iterable -) = calculateDiff(other, true) +) = calculateDiff(other, strictComparison = true) /** * Compare one-to-one diff --git a/common/src/commonTest/kotlin/dev/inmo/micro_utils/common/DiffUtilsTests.kt b/common/src/commonTest/kotlin/dev/inmo/micro_utils/common/DiffUtilsTests.kt index fdaa2611059..6bf75aa9dd4 100644 --- a/common/src/commonTest/kotlin/dev/inmo/micro_utils/common/DiffUtilsTests.kt +++ b/common/src/commonTest/kotlin/dev/inmo/micro_utils/common/DiffUtilsTests.kt @@ -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