diff options
Diffstat (limited to 'xdelta3/testing/regtest.cc')
-rw-r--r-- | xdelta3/testing/regtest.cc | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc index f64111e..3b4d4c6 100644 --- a/xdelta3/testing/regtest.cc +++ b/xdelta3/testing/regtest.cc | |||
@@ -68,8 +68,8 @@ void InMemoryEncodeDecode(FileSpec &source_file, FileSpec &target_file) { | |||
68 | ret = xd3_decode_input(&decode_stream); | 68 | ret = xd3_decode_input(&decode_stream); |
69 | } | 69 | } |
70 | 70 | ||
71 | DP(RINT "%s = %s\n", encoding ? "encoding" : "decoding", | 71 | //DP(RINT "%s = %s\n", encoding ? "encoding" : "decoding", |
72 | xd3_strerror(ret)); | 72 | // xd3_strerror(ret)); |
73 | 73 | ||
74 | switch (ret) { | 74 | switch (ret) { |
75 | case XD3_OUTPUT: | 75 | case XD3_OUTPUT: |
@@ -117,7 +117,7 @@ void InMemoryEncodeDecode(FileSpec &source_file, FileSpec &target_file) { | |||
117 | encoding = false; | 117 | encoding = false; |
118 | } else { | 118 | } else { |
119 | CHECK_EQ(0, CmpDifferentBlockBytes(decoded_block, target_block)); | 119 | CHECK_EQ(0, CmpDifferentBlockBytes(decoded_block, target_block)); |
120 | DP(RINT "verified block %"Q"u\n", target_iterator.Blkno()); | 120 | //DP(RINT "verified block %"Q"u\n", target_iterator.Blkno()); |
121 | decoded_block.Reset(); | 121 | decoded_block.Reset(); |
122 | encoding = true; | 122 | encoding = true; |
123 | } | 123 | } |
@@ -236,23 +236,18 @@ void TestFirstByte() { | |||
236 | spec0.GenerateFixedSize(Constants::BLOCK_SIZE + 1); | 236 | spec0.GenerateFixedSize(Constants::BLOCK_SIZE + 1); |
237 | spec0.ModifyTo<Modify1stByte>(&spec1); | 237 | spec0.ModifyTo<Modify1stByte>(&spec1); |
238 | CHECK_EQ(1, CmpDifferentBytes(spec0, spec1)); | 238 | CHECK_EQ(1, CmpDifferentBytes(spec0, spec1)); |
239 | } | ||
240 | |||
241 | void TestBasicEncodeDecode() { | ||
242 | MTRandom rand; | ||
243 | FileSpec spec0(&rand); | ||
244 | FileSpec spec1(&rand); | ||
245 | spec0.GenerateFixedSize(1024); | ||
246 | spec0.ModifyTo<Modify1stByte>(&spec1); | ||
247 | InMemoryEncodeDecode(spec0, spec1); | ||
248 | 239 | ||
249 | spec0.GenerateFixedSize(Constants::BLOCK_SIZE); | 240 | SizeIterator<size_t, SmallSizes> si(&rand, 20); |
250 | spec0.ModifyTo<Modify1stByte>(&spec1); | ||
251 | InMemoryEncodeDecode(spec0, spec1); | ||
252 | 241 | ||
253 | spec0.GenerateFixedSize(Constants::BLOCK_SIZE * 2); | 242 | for (; !si.Done(); si.Next()) { |
254 | spec0.ModifyTo<Modify1stByte>(&spec1); | 243 | size_t size = si.Get(); |
255 | InMemoryEncodeDecode(spec0, spec1); | 244 | if (size == 0) { |
245 | continue; | ||
246 | } | ||
247 | spec0.GenerateFixedSize(size); | ||
248 | spec0.ModifyTo<Modify1stByte>(&spec1); | ||
249 | InMemoryEncodeDecode(spec0, spec1); | ||
250 | } | ||
256 | } | 251 | } |
257 | 252 | ||
258 | int main(int argc, char **argv) { | 253 | int main(int argc, char **argv) { |
@@ -260,7 +255,6 @@ int main(int argc, char **argv) { | |||
260 | TEST(TestRandomNumbers); | 255 | TEST(TestRandomNumbers); |
261 | TEST(TestRandomFile); | 256 | TEST(TestRandomFile); |
262 | TEST(TestFirstByte); | 257 | TEST(TestFirstByte); |
263 | TEST(TestBasicEncodeDecode); | ||
264 | return 0; | 258 | return 0; |
265 | } | 259 | } |
266 | 260 | ||