diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2008-07-05 17:13:49 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2008-07-05 17:13:49 +0000 |
commit | f946a79d77bd04e0d671b3c66e926d0c1ca3a213 (patch) | |
tree | b3d5ad97e97a3ae08b4e9bbee0fd331df344e52e /xdelta3/testing/file.h | |
parent | 1c583b507081301a0c6738eeaf541790b2393714 (diff) |
New ChangeListMutator functionality.
Diffstat (limited to 'xdelta3/testing/file.h')
-rw-r--r-- | xdelta3/testing/file.h | 32 |
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++ -*- */ |
2 | namespace regtest { | 2 | namespace regtest { |
3 | 3 | ||
4 | class 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 | |||
17 | typedef map<xoff_t, Segment> SegmentMap; | ||
18 | |||
19 | class Block; | 4 | class Block; |
20 | class BlockIterator; | 5 | class 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: |