From ce3987d009a3c79ef54e83687173c5a7324333b7 Mon Sep 17 00:00:00 2001 From: anzhu Date: Tue, 11 Apr 2023 12:24:41 +0300 Subject: [PATCH] Add 2 tests for merge indexes --- src/commonTest/kotlin/testMerge.kt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/commonTest/kotlin/testMerge.kt b/src/commonTest/kotlin/testMerge.kt index d6d2548..7b9a253 100644 --- a/src/commonTest/kotlin/testMerge.kt +++ b/src/commonTest/kotlin/testMerge.kt @@ -1,4 +1,5 @@ import net.sergeych.merge3.MergeResult +import net.sergeych.merge3.MergedBlock import net.sergeych.merge3.merge3 import net.sergeych.mp_logger.Log import net.sergeych.sprintf.sprintf @@ -74,4 +75,30 @@ class BasicTest { println(m.changedAreas) assertEquals("Hello 123456", m.merged.str) } + + @Test + fun testMergeIndexes() { + Log.connectConsole() + val src = "Hello".toList() + val a = "123 Hello".toList() + val b = "456 Hello".toList() + + val m = merge3(src, b, a, true) + val unchanged = m.blocks.last() as MergedBlock.Unchanged + println(unchanged) + assertEquals(0, unchanged.referenceIndex) + } + + @Test + fun testMergeIndexes2() { + Log.connectConsole() + val src = "Hello".toList() + val a = "1Hello".toList() + val b = "2Hello".toList() + + val m = merge3(src, b, a, true) + val unchanged = m.blocks.last() as MergedBlock.Unchanged + println(unchanged) + assertEquals(0, unchanged.referenceIndex) + } } \ No newline at end of file