From 941d650dd29af9aad526aacd3e75dc96cc3ccef8 Mon Sep 17 00:00:00 2001 From: Lydia Buntrock Date: Wed, 8 Apr 2020 14:43:51 +0200 Subject: [PATCH] [TEST] add tests for issue #1473 Signed-off-by: Lydia Buntrock --- CHANGELOG.md | 2 - .../search/fm_index/bi_fm_index_aa27_test.cpp | 2 - .../search/fm_index/bi_fm_index_char_test.cpp | 2 - .../search/fm_index/bi_fm_index_dna4_test.cpp | 2 - .../search/fm_index/fm_index_dna4_test.cpp | 3 -- ..._index_cursor_collection_test_template.hpp | 35 +++++++++++++++- ..._index_cursor_collection_test_template.hpp | 40 +++++-------------- 7 files changed, 45 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0068229a1af..5f2105afbfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,8 +56,6 @@ Note that 3.1.0 will be the first API stable release and interfaces in this rele * Added `seqan3::interleaved_bloom_filter`, a data structure that efficiently answers set-membership queries for multiple bins ([\#920](https://github.com/seqan/seqan3/pull/920)). -* The `extend_right()` function can now also handle `char const *`. - ([\#1588](https://github.com/seqan/seqan3/pull/1588)). ## API changes diff --git a/test/unit/search/fm_index/bi_fm_index_aa27_test.cpp b/test/unit/search/fm_index/bi_fm_index_aa27_test.cpp index fb2989795cc..32b0c0a2b9a 100644 --- a/test/unit/search/fm_index/bi_fm_index_aa27_test.cpp +++ b/test/unit/search/fm_index/bi_fm_index_aa27_test.cpp @@ -10,8 +10,6 @@ #include "fm_index_collection_test_template.hpp" #include "fm_index_test_template.hpp" -#include - using t1 = std::pair, seqan3::aa27_vector>; INSTANTIATE_TYPED_TEST_SUITE_P(aa27, fm_index_test, t1, ); diff --git a/test/unit/search/fm_index/bi_fm_index_char_test.cpp b/test/unit/search/fm_index/bi_fm_index_char_test.cpp index 6e9bb7337f3..5ea27296ad2 100644 --- a/test/unit/search/fm_index/bi_fm_index_char_test.cpp +++ b/test/unit/search/fm_index/bi_fm_index_char_test.cpp @@ -8,8 +8,6 @@ #include "fm_index_collection_test_template.hpp" #include "fm_index_test_template.hpp" -#include - using t1 = std::pair, std::vector>; INSTANTIATE_TYPED_TEST_SUITE_P(char, fm_index_test, t1, ); diff --git a/test/unit/search/fm_index/bi_fm_index_dna4_test.cpp b/test/unit/search/fm_index/bi_fm_index_dna4_test.cpp index 64369f3d0ba..96e78328f20 100644 --- a/test/unit/search/fm_index/bi_fm_index_dna4_test.cpp +++ b/test/unit/search/fm_index/bi_fm_index_dna4_test.cpp @@ -10,8 +10,6 @@ #include "fm_index_collection_test_template.hpp" #include "fm_index_test_template.hpp" -#include - using t1 = std::pair, seqan3::dna4_vector>; INSTANTIATE_TYPED_TEST_SUITE_P(dna4, fm_index_test, t1, ); diff --git a/test/unit/search/fm_index/fm_index_dna4_test.cpp b/test/unit/search/fm_index/fm_index_dna4_test.cpp index c8f18ddd6f5..09b4114c115 100644 --- a/test/unit/search/fm_index/fm_index_dna4_test.cpp +++ b/test/unit/search/fm_index/fm_index_dna4_test.cpp @@ -11,9 +11,6 @@ #include "fm_index_collection_test_template.hpp" #include "fm_index_test_template.hpp" -#include -#include - using t1 = std::pair, seqan3::dna4_vector>; INSTANTIATE_TYPED_TEST_SUITE_P(dna4, fm_index_test, t1, ); using t2 = std::pair, std::vector>; diff --git a/test/unit/search/fm_index_cursor/bi_fm_index_cursor_collection_test_template.hpp b/test/unit/search/fm_index_cursor/bi_fm_index_cursor_collection_test_template.hpp index 1a4ee1054b3..1bfc5c571ca 100644 --- a/test/unit/search/fm_index_cursor/bi_fm_index_cursor_collection_test_template.hpp +++ b/test/unit/search/fm_index_cursor/bi_fm_index_cursor_collection_test_template.hpp @@ -222,5 +222,38 @@ TYPED_TEST_P(bi_fm_index_cursor_collection_test, to_rev_cursor) } } +TYPED_TEST_P(bi_fm_index_cursor_collection_test, locate_char_string) +{ + using alphabet_type = typename TestFixture::alphabet_type; + + // test case for https://github.com/seqan/seqan3/issues/1473 + if constexpr (std::is_same::value) + { + typename TypeParam::index_type fm{this->text_col1}; // {"AACGATCGGA", "AACGATCGGA"} + char const * cg = "CG"; + + // extend_right() + { + TypeParam it1 = TypeParam(fm); + TypeParam it2 = TypeParam(fm); + + it1.extend_right(cg); + it2.extend_right(seqan3::views::slice(this->text1, 1, 3)); // "CG" + + EXPECT_TRUE(std::ranges::equal(it1.locate(), it2.locate())); + } + // extend_left() + { + auto it1 = TypeParam(fm); + auto it2 = TypeParam(fm); + + it1.extend_left(cg); + it2.extend_right(seqan3::views::slice(this->text1, 1, 3)); // "CG" + + EXPECT_TRUE(std::ranges::equal(it1.locate(), it2.locate())); + } + } +} + REGISTER_TYPED_TEST_SUITE_P(bi_fm_index_cursor_collection_test, cursor, extend, extend_char, extend_range, - extend_and_cycle, extend_range_and_cycle, to_fwd_cursor, to_rev_cursor); + extend_and_cycle, extend_range_and_cycle, to_fwd_cursor, to_rev_cursor, locate_char_string); diff --git a/test/unit/search/fm_index_cursor/fm_index_cursor_collection_test_template.hpp b/test/unit/search/fm_index_cursor/fm_index_cursor_collection_test_template.hpp index db69f743ad7..e82c1c28ed8 100644 --- a/test/unit/search/fm_index_cursor/fm_index_cursor_collection_test_template.hpp +++ b/test/unit/search/fm_index_cursor/fm_index_cursor_collection_test_template.hpp @@ -323,40 +323,22 @@ TYPED_TEST_P(fm_index_cursor_collection_test, lazy_locate) TYPED_TEST_P(fm_index_cursor_collection_test, locate_char_string) { - // test case for https://github.com/seqan/seqan3/issues/1473 - std::string text = "How much wood would a woodchuck chuck?"; - char const * wood = "wood"; + using alphabet_type = typename TestFixture::alphabet_type; - // extend_right() + // test case for https://github.com/seqan/seqan3/issues/1473 + if constexpr (std::is_same::value) { - seqan3::fm_index index{text}; - auto it1 = index.cursor(); - auto it2 = index.cursor(); - - it1.extend_right("wood"); - it2.extend_right(wood); - - EXPECT_TRUE(std::ranges::equal(it1.locate(), it2.locate())); // [22,9] == [22,9] - - seqan3::bi_fm_index b_index{text}; - auto it3 = b_index.cursor(); - auto it4 = b_index.cursor(); - - it3.extend_right("wood"); - it4.extend_right(wood); + typename TypeParam::index_type fm{this->text_col1}; // {"ACGACG", "ACGACG"} + char const * cg = "CG"; - EXPECT_TRUE(std::ranges::equal(it3.locate(), it4.locate())); // [22,9] == [22,9] - } - // extend_left() - { - seqan3::bi_fm_index b_index{text}; - auto it3 = b_index.cursor(); - auto it4 = b_index.cursor(); + // extend_right() + TypeParam it1 = TypeParam(fm); + TypeParam it2 = TypeParam(fm); - it3.extend_left("wood"); - it4.extend_left(wood); + it1.extend_right(cg); + it2.extend_right(seqan3::views::slice(this->text1, 1, 3)); // "CG" - EXPECT_TRUE(std::ranges::equal(it3.locate(), it4.locate())); // [22,9] == [22,9] + EXPECT_TRUE(std::ranges::equal(it1.locate(), it2.locate())); // [(0,1),(0,4),(1,4),(1,1)] } }