diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2008-07-06 15:19:28 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2008-07-06 15:19:28 +0000 |
commit | 7dd0248a21ecc9bd0b333d3c251b52faee532549 (patch) | |
tree | 579cc869b076897970e99596a242471b9cbd1d1e /xdelta3/testing/regtest.cc | |
parent | e82b0cd004eadfefb9465713acbe6b62a3f99f6f (diff) |
Add mutator test working.
Diffstat (limited to 'xdelta3/testing/regtest.cc')
-rw-r--r-- | xdelta3/testing/regtest.cc | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc index 12499ba..487a407 100644 --- a/xdelta3/testing/regtest.cc +++ b/xdelta3/testing/regtest.cc | |||
@@ -268,9 +268,7 @@ void TestModifyMutator() { | |||
268 | for (size_t i = 0; i < SIZEOF_ARRAY(test_cases); i++) { | 268 | for (size_t i = 0; i < SIZEOF_ARRAY(test_cases); i++) { |
269 | ChangeList cl1; | 269 | ChangeList cl1; |
270 | cl1.push_back(Change(Change::MODIFY, test_cases[i].size, test_cases[i].addr)); | 270 | cl1.push_back(Change(Change::MODIFY, test_cases[i].size, test_cases[i].addr)); |
271 | spec0.Print(); | ||
272 | spec0.ModifyTo(ChangeListMutator(cl1), &spec1); | 271 | spec0.ModifyTo(ChangeListMutator(cl1), &spec1); |
273 | spec1.Print(); | ||
274 | 272 | ||
275 | size_t diff = CmpDifferentBytes(spec0, spec1); | 273 | size_t diff = CmpDifferentBytes(spec0, spec1); |
276 | CHECK_LE(diff, test_cases[i].size); | 274 | CHECK_LE(diff, test_cases[i].size); |
@@ -280,12 +278,43 @@ void TestModifyMutator() { | |||
280 | } | 278 | } |
281 | } | 279 | } |
282 | 280 | ||
281 | void TestAddMutator() { | ||
282 | MTRandom rand; | ||
283 | FileSpec spec0(&rand); | ||
284 | FileSpec spec1(&rand); | ||
285 | |||
286 | spec0.GenerateFixedSize(Constants::BLOCK_SIZE * 2); | ||
287 | |||
288 | struct { | ||
289 | size_t size; | ||
290 | size_t addr; | ||
291 | } test_cases[] = { | ||
292 | { 1, 0 }, | ||
293 | { 1, 1 }, | ||
294 | { 1, Constants::BLOCK_SIZE - 1 }, | ||
295 | { 1, Constants::BLOCK_SIZE }, | ||
296 | { 1, Constants::BLOCK_SIZE + 1}, | ||
297 | { 1, 2 * Constants::BLOCK_SIZE }, | ||
298 | }; | ||
299 | |||
300 | for (size_t i = 0; i < SIZEOF_ARRAY(test_cases); i++) { | ||
301 | ChangeList cl1; | ||
302 | cl1.push_back(Change(Change::ADD, test_cases[i].size, test_cases[i].addr)); | ||
303 | spec0.Print(); | ||
304 | spec0.ModifyTo(ChangeListMutator(cl1), &spec1); | ||
305 | spec1.Print(); | ||
306 | |||
307 | InMemoryEncodeDecode(spec0, spec1); | ||
308 | } | ||
309 | } | ||
310 | |||
283 | int main(int argc, char **argv) { | 311 | int main(int argc, char **argv) { |
284 | #define TEST(x) cerr << #x << "..." << endl; x() | 312 | #define TEST(x) cerr << #x << "..." << endl; x() |
285 | TEST(TestRandomNumbers); | 313 | TEST(TestRandomNumbers); |
286 | TEST(TestRandomFile); | 314 | TEST(TestRandomFile); |
287 | TEST(TestFirstByte); | 315 | TEST(TestFirstByte); |
288 | TEST(TestModifyMutator); | 316 | TEST(TestModifyMutator); |
317 | TEST(TestAddMutator); | ||
289 | return 0; | 318 | return 0; |
290 | } | 319 | } |
291 | 320 | ||