summaryrefslogtreecommitdiff
path: root/test/merge4.test
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
committercashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
commit4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch)
treec296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /test/merge4.test
downloadrelic-master.tar.gz
initial commitHEADmaster
Diffstat (limited to 'test/merge4.test')
-rw-r--r--test/merge4.test105
1 files changed, 105 insertions, 0 deletions
diff --git a/test/merge4.test b/test/merge4.test
new file mode 100644
index 0000000..629ba9c
--- /dev/null
+++ b/test/merge4.test
@@ -0,0 +1,105 @@
+#
+# Copyright (c) 2009 D. Richard Hipp
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the Simplified BSD License (also
+# known as the "2-Clause License" or "FreeBSD License".)
+#
+# This program is distributed in the hope that it will be useful,
+# but without any warranty; without even the implied warranty of
+# merchantability or fitness for a particular purpose.
+#
+# Author contact information:
+# drh@hwaci.com
+# http://www.hwaci.com/drh/
+#
+############################################################################
+#
+# Tests of the 3-way merge
+#
+
+test_setup ""
+
+proc merge-test {testid basis v1 v2 result1 result2 {fossil_args ""}} {
+ write_file t1 [join [string trim $basis] \n]\n
+ write_file t2 [join [string trim $v1] \n]\n
+ write_file t3 [join [string trim $v2] \n]\n
+ fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args
+ fossil 3-way-merge t1 t3 t2 t5 {*}$fossil_args
+ set x [read_file t4]
+ regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $x {>} x
+ regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $x {#} x
+ regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $x {=} x
+ regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $x {<} x
+ set x [split [string trim $x] \n]
+ set y [read_file t5]
+ regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $y {>} y
+ regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $y {#} y
+ regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $y {=} y
+ regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $y {<} y
+ set y [split [string trim $y] \n]
+ set result1 [string trim $result1]
+ if {$x!=$result1} {
+ protOut " Expected \[$result1\]"
+ protOut " Got \[$x\]"
+ test merge4-$testid 0
+ } else {
+ set result2 [string trim $result2]
+ if {$y!=$result2} {
+ protOut " Expected \[$result2\]"
+ protOut " Got \[$y\]"
+ test merge4-$testid 0
+ } else {
+ test merge4-$testid 1
+ }
+ }
+}
+
+merge-test 1000 {
+ 1 2 3 4 5 6 7 8 9
+} {
+ 1 2b 3b 4b 5 6b 7b 8b 9
+} {
+ 1 2 3 4c 5c 6c 7 8 9
+} {
+ 1 > 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 < 9
+} {
+ 1 > 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b < 9
+} -expectError
+merge-test 1001 {
+ 1 2 3 4 5 6 7 8 9
+} {
+ 1 2b 3b 4 5 6 7b 8b 9
+} {
+ 1 2 3 4c 5c 6c 7 8 9
+} {
+ 1 2b 3b 4c 5c 6c 7b 8b 9
+} {
+ 1 2b 3b 4c 5c 6c 7b 8b 9
+}
+merge-test 1002 {
+ 2 3 4 5 6 7 8
+} {
+ 2b 3b 4b 5 6b 7b 8b
+} {
+ 2 3 4c 5c 6c 7 8
+} {
+ > 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 <
+} {
+ > 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b <
+} -expectError
+merge-test 1003 {
+ 2 3 4 5 6 7 8
+} {
+ 2b 3b 4 5 6 7b 8b
+} {
+ 2 3 4c 5c 6c 7 8
+} {
+ 2b 3b 4c 5c 6c 7b 8b
+} {
+ 2b 3b 4c 5c 6c 7b 8b
+}
+
+###############################################################################
+
+test_cleanup