From f4b114cb4efa5db994edb8c98de99661f480e994 Mon Sep 17 00:00:00 2001 From: Paul Baltescu Date: Wed, 6 Mar 2013 19:43:54 +0000 Subject: Unit test for RuleExtractorHelper. --- extractor/rule_extractor_helper.h | 1 - extractor/rule_extractor_helper_test.cc | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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 GetGapOrder(const vector >& gaps) const; - // TODO(pauldb): Add unit tests. virtual unordered_map GetSourceIndexes( const vector& matching, const vector& 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(source_data_array, + target_data_array, alignment, 10, 5, true, true, true); + + vector matching = {13, 18, 21}; + vector chunklen = {3, 2, 1}; + unordered_map 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 -- cgit v1.2.3