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