summaryrefslogtreecommitdiff
path: root/xdelta3/testing/regtest.cc
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2008-08-16 15:51:00 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2008-08-16 15:51:00 +0000
commitc2649db85aa9ef74412efd7c7e19d917646dce74 (patch)
tree12a8bc4c5a2042283eaae1ae330b71d1250a5cf7 /xdelta3/testing/regtest.cc
parentcfa558736324be5e2068f5459a55f882c2631bc6 (diff)
Fixes a error in the test. Merge test passes...???
Diffstat (limited to 'xdelta3/testing/regtest.cc')
-rw-r--r--xdelta3/testing/regtest.cc52
1 files changed, 36 insertions, 16 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc
index f0b30ee..1a522e2 100644
--- a/xdelta3/testing/regtest.cc
+++ b/xdelta3/testing/regtest.cc
@@ -94,7 +94,8 @@ void InMemoryEncodeDecode(const TestOptions &options,
94 while (!done) { 94 while (!done) {
95 target_iterator.Get(&target_block); 95 target_iterator.Get(&target_block);
96 96
97 if (target_block.Size() < target_iterator.BlockSize()) { 97 if (target_file.Blocks() == 0 ||
98 target_iterator.Blkno() == (target_file.Blocks() - 1)) {
98 xd3_set_flags(&encode_stream, XD3_FLUSH | encode_stream.flags); 99 xd3_set_flags(&encode_stream, XD3_FLUSH | encode_stream.flags);
99 } 100 }
100 101
@@ -614,14 +615,32 @@ void TestEmptyInMemory() {
614 FileSpec spec0(&rand); 615 FileSpec spec0(&rand);
615 FileSpec spec1(&rand); 616 FileSpec spec1(&rand);
616 TestOptions options; 617 TestOptions options;
617 Block delta; 618 Block block;
618 619
619 spec0.GenerateFixedSize(0); 620 spec0.GenerateFixedSize(0);
620 spec1.GenerateFixedSize(0); 621 spec1.GenerateFixedSize(0);
621 622
622 InMemoryEncodeDecode(options, spec0, spec1, &delta); 623 InMemoryEncodeDecode(options, spec0, spec1, &block);
623 624
624 CHECK_LT(0, delta.Size()); 625 Delta delta(block);
626 CHECK_LT(0, block.Size());
627 CHECK_EQ(1, delta.Windows());
628}
629
630void TestBlockInMemory() {
631 MTRandom rand;
632 FileSpec spec0(&rand);
633 FileSpec spec1(&rand);
634 TestOptions options;
635 Block block;
636
637 spec0.GenerateFixedSize(Constants::BLOCK_SIZE);
638 spec1.GenerateFixedSize(Constants::BLOCK_SIZE);
639
640 InMemoryEncodeDecode(options, spec0, spec1, &block);
641
642 Delta delta(block);
643 CHECK_EQ(1, delta.Windows());
625} 644}
626 645
627void FourWayMergeTest(const TestOptions &options, 646void FourWayMergeTest(const TestOptions &options,
@@ -657,9 +676,9 @@ void FourWayMergeTest(const TestOptions &options,
657 mcmd.push_back(out.Name()); 676 mcmd.push_back(out.Name());
658 mcmd.push_back(NULL); 677 mcmd.push_back(NULL);
659 678
679 DP(RINT "Running one merge: %s\n", CommandToString(mcmd).c_str());
660 CHECK_EQ(0, xd3_main_cmdline(mcmd.size() - 1, 680 CHECK_EQ(0, xd3_main_cmdline(mcmd.size() - 1,
661 const_cast<char**>(&mcmd[0]))); 681 const_cast<char**>(&mcmd[0])));
662 DP(RINT "Ran one merge! %s\n", CommandToString(mcmd).c_str());
663 682
664 ExtFile recon; 683 ExtFile recon;
665 vector<const char*> tcmd; 684 vector<const char*> tcmd;
@@ -741,17 +760,18 @@ void TestMergeCommand() {
741 760
742int main(int argc, char **argv) { 761int main(int argc, char **argv) {
743#define TEST(x) cerr << #x << "..." << endl; x() 762#define TEST(x) cerr << #x << "..." << endl; x()
744// TEST(TestRandomNumbers); 763 TEST(TestRandomNumbers);
745// TEST(TestRandomFile); 764 TEST(TestRandomFile);
746// TEST(TestFirstByte); 765 TEST(TestFirstByte);
747// TEST(TestModifyMutator); 766 TEST(TestEmptyInMemory);
748// TEST(TestAddMutator); 767 TEST(TestBlockInMemory);
749// TEST(TestDeleteMutator); 768 TEST(TestModifyMutator);
750// TEST(TestCopyMutator); 769 TEST(TestAddMutator);
751// TEST(TestMoveMutator); 770 TEST(TestDeleteMutator);
752// TEST(TestOverwriteMutator); 771 TEST(TestCopyMutator);
753// TEST(TestNonBlockingProgress); 772 TEST(TestMoveMutator);
754// TEST(TestEmptyInMemory); 773 TEST(TestOverwriteMutator);
774 TEST(TestNonBlockingProgress);
755 TEST(TestMergeCommand); 775 TEST(TestMergeCommand);
756 return 0; 776 return 0;
757} 777}