diff options
author | Paul Baltescu <pauldb89@gmail.com> | 2013-03-06 19:43:54 +0000 |
---|---|---|
committer | Paul Baltescu <pauldb89@gmail.com> | 2013-03-06 19:43:54 +0000 |
commit | f4b114cb4efa5db994edb8c98de99661f480e994 (patch) | |
tree | b3f3591994fa763c78ca4022597e23d7452e441e /extractor | |
parent | 3219aaf89f0c08c5ac18da6338a3df87b1e5dd3f (diff) |
Unit test for RuleExtractorHelper.
Diffstat (limited to 'extractor')
-rw-r--r-- | extractor/rule_extractor_helper.h | 1 | ||||
-rw-r--r-- | extractor/rule_extractor_helper_test.cc | 17 |
2 files changed, 17 insertions, 1 deletions
diff --git a/extractor/rule_extractor_helper.h b/extractor/rule_extractor_helper.h index 95274df6..7bf80c4b 100644 --- a/extractor/rule_extractor_helper.h +++ b/extractor/rule_extractor_helper.h @@ -57,7 +57,6 @@ class RuleExtractorHelper { virtual vector<int> GetGapOrder(const vector<pair<int, int> >& gaps) const; - // TODO(pauldb): Add unit tests. virtual unordered_map<int, int> GetSourceIndexes( const vector<int>& matching, const vector<int>& chunklen, int starts_with_x) const; diff --git a/extractor/rule_extractor_helper_test.cc b/extractor/rule_extractor_helper_test.cc index ec0635b1..24a322df 100644 --- a/extractor/rule_extractor_helper_test.cc +++ b/extractor/rule_extractor_helper_test.cc @@ -620,5 +620,22 @@ TEST_F(RuleExtractorHelperTest, TestGetGapIntegrityChecksFailed) { met_constraints)); } +TEST_F(RuleExtractorHelperTest, TestGetSourceIndexes) { + helper = make_shared<RuleExtractorHelper>(source_data_array, + target_data_array, alignment, 10, 5, true, true, true); + + vector<int> matching = {13, 18, 21}; + vector<int> chunklen = {3, 2, 1}; + unordered_map<int, int> expected_indexes = { + {3, 1}, {4, 2}, {5, 3}, {8, 5}, {9, 6}, {11, 8} + }; + EXPECT_EQ(expected_indexes, helper->GetSourceIndexes(matching, chunklen, 1)); + + matching = {12, 17}; + chunklen = {2, 4}; + expected_indexes = {{2, 0}, {3, 1}, {7, 3}, {8, 4}, {9, 5}, {10, 6}}; + EXPECT_EQ(expected_indexes, helper->GetSourceIndexes(matching, chunklen, 0)); +} + } // namespace } // namespace extractor |