92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: # Copyright (c) 2009 D. Richard Hipp 92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: # This program is free software; you can redistribute it and/or 92638367d8 2009-03-22 drh: # modify it under the terms of the GNU General Public 92638367d8 2009-03-22 drh: # License version 2 as published by the Free Software Foundation. 92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: # This program is distributed in the hope that it will be useful, 92638367d8 2009-03-22 drh: # but WITHOUT ANY WARRANTY; without even the implied warranty of 92638367d8 2009-03-22 drh: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 92638367d8 2009-03-22 drh: # General Public License for more details. 92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: # You should have received a copy of the GNU General Public 92638367d8 2009-03-22 drh: # License along with this library; if not, write to the 92638367d8 2009-03-22 drh: # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 92638367d8 2009-03-22 drh: # Boston, MA 02111-1307, USA. 92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: # Author contact information: 92638367d8 2009-03-22 drh: # drh@hwaci.com 92638367d8 2009-03-22 drh: # http://www.hwaci.com/drh/ 92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: ############################################################################ 92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: # Tests of the 3-way merge 92638367d8 2009-03-22 drh: # 92638367d8 2009-03-22 drh: 92638367d8 2009-03-22 drh: proc merge-test {testid basis v1 v2 result1 result2} { 92638367d8 2009-03-22 drh: write_file t1 [join [string trim $basis] \n]\n 92638367d8 2009-03-22 drh: write_file t2 [join [string trim $v1] \n]\n 92638367d8 2009-03-22 drh: write_file t3 [join [string trim $v2] \n]\n 92638367d8 2009-03-22 drh: fossil test-3-way-merge t1 t2 t3 t4 92638367d8 2009-03-22 drh: fossil test-3-way-merge t1 t3 t2 t5 92638367d8 2009-03-22 drh: set x [read_file t4] 92638367d8 2009-03-22 drh: regsub -all {>>>>>>> BEGIN MERGE CONFLICT} $x {>} x 92638367d8 2009-03-22 drh: regsub -all {============================} $x {=} x 92638367d8 2009-03-22 drh: regsub -all {<<<<<<< END MERGE CONFLICT} $x {<} x 92638367d8 2009-03-22 drh: set x [split [string trim $x] \n] 92638367d8 2009-03-22 drh: set y [read_file t5] 92638367d8 2009-03-22 drh: regsub -all {>>>>>>> BEGIN MERGE CONFLICT} $y {>} y 92638367d8 2009-03-22 drh: regsub -all {============================} $y {=} y 92638367d8 2009-03-22 drh: regsub -all {<<<<<<< END MERGE CONFLICT} $y {<} y 92638367d8 2009-03-22 drh: set y [split [string trim $y] \n] 92638367d8 2009-03-22 drh: set result1 [string trim $result1] 92638367d8 2009-03-22 drh: if {$x!=$result1} { 92638367d8 2009-03-22 drh: puts " Expected \[$result1\]" 92638367d8 2009-03-22 drh: puts " Got \[$x\]" 92638367d8 2009-03-22 drh: test merge3-$testid 0 92638367d8 2009-03-22 drh: } else { 92638367d8 2009-03-22 drh: set result2 [string trim $result2] 92638367d8 2009-03-22 drh: if {$y!=$result2} { 92638367d8 2009-03-22 drh: puts " Expected \[$result2\]" 92638367d8 2009-03-22 drh: puts " Got \[$y\]" 92638367d8 2009-03-22 drh: test merge3-$testid 0 92638367d8 2009-03-22 drh: } else { 92638367d8 2009-03-22 drh: test merge3-$testid 1 92638367d8 2009-03-22 drh: } 92638367d8 2009-03-22 drh: } 92638367d8 2009-03-22 drh: } 92638367d8 2009-03-22 drh: 92638367d8 2009-03-22 drh: merge-test 1000 { 92638367d8 2009-03-22 drh: 1 2 3 4 5 6 7 8 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 2b 3b 4b 5 6b 7b 8b 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 2 3 4c 5c 6c 7 8 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 > 2b 3b 4b 5 6b 7b 8b = 2 3 4c 5c 6c 7 8 < 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 > 2 3 4c 5c 6c 7 8 = 2b 3b 4b 5 6b 7b 8b < 9 92638367d8 2009-03-22 drh: } 92638367d8 2009-03-22 drh: merge-test 1001 { 92638367d8 2009-03-22 drh: 1 2 3 4 5 6 7 8 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 2b 3b 4 5 6 7b 8b 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 2 3 4c 5c 6c 7 8 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 2b 3b 4c 5c 6c 7b 8b 9 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 1 2b 3b 4c 5c 6c 7b 8b 9 92638367d8 2009-03-22 drh: } 92638367d8 2009-03-22 drh: merge-test 1002 { 92638367d8 2009-03-22 drh: 2 3 4 5 6 7 8 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 2b 3b 4b 5 6b 7b 8b 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 2 3 4c 5c 6c 7 8 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: > 2b 3b 4b 5 6b 7b 8b = 2 3 4c 5c 6c 7 8 < 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: > 2 3 4c 5c 6c 7 8 = 2b 3b 4b 5 6b 7b 8b < 92638367d8 2009-03-22 drh: } 92638367d8 2009-03-22 drh: merge-test 1003 { 92638367d8 2009-03-22 drh: 2 3 4 5 6 7 8 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 2b 3b 4 5 6 7b 8b 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 2 3 4c 5c 6c 7 8 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 2b 3b 4c 5c 6c 7b 8b 92638367d8 2009-03-22 drh: } { 92638367d8 2009-03-22 drh: 2b 3b 4c 5c 6c 7b 8b 92638367d8 2009-03-22 drh: }