Fossil SCM
| dbda8d6… | drh | 1 | # |
| dbda8d6… | drh | 2 | # Copyright (c) 2006 D. Richard Hipp |
| dbda8d6… | drh | 3 | # |
| dbda8d6… | drh | 4 | # This program is free software; you can redistribute it and/or |
| 9d723c5… | drh | 5 | # modify it under the terms of the Simplified BSD License (also |
| 9d723c5… | drh | 6 | # known as the "2-Clause License" or "FreeBSD License".) |
| dbda8d6… | drh | 7 | # |
| dbda8d6… | drh | 8 | # This program is distributed in the hope that it will be useful, |
| 9d723c5… | drh | 9 | # but without any warranty; without even the implied warranty of |
| 9d723c5… | drh | 10 | # merchantability or fitness for a particular purpose. |
| dbda8d6… | drh | 11 | # |
| dbda8d6… | drh | 12 | # Author contact information: |
| dbda8d6… | drh | 13 | # [email protected] |
| dbda8d6… | drh | 14 | # http://www.hwaci.com/drh/ |
| dbda8d6… | drh | 15 | # |
| dbda8d6… | drh | 16 | ############################################################################ |
| dbda8d6… | drh | 17 | # |
| dbda8d6… | drh | 18 | # Tests of the delta mechanism. |
| dbda8d6… | drh | 19 | # |
| dbda8d6… | drh | 20 | |
| fa59221… | mistachkin | 21 | test_setup "" |
| fa59221… | mistachkin | 22 | |
| dbda8d6… | drh | 23 | # Use test script files as the basis for this test. |
| dbda8d6… | drh | 24 | # |
| dbda8d6… | drh | 25 | # For each test, copy the file intact to "./t1". Make |
| dbda8d6… | drh | 26 | # some random changes in "./t2". Then call test-delta on the |
| dbda8d6… | drh | 27 | # two files to make sure that deltas between these two files |
| dbda8d6… | drh | 28 | # work properly. |
| dbda8d6… | drh | 29 | # |
| e5bcfd1… | preben | 30 | set filelist [lsort [glob $testdir/*]] |
| dbda8d6… | drh | 31 | foreach f $filelist { |
| 6502627… | drh | 32 | if {[file isdir $f]} continue |
| dbda8d6… | drh | 33 | set base [file root [file tail $f]] |
| dbda8d6… | drh | 34 | set f1 [read_file $f] |
| dbda8d6… | drh | 35 | write_file t1 $f1 |
| dbda8d6… | drh | 36 | for {set i 0} {$i<100} {incr i} { |
| dbda8d6… | drh | 37 | write_file t2 [random_changes $f1 1 1 0 0.1] |
| dbda8d6… | drh | 38 | fossil test-delta t1 t2 |
| 4ede0df… | andybradford | 39 | test delta-$base-$i-1 {[normalize_result]=="ok"} |
| dbda8d6… | drh | 40 | write_file t2 [random_changes $f1 1 1 0 0.2] |
| dbda8d6… | drh | 41 | fossil test-delta t1 t2 |
| 4ede0df… | andybradford | 42 | test delta-$base-$i-2 {[normalize_result]=="ok"} |
| dbda8d6… | drh | 43 | write_file t2 [random_changes $f1 1 1 0 0.4] |
| dbda8d6… | drh | 44 | fossil test-delta t1 t2 |
| 4ede0df… | andybradford | 45 | test delta-$base-$i-3 {[normalize_result]=="ok"} |
| dbda8d6… | drh | 46 | } |
| dbda8d6… | drh | 47 | } |
| fa59221… | mistachkin | 48 | |
| 4ede0df… | andybradford | 49 | set empties { "" "" "" a a "" } |
| 4ede0df… | andybradford | 50 | set i 0 |
| 4ede0df… | andybradford | 51 | foreach {f1 f2} $empties { |
| 4ede0df… | andybradford | 52 | incr i |
| 4ede0df… | andybradford | 53 | write_file t1 $f1 |
| 4ede0df… | andybradford | 54 | write_file t2 $f2 |
| 4ede0df… | andybradford | 55 | fossil test-delta t1 t2 |
| 4ede0df… | andybradford | 56 | test delta-empty-$i {[normalize_result]=="ok"} |
| 4ede0df… | andybradford | 57 | } |
| fa59221… | mistachkin | 58 | ############################################################################### |
| fa59221… | mistachkin | 59 | |
| fa59221… | mistachkin | 60 | test_cleanup |