summaryrefslogtreecommitdiff
path: root/xdelta3/testing/cmp.h
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2008-07-02 03:52:23 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2008-07-02 03:52:23 +0000
commit39986a1759550d3d5083e710862295588837f719 (patch)
treeecc11bc31609eecd8461d3afbd8a2b354ec65c6f /xdelta3/testing/cmp.h
parent9e896b470f5a4550a7fbbdc515db08b0249f5950 (diff)
Add new test for streaming encode/decode. The encoder writes directly
to the decoder. The test passes for sizes < Constants::BLOCK_SIZE so far, needs work.
Diffstat (limited to 'xdelta3/testing/cmp.h')
-rw-r--r--xdelta3/testing/cmp.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/xdelta3/testing/cmp.h b/xdelta3/testing/cmp.h
index 12b499d..fb499ae 100644
--- a/xdelta3/testing/cmp.h
+++ b/xdelta3/testing/cmp.h
@@ -1,6 +1,23 @@
1/* -*- Mode: C++ -*- */ 1/* -*- Mode: C++ -*- */
2namespace regtest { 2namespace regtest {
3 3
4inline size_t CmpDifferentBlockBytes(const Block &a, const Block &b) {
5 size_t total = 0;
6 size_t i = 0;
7 size_t m = min(a.Size(), b.Size());
8
9 for (; i < m; i++) {
10 if (a[i] != b[i]) {
11 total++;
12 }
13 }
14
15 total += a.Size() - i;
16 total += b.Size() - i;
17
18 return total;
19}
20
4inline xoff_t CmpDifferentBytes(const FileSpec &a, const FileSpec &b) { 21inline xoff_t CmpDifferentBytes(const FileSpec &a, const FileSpec &b) {
5 Block block_a, block_b; 22 Block block_a, block_b;
6 xoff_t total = 0; 23 xoff_t total = 0;
@@ -11,17 +28,7 @@ inline xoff_t CmpDifferentBytes(const FileSpec &a, const FileSpec &b) {
11 a_i.Get(&block_a); 28 a_i.Get(&block_a);
12 b_i.Get(&block_b); 29 b_i.Get(&block_b);
13 30
14 size_t i = 0; 31 total += CmpDifferentBlockBytes(block_a, block_b);
15 size_t m = min(block_a.Size(), block_b.Size());
16
17 for (; i < m; i++) {
18 if (block_a[i] != block_b[i]) {
19 total++;
20 }
21 }
22
23 total += block_a.Size() - i;
24 total += block_b.Size() - i;
25 } 32 }
26 33
27 for (; !a_i.Done(); a_i.Next()) { 34 for (; !a_i.Done(); a_i.Next()) {