summaryrefslogtreecommitdiff
path: root/xdelta3/testing/cmp.h
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2009-02-10 03:49:57 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2009-02-10 03:49:57 +0000
commit1b96ad8ae09b53cdcd7dd03d4bac09ba8c61e5a6 (patch)
tree33aae63f229f1def8cd036dd4ec4fe3ec36a3055 /xdelta3/testing/cmp.h
parent0b19bfedbd1f17004bdc6766a7ba5e61dddc20b0 (diff)
Templatize the test, expose issue 79.
Diffstat (limited to 'xdelta3/testing/cmp.h')
-rw-r--r--xdelta3/testing/cmp.h30
1 files changed, 3 insertions, 27 deletions
diff --git a/xdelta3/testing/cmp.h b/xdelta3/testing/cmp.h
index d96c386..e5e37cf 100644
--- a/xdelta3/testing/cmp.h
+++ b/xdelta3/testing/cmp.h
@@ -1,7 +1,5 @@
1/* -*- Mode: C++ -*- */ 1/* -*- Mode: C++ -*- */
2namespace regtest { 2static size_t CmpDifferentBlockBytes(const Block &a, const Block &b) {
3
4inline size_t CmpDifferentBlockBytes(const Block &a, const Block &b) {
5 size_t total = 0; 3 size_t total = 0;
6 size_t i = 0; 4 size_t i = 0;
7 size_t m = min(a.Size(), b.Size()); 5 size_t m = min(a.Size(), b.Size());
@@ -18,10 +16,10 @@ inline size_t CmpDifferentBlockBytes(const Block &a, const Block &b) {
18 return total; 16 return total;
19} 17}
20 18
21inline xoff_t CmpDifferentBytes(const FileSpec &a, const FileSpec &b) { 19static xoff_t CmpDifferentBytes(const FileSpec &a, const FileSpec &b) {
22 Block block_a, block_b; 20 Block block_a, block_b;
23 xoff_t total = 0; 21 xoff_t total = 0;
24 FileSpec::iterator a_i(a), b_i(b); 22 typename FileSpec::iterator a_i(a), b_i(b);
25 23
26 for (; !a_i.Done() && !b_i.Done(); a_i.Next(), b_i.Next()) { 24 for (; !a_i.Done() && !b_i.Done(); a_i.Next(), b_i.Next()) {
27 25
@@ -40,25 +38,3 @@ inline xoff_t CmpDifferentBytes(const FileSpec &a, const FileSpec &b) {
40 38
41 return total; 39 return total;
42} 40}
43
44inline bool ExtFile::EqualsSpec(const FileSpec &spec) const {
45 main_file t;
46 main_file_init(&t);
47 CHECK_EQ(0, main_file_open(&t, Name(), XO_READ));
48
49 Block tblock;
50 Block sblock;
51 for (BlockIterator iter(spec); !iter.Done(); iter.Next()) {
52 iter.Get(&sblock);
53 tblock.SetSize(sblock.Size());
54 usize_t tread;
55 CHECK_EQ(0, main_file_read(&t, tblock.Data(), tblock.Size(), &tread, "read failed"));
56 CHECK_EQ(0, CmpDifferentBlockBytes(tblock, sblock));
57 }
58
59 CHECK_EQ(0, main_file_close(&t));
60 main_file_cleanup(&t);
61 return true;
62}
63
64} // namespace regtest