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 | 0c30e5f14d415ec9a399ca4af82cee1885e60f4f (patch) | |
tree | bdcb51aa1f2aca6586dee797f439eac97770214c | |
parent | fa9a4f72cb1fc8de823a11db4e510fccbe1c3532 (diff) |
Unit test for RuleExtractorHelper.
-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 |