summaryrefslogtreecommitdiff
path: root/xdelta3/testing/file.h
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2008-07-05 17:13:49 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2008-07-05 17:13:49 +0000
commitf946a79d77bd04e0d671b3c66e926d0c1ca3a213 (patch)
treeb3d5ad97e97a3ae08b4e9bbee0fd331df344e52e /xdelta3/testing/file.h
parent1c583b507081301a0c6738eeaf541790b2393714 (diff)
New ChangeListMutator functionality.
Diffstat (limited to 'xdelta3/testing/file.h')
-rw-r--r--xdelta3/testing/file.h32
1 files changed, 13 insertions, 19 deletions
diff --git a/xdelta3/testing/file.h b/xdelta3/testing/file.h
index c281de9..dae97de 100644
--- a/xdelta3/testing/file.h
+++ b/xdelta3/testing/file.h
@@ -1,21 +1,6 @@
1/* -*- Mode: C++ -*- */ 1/* -*- Mode: C++ -*- */
2namespace regtest { 2namespace regtest {
3 3
4class Segment {
5 public:
6 Segment(uint32_t seed, size_t length)
7 : seed(seed),
8 length(length),
9 seed_offset(0) { }
10
11 uint32_t seed; // Seed used for generating byte sequence
12 size_t length; // Length of this segment
13 size_t seed_offset; // Seed positions the sequence this many bytes
14 // before its beginning.
15};
16
17typedef map<xoff_t, Segment> SegmentMap;
18
19class Block; 4class Block;
20class BlockIterator; 5class BlockIterator;
21 6
@@ -64,16 +49,25 @@ class FileSpec {
64 } 49 }
65 50
66 // Create a mutation according to "what". 51 // Create a mutation according to "what".
67 template <typename T> 52 void ModifyTo(const Mutator &mutator,
68 void ModifyTo(FileSpec *modify) const { 53 FileSpec *modify) const {
69 modify->table_ = table_; 54 modify->Reset();
70 T::Mutate(&modify->table_, rand_); 55 mutator.Mutate(&modify->table_, &table_, rand_);
71 } 56 }
72 57
73 void Reset() { 58 void Reset() {
74 table_.clear(); 59 table_.clear();
75 } 60 }
76 61
62 void Print() const {
63 for (SegmentMap::const_iterator iter(table_.begin());
64 iter != table_.end();
65 ++iter) {
66 cerr << "Segment at " << iter->first << " (" << iter->second.seed
67 << "," << iter->second.length << "," << iter->second.seed_offset << ")" << endl;
68 }
69 }
70
77 typedef BlockIterator iterator; 71 typedef BlockIterator iterator;
78 72
79 private: 73 private: