summaryrefslogtreecommitdiff
path: root/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'extractor')
-rw-r--r--extractor/rule_extractor_helper.h1
-rw-r--r--extractor/rule_extractor_helper_test.cc17
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