summaryrefslogtreecommitdiff
path: root/xdelta3/testing/regtest.cc
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/regtest.cc
parent1c583b507081301a0c6738eeaf541790b2393714 (diff)
New ChangeListMutator functionality.
Diffstat (limited to 'xdelta3/testing/regtest.cc')
-rw-r--r--xdelta3/testing/regtest.cc26
1 files changed, 21 insertions, 5 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc
index 3b4d4c6..0e541ec 100644
--- a/xdelta3/testing/regtest.cc
+++ b/xdelta3/testing/regtest.cc
@@ -4,8 +4,6 @@
4// Declare constants (needed for reference-values, etc). 4// Declare constants (needed for reference-values, etc).
5const xoff_t Constants::BLOCK_SIZE; 5const xoff_t Constants::BLOCK_SIZE;
6 6
7//////////////////////////////////////////////////////////////////////
8
9// TODO: more options! 7// TODO: more options!
10void InMemoryEncodeDecode(FileSpec &source_file, FileSpec &target_file) { 8void InMemoryEncodeDecode(FileSpec &source_file, FileSpec &target_file) {
11 xd3_stream encode_stream; 9 xd3_stream encode_stream;
@@ -230,11 +228,11 @@ void TestFirstByte() {
230 CHECK_EQ(1, CmpDifferentBytes(spec1, spec0)); 228 CHECK_EQ(1, CmpDifferentBytes(spec1, spec0));
231 229
232 spec0.GenerateFixedSize(1); 230 spec0.GenerateFixedSize(1);
233 spec0.ModifyTo<Modify1stByte>(&spec1); 231 spec0.ModifyTo(Modify1stByte(), &spec1);
234 CHECK_EQ(1, CmpDifferentBytes(spec0, spec1)); 232 CHECK_EQ(1, CmpDifferentBytes(spec0, spec1));
235 233
236 spec0.GenerateFixedSize(Constants::BLOCK_SIZE + 1); 234 spec0.GenerateFixedSize(Constants::BLOCK_SIZE + 1);
237 spec0.ModifyTo<Modify1stByte>(&spec1); 235 spec0.ModifyTo(Modify1stByte(), &spec1);
238 CHECK_EQ(1, CmpDifferentBytes(spec0, spec1)); 236 CHECK_EQ(1, CmpDifferentBytes(spec0, spec1));
239 237
240 SizeIterator<size_t, SmallSizes> si(&rand, 20); 238 SizeIterator<size_t, SmallSizes> si(&rand, 20);
@@ -245,16 +243,34 @@ void TestFirstByte() {
245 continue; 243 continue;
246 } 244 }
247 spec0.GenerateFixedSize(size); 245 spec0.GenerateFixedSize(size);
248 spec0.ModifyTo<Modify1stByte>(&spec1); 246 spec0.ModifyTo(Modify1stByte(), &spec1);
249 InMemoryEncodeDecode(spec0, spec1); 247 InMemoryEncodeDecode(spec0, spec1);
250 } 248 }
251} 249}
252 250
251void TestModifyMutator() {
252 MTRandom rand;
253 FileSpec spec0(&rand);
254 FileSpec spec1(&rand);
255
256 spec0.GenerateFixedSize(Constants::BLOCK_SIZE * 3);
257
258 ChangeList cl1;
259 cl1.push_back(Change(Change::MODIFY, Constants::BLOCK_SIZE, 0));
260 spec0.Print();
261 spec0.ModifyTo(ChangeListMutator(cl1), &spec1);
262 spec1.Print();
263 CHECK_EQ(Constants::BLOCK_SIZE, CmpDifferentBytes(spec0, spec1));
264 InMemoryEncodeDecode(spec0, spec1);
265
266}
267
253int main(int argc, char **argv) { 268int main(int argc, char **argv) {
254#define TEST(x) cerr << #x << "..." << endl; x() 269#define TEST(x) cerr << #x << "..." << endl; x()
255 TEST(TestRandomNumbers); 270 TEST(TestRandomNumbers);
256 TEST(TestRandomFile); 271 TEST(TestRandomFile);
257 TEST(TestFirstByte); 272 TEST(TestFirstByte);
273 TEST(TestModifyMutator);
258 return 0; 274 return 0;
259} 275}
260 276