Skip to content

Commit

Permalink
[TEST] add tests for issue #1473
Browse files Browse the repository at this point in the history
Signed-off-by: Lydia Buntrock <lydia.buntrock@fu-berlin.de>
  • Loading branch information
Irallia committed Apr 8, 2020
1 parent a478547 commit 941d650
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 41 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions test/unit/search/fm_index/bi_fm_index_aa27_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "fm_index_collection_test_template.hpp"
#include "fm_index_test_template.hpp"

#include <seqan3/alphabet/aminoacid/aa27.hpp>

using t1 = std::pair<seqan3::bi_fm_index<seqan3::aa27, seqan3::text_layout::single>,
seqan3::aa27_vector>;
INSTANTIATE_TYPED_TEST_SUITE_P(aa27, fm_index_test, t1, );
Expand Down
2 changes: 0 additions & 2 deletions test/unit/search/fm_index/bi_fm_index_char_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "fm_index_collection_test_template.hpp"
#include "fm_index_test_template.hpp"

#include <seqan3/alphabet/adaptation/uint.hpp>

using t1 = std::pair<seqan3::bi_fm_index<unsigned char, seqan3::text_layout::single>,
std::vector<unsigned char>>;
INSTANTIATE_TYPED_TEST_SUITE_P(char, fm_index_test, t1, );
Expand Down
2 changes: 0 additions & 2 deletions test/unit/search/fm_index/bi_fm_index_dna4_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "fm_index_collection_test_template.hpp"
#include "fm_index_test_template.hpp"

#include <seqan3/alphabet/nucleotide/dna4.hpp>

using t1 = std::pair<seqan3::bi_fm_index<seqan3::dna4, seqan3::text_layout::single>,
seqan3::dna4_vector>;
INSTANTIATE_TYPED_TEST_SUITE_P(dna4, fm_index_test, t1, );
Expand Down
3 changes: 0 additions & 3 deletions test/unit/search/fm_index/fm_index_dna4_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include "fm_index_collection_test_template.hpp"
#include "fm_index_test_template.hpp"

#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/nucleotide/dna5.hpp>

using t1 = std::pair<seqan3::fm_index<seqan3::dna4, seqan3::text_layout::single>, seqan3::dna4_vector>;
INSTANTIATE_TYPED_TEST_SUITE_P(dna4, fm_index_test, t1, );
using t2 = std::pair<seqan3::fm_index<seqan3::dna4, seqan3::text_layout::collection>, std::vector<seqan3::dna4_vector>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<alphabet_type, char>::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);
Original file line number Diff line number Diff line change
Expand Up @@ -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<alphabet_type, char>::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)]
}
}

Expand Down

0 comments on commit 941d650

Please sign in to comment.