summaryrefslogtreecommitdiff
path: root/xdelta3/testing/regtest.cc
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2008-07-06 00:39:55 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2008-07-06 00:39:55 +0000
commite82b0cd004eadfefb9465713acbe6b62a3f99f6f (patch)
tree2fc6c947d08abf65b726c0efd2343afdce37a8d5 /xdelta3/testing/regtest.cc
parentf946a79d77bd04e0d671b3c66e926d0c1ca3a213 (diff)
Fix the modify test.
Diffstat (limited to 'xdelta3/testing/regtest.cc')
-rw-r--r--xdelta3/testing/regtest.cc29
1 files changed, 22 insertions, 7 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc
index 0e541ec..12499ba 100644
--- a/xdelta3/testing/regtest.cc
+++ b/xdelta3/testing/regtest.cc
@@ -255,14 +255,29 @@ void TestModifyMutator() {
255 255
256 spec0.GenerateFixedSize(Constants::BLOCK_SIZE * 3); 256 spec0.GenerateFixedSize(Constants::BLOCK_SIZE * 3);
257 257
258 ChangeList cl1; 258 struct {
259 cl1.push_back(Change(Change::MODIFY, Constants::BLOCK_SIZE, 0)); 259 size_t size;
260 spec0.Print(); 260 size_t addr;
261 spec0.ModifyTo(ChangeListMutator(cl1), &spec1); 261 } test_cases[] = {
262 spec1.Print(); 262 { Constants::BLOCK_SIZE, 0 },
263 CHECK_EQ(Constants::BLOCK_SIZE, CmpDifferentBytes(spec0, spec1)); 263 { Constants::BLOCK_SIZE / 2, 1 },
264 InMemoryEncodeDecode(spec0, spec1); 264 { Constants::BLOCK_SIZE, 1 },
265 { Constants::BLOCK_SIZE * 2, 1 },
266 };
267
268 for (size_t i = 0; i < SIZEOF_ARRAY(test_cases); i++) {
269 ChangeList cl1;
270 cl1.push_back(Change(Change::MODIFY, test_cases[i].size, test_cases[i].addr));
271 spec0.Print();
272 spec0.ModifyTo(ChangeListMutator(cl1), &spec1);
273 spec1.Print();
274
275 size_t diff = CmpDifferentBytes(spec0, spec1);
276 CHECK_LE(diff, test_cases[i].size);
277 CHECK_GE(diff, test_cases[i].size - (2 * test_cases[i].size / 256));
265 278
279 InMemoryEncodeDecode(spec0, spec1);
280 }
266} 281}
267 282
268int main(int argc, char **argv) { 283int main(int argc, char **argv) {