diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2008-08-16 15:51:00 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2008-08-16 15:51:00 +0000 |
commit | c2649db85aa9ef74412efd7c7e19d917646dce74 (patch) | |
tree | 12a8bc4c5a2042283eaae1ae330b71d1250a5cf7 /xdelta3/testing | |
parent | cfa558736324be5e2068f5459a55f882c2631bc6 (diff) |
Fixes a error in the test. Merge test passes...???
Diffstat (limited to 'xdelta3/testing')
-rw-r--r-- | xdelta3/testing/delta.h | 4 | ||||
-rw-r--r-- | xdelta3/testing/regtest.cc | 52 |
2 files changed, 40 insertions, 16 deletions
diff --git a/xdelta3/testing/delta.h b/xdelta3/testing/delta.h index b74f3bd..103d7cc 100644 --- a/xdelta3/testing/delta.h +++ b/xdelta3/testing/delta.h | |||
@@ -14,6 +14,10 @@ public: | |||
14 | return stream_.whole_target.addslen; | 14 | return stream_.whole_target.addslen; |
15 | } | 15 | } |
16 | 16 | ||
17 | xoff_t Windows() const { | ||
18 | return stream_.whole_target.windows; | ||
19 | } | ||
20 | |||
17 | void Print() const; | 21 | void Print() const; |
18 | 22 | ||
19 | private: | 23 | private: |
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 | |||
630 | void 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 | ||
627 | void FourWayMergeTest(const TestOptions &options, | 646 | void 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 | ||
742 | int main(int argc, char **argv) { | 761 | int 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 | } |