Skip to content

Commit

Permalink
[MISC] remove using namespace seqan3/test/unit/alphabet/a*-c* (#1657)
Browse files Browse the repository at this point in the history
* [MISC] Remove 'using namespace seqan3' from test/unit/alphabet/a*.

* [MISC] Remove 'using namespace seqan3' from test/unit/alphabet/c*.

* [MISC] style guide fixes
  • Loading branch information
Irallia authored Apr 6, 2020
1 parent acd4e28 commit 97d7646
Show file tree
Hide file tree
Showing 20 changed files with 630 additions and 581 deletions.
62 changes: 35 additions & 27 deletions test/unit/alphabet/adaptation/char_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "../semi_alphabet_constexpr_test_template.hpp"
#include "../semi_alphabet_test_template.hpp"

using namespace seqan3;

using char_types = ::testing::Types<char, char16_t, char32_t, wchar_t>;

INSTANTIATE_TYPED_TEST_SUITE_P(char_adaptation, alphabet_, char_types, );
Expand All @@ -39,65 +37,75 @@ TYPED_TEST(char_adaptation, type_properties)

TYPED_TEST(char_adaptation, alphabet_char_t)
{
EXPECT_TRUE((std::is_same_v<alphabet_char_t<TypeParam >, TypeParam>));
EXPECT_TRUE((std::is_same_v<alphabet_char_t<TypeParam & >, TypeParam>));
EXPECT_TRUE((std::is_same_v<alphabet_char_t<TypeParam &&>, TypeParam>));
EXPECT_TRUE((std::is_same_v<seqan3::alphabet_char_t<TypeParam>, TypeParam>));
EXPECT_TRUE((std::is_same_v<seqan3::alphabet_char_t<TypeParam &>, TypeParam>));
EXPECT_TRUE((std::is_same_v<seqan3::alphabet_char_t<TypeParam &&>, TypeParam>));
}

TYPED_TEST(char_adaptation, to_char)
{
TypeParam l{'A'};
EXPECT_TRUE((std::is_same_v<decltype(to_char(l)), alphabet_char_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(to_char(TypeParam{'A'})), alphabet_char_t<TypeParam>>));
EXPECT_EQ(to_char(TypeParam{'A'}), l);
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_char(l)),
seqan3::alphabet_char_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_char(TypeParam{'A'})),
seqan3::alphabet_char_t<TypeParam>>));
EXPECT_EQ(seqan3::to_char(TypeParam{'A'}), l);
}

TYPED_TEST(char_adaptation, assign_char_to)
{
TypeParam l{'A'};
EXPECT_TRUE((std::is_same_v<decltype(assign_char_to('A', l )), alphabet_char_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(assign_char_to('A', TypeParam{'A'})), alphabet_char_t<TypeParam> >));
EXPECT_EQ((assign_char_to('A', TypeParam{'C'})), l);
EXPECT_EQ((assign_char_to('C', l )), TypeParam{'C'});
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_to('A', l)),
seqan3::alphabet_char_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_to('A', TypeParam{'A'})),
seqan3::alphabet_char_t<TypeParam>>));
EXPECT_EQ((seqan3::assign_char_to('A', TypeParam{'C'})), l);
EXPECT_EQ((seqan3::assign_char_to('C', l)), TypeParam{'C'});
}

TYPED_TEST(char_adaptation, assign_char_strictly_to)
{
TypeParam l{'A'};
EXPECT_TRUE((std::is_same_v<decltype(assign_char_strictly_to('A', l )), alphabet_char_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(assign_char_strictly_to('A', TypeParam{'A'})), alphabet_char_t<TypeParam> >));
EXPECT_EQ((assign_char_strictly_to('A', TypeParam{'C'})), l);
EXPECT_EQ((assign_char_strictly_to('C', l )), TypeParam{'C'});
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_strictly_to('A', l)),
seqan3::alphabet_char_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_strictly_to('A', TypeParam{'A'})),
seqan3::alphabet_char_t<TypeParam>>));
EXPECT_EQ((seqan3::assign_char_strictly_to('A', TypeParam{'C'})), l);
EXPECT_EQ((seqan3::assign_char_strictly_to('C', l)), TypeParam{'C'});
}

TYPED_TEST(char_adaptation, alphabet_rank_t)
{
EXPECT_TRUE((std::is_integral_v<alphabet_rank_t<TypeParam>>));
EXPECT_TRUE((std::is_unsigned_v<alphabet_rank_t<TypeParam>>));
EXPECT_GE(sizeof(alphabet_rank_t<TypeParam>), sizeof(TypeParam));
EXPECT_TRUE((std::is_integral_v<seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_TRUE((std::is_unsigned_v<seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_GE(sizeof(seqan3::alphabet_rank_t<TypeParam>), sizeof(TypeParam));
}

TYPED_TEST(char_adaptation, to_rank)
{
TypeParam l{'A'};
EXPECT_TRUE((std::is_same_v<decltype(to_rank(l)), alphabet_rank_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(to_rank(TypeParam{'A'})), alphabet_rank_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_rank(l)),
seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_rank(TypeParam{'A'})),
seqan3::alphabet_rank_t<TypeParam>>));

unsigned char cmp{'A'};
EXPECT_EQ(to_rank(TypeParam{65}), cmp);
EXPECT_EQ(seqan3::to_rank(TypeParam{65}), cmp);
}

TYPED_TEST(char_adaptation, assign_rank_to)
{
TypeParam l{'A'};
EXPECT_TRUE((std::is_same_v<decltype(assign_rank_to(65, l)), alphabet_char_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(assign_rank_to(65, TypeParam{'A'})), alphabet_char_t<TypeParam> >));
EXPECT_EQ((assign_rank_to(65, TypeParam{'C'})), l);
EXPECT_EQ((assign_rank_to(67, l)), TypeParam{'C'});
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_rank_to(65, l)),
seqan3::alphabet_char_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_rank_to(65, TypeParam{'A'})),
seqan3::alphabet_char_t<TypeParam>>));
EXPECT_EQ((seqan3::assign_rank_to(65, TypeParam{'C'})), l);
EXPECT_EQ((seqan3::assign_rank_to(67, l)), TypeParam{'C'});
}

TYPED_TEST(char_adaptation, alphabet_size)
{
EXPECT_EQ(alphabet_size<TypeParam>,
EXPECT_EQ(seqan3::alphabet_size<TypeParam>,
static_cast<size_t>(std::numeric_limits<TypeParam>::max()) + 1 - std::numeric_limits<TypeParam>::lowest());
}
62 changes: 35 additions & 27 deletions test/unit/alphabet/adaptation/uint_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "../semi_alphabet_constexpr_test_template.hpp"
#include "../semi_alphabet_test_template.hpp"

using namespace seqan3;

// uint32_t, too slow
using fast_uint_types = ::testing::Types<uint8_t, uint16_t/*, uint32_t*/>;

Expand All @@ -42,70 +40,80 @@ TYPED_TEST(uint_adaptation, type_properties)

TYPED_TEST(uint_adaptation, alphabet_rank_t)
{
EXPECT_TRUE((std::is_same_v<alphabet_rank_t<TypeParam >, TypeParam>));
EXPECT_TRUE((std::is_same_v<alphabet_rank_t<TypeParam & >, TypeParam>));
EXPECT_TRUE((std::is_same_v<alphabet_rank_t<TypeParam &&>, TypeParam>));
EXPECT_TRUE((std::is_same_v<seqan3::alphabet_rank_t<TypeParam>, TypeParam>));
EXPECT_TRUE((std::is_same_v<seqan3::alphabet_rank_t<TypeParam &>, TypeParam>));
EXPECT_TRUE((std::is_same_v<seqan3::alphabet_rank_t<TypeParam &&>, TypeParam>));
}

TYPED_TEST(uint_adaptation, to_rank)
{
TypeParam l{65};
EXPECT_TRUE((std::is_same_v<decltype(to_rank(l)), alphabet_rank_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(to_rank(TypeParam{65})), alphabet_rank_t<TypeParam>>));
EXPECT_EQ(to_rank(TypeParam{65}), l);
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_rank(l)),
seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_rank(TypeParam{65})),
seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_EQ(seqan3::to_rank(TypeParam{65}), l);
}

TYPED_TEST(uint_adaptation, assign_rank)
{
TypeParam l{65};
EXPECT_TRUE((std::is_same_v<decltype(assign_rank_to(65, l)), alphabet_rank_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(assign_rank_to(65, TypeParam{65})), alphabet_rank_t<TypeParam> >));
EXPECT_EQ((assign_rank_to(65, TypeParam{65})), l);
EXPECT_EQ((assign_rank_to(67, l)), TypeParam{67});
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_rank_to(65, l)),
seqan3::alphabet_rank_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_rank_to(65, TypeParam{65})),
seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_EQ((seqan3::assign_rank_to(65, TypeParam{65})), l);
EXPECT_EQ((seqan3::assign_rank_to(67, l)), TypeParam{67});
}

TYPED_TEST(uint_adaptation, alphabet_char_t)
{
EXPECT_TRUE((std::is_integral_v<alphabet_rank_t<TypeParam>>));
EXPECT_GE(sizeof(alphabet_rank_t<TypeParam>), sizeof(TypeParam));
EXPECT_TRUE((std::is_integral_v<seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_GE(sizeof(seqan3::alphabet_rank_t<TypeParam>), sizeof(TypeParam));
}

TYPED_TEST(uint_adaptation, to_char)
{
TypeParam l{65};
EXPECT_TRUE((std::is_same_v<decltype(to_char(l)), alphabet_char_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(to_char(TypeParam{65})), alphabet_char_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_char(l)),
seqan3::alphabet_char_t<TypeParam>>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::to_char(TypeParam{65})),
seqan3::alphabet_char_t<TypeParam>>));
if constexpr (std::is_unsigned_v<TypeParam>)
{
unsigned char cmp{'A'};
EXPECT_EQ(to_rank(TypeParam{65}), cmp);
EXPECT_EQ(seqan3::to_rank(TypeParam{65}), cmp);
}
else
{
EXPECT_EQ(to_rank(TypeParam{65}), 'A');
EXPECT_EQ(seqan3::to_rank(TypeParam{65}), 'A');
}
}

TYPED_TEST(uint_adaptation, assign_char)
{
TypeParam l{65};
EXPECT_TRUE((std::is_same_v<decltype(assign_char_to('A', l)), alphabet_rank_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(assign_char_to('A', TypeParam{'A'})), alphabet_rank_t<TypeParam> >));
EXPECT_EQ((assign_char_to('A', TypeParam{67})), l);
EXPECT_EQ((assign_char_to('C', l)), TypeParam{67});
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_to('A', l)),
seqan3::alphabet_rank_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_to('A', TypeParam{'A'})),
seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_EQ((seqan3::assign_char_to('A', TypeParam{67})), l);
EXPECT_EQ((seqan3::assign_char_to('C', l)), TypeParam{67});
}

TYPED_TEST(uint_adaptation, assign_char_strictly_to)
{
TypeParam l{65};
EXPECT_TRUE((std::is_same_v<decltype(assign_char_strictly_to('A', l )), alphabet_rank_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(assign_char_strictly_to('A', TypeParam{'A'})), alphabet_rank_t<TypeParam> >));
EXPECT_EQ((assign_char_strictly_to('A', TypeParam{67})), l);
EXPECT_EQ((assign_char_strictly_to('C', l )), TypeParam{67});
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_strictly_to('A', l)),
seqan3::alphabet_rank_t<TypeParam> &>));
EXPECT_TRUE((std::is_same_v<decltype(seqan3::assign_char_strictly_to('A', TypeParam{'A'})),
seqan3::alphabet_rank_t<TypeParam>>));
EXPECT_EQ((seqan3::assign_char_strictly_to('A', TypeParam{67})), l);
EXPECT_EQ((seqan3::assign_char_strictly_to('C', l)), TypeParam{67});
}

TYPED_TEST(uint_adaptation, alphabet_size)
{
EXPECT_EQ(alphabet_size<TypeParam>,
EXPECT_EQ(seqan3::alphabet_size<TypeParam>,
static_cast<uint64_t>(std::numeric_limits<TypeParam>::max()) + 1 - std::numeric_limits<TypeParam>::lowest());
}
14 changes: 7 additions & 7 deletions test/unit/alphabet/alphabet_cereal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
#include <seqan3/alphabet/quality/qualified.hpp>
#include <seqan3/test/cereal.hpp>

using namespace seqan3;

template <typename T>
using alphabet_cereal = ::testing::Test;

using test_types = ::testing::Types<dna4, qualified<dna4, phred42>, gapped<dna4>>;
using test_types = ::testing::Types<seqan3::dna4,
seqan3::qualified<seqan3::dna4, seqan3::phred42>,
seqan3::gapped<seqan3::dna4>>;

TYPED_TEST_SUITE(alphabet_cereal, test_types, );

TYPED_TEST(alphabet_cereal, serialisation)
{
TypeParam letter;

assign_rank_to(1 % alphabet_size<TypeParam>, letter);
test::do_serialisation(letter);
seqan3::assign_rank_to(1 % seqan3::alphabet_size<TypeParam>, letter);
seqan3::test::do_serialisation(letter);

std::vector<TypeParam> vec;
vec.resize(10);
for (unsigned i = 0; i < 10; ++i)
assign_rank_to(i % alphabet_size<TypeParam>, vec[i]);
test::do_serialisation(vec);
seqan3::assign_rank_to(i % seqan3::alphabet_size<TypeParam>, vec[i]);
seqan3::test::do_serialisation(vec);
}
4 changes: 3 additions & 1 deletion test/unit/alphabet/alphabet_hash_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
template <typename T>
using alphabet_hashing = ::testing::Test;

using test_types = ::testing::Types<seqan3::dna4, seqan3::qualified<seqan3::dna4, seqan3::phred42>, seqan3::gapped<seqan3::dna4>>;
using test_types = ::testing::Types<seqan3::dna4,
seqan3::qualified<seqan3::dna4, seqan3::phred42>,
seqan3::gapped<seqan3::dna4>>;

TYPED_TEST_SUITE(alphabet_hashing, test_types, );

Expand Down
60 changes: 31 additions & 29 deletions test/unit/alphabet/aminoacid/aa10li_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
#include <seqan3/alphabet/aminoacid/aa10li.hpp>
#include <seqan3/range/views/zip.hpp>

INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, alphabet_, aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, semi_alphabet_test, aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, alphabet_constexpr, aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, semi_alphabet_constexpr, aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, aminoacid, aa10li, );
using seqan3::operator""_aa10li;

INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, alphabet_, seqan3::aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, semi_alphabet_test, seqan3::aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, alphabet_constexpr, seqan3::aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, semi_alphabet_constexpr, seqan3::aa10li, );
INSTANTIATE_TYPED_TEST_SUITE_P(aa10li, aminoacid, seqan3::aa10li, );

TEST(aa10li, assign_char)
{
Expand All @@ -33,7 +35,7 @@ TEST(aa10li, assign_char)
'*', '!'
};

std::vector<aa10li> alphabets
std::vector<seqan3::aa10li> alphabets
{
'A'_aa10li, 'B'_aa10li, 'C'_aa10li, 'B'_aa10li, 'B'_aa10li, 'F'_aa10li, 'G'_aa10li,
'H'_aa10li, 'I'_aa10li, 'J'_aa10li, 'K'_aa10li, 'J'_aa10li, 'J'_aa10li,
Expand All @@ -46,8 +48,8 @@ TEST(aa10li, assign_char)
'F'_aa10li, 'A'_aa10li
};

for (auto [ chr, alp ] : views::zip(chars, alphabets))
EXPECT_EQ((assign_char_to(chr, aa10li{})), alp);
for (auto [ chr, alp ] : seqan3::views::zip(chars, alphabets))
EXPECT_EQ((seqan3::assign_char_to(chr, seqan3::aa10li{})), alp);
}

TEST(aa10li, to_char)
Expand All @@ -58,16 +60,16 @@ TEST(aa10li, to_char)
'B', 'K', 'A', 'A', 'I', 'F', 'F', 'B', 'J', 'K', 'C', 'A', 'B'
};

std::vector<aa10li> alphabets
std::vector<seqan3::aa10li> alphabets
{
'A'_aa10li, 'C'_aa10li, 'D'_aa10li, 'E'_aa10li, 'F'_aa10li, 'G'_aa10li, 'H'_aa10li,
'I'_aa10li, 'K'_aa10li, 'L'_aa10li, 'M'_aa10li, 'N'_aa10li, 'P'_aa10li,
'Q'_aa10li, 'R'_aa10li, 'S'_aa10li, 'T'_aa10li, 'V'_aa10li, 'W'_aa10li, 'Y'_aa10li,
'B'_aa10li, 'J'_aa10li, 'O'_aa10li, 'U'_aa10li, 'X'_aa10li, 'Z'_aa10li
};

for (auto [ chr, alp ] : views::zip(chars, alphabets))
EXPECT_EQ(to_char(alp), chr);
for (auto [ chr, alp ] : seqan3::views::zip(chars, alphabets))
EXPECT_EQ(seqan3::to_char(alp), chr);
}

// ------------------------------------------------------------------
Expand All @@ -76,35 +78,35 @@ TEST(aa10li, to_char)

TEST(literals, char_literal)
{
EXPECT_EQ(to_char('A'_aa10li), 'A');
EXPECT_EQ(to_char('B'_aa10li), 'B');
EXPECT_EQ(to_char('C'_aa10li), 'C');
EXPECT_EQ(to_char('F'_aa10li), 'F');
EXPECT_EQ(to_char('G'_aa10li), 'G');
EXPECT_EQ(to_char('H'_aa10li), 'H');
EXPECT_EQ(to_char('I'_aa10li), 'I');
EXPECT_EQ(to_char('J'_aa10li), 'J');
EXPECT_EQ(to_char('K'_aa10li), 'K');
EXPECT_EQ(to_char('P'_aa10li), 'P');

EXPECT_EQ(to_char('*'_aa10li), 'F');
EXPECT_EQ(to_char('!'_aa10li), 'A');
EXPECT_EQ(seqan3::to_char('A'_aa10li), 'A');
EXPECT_EQ(seqan3::to_char('B'_aa10li), 'B');
EXPECT_EQ(seqan3::to_char('C'_aa10li), 'C');
EXPECT_EQ(seqan3::to_char('F'_aa10li), 'F');
EXPECT_EQ(seqan3::to_char('G'_aa10li), 'G');
EXPECT_EQ(seqan3::to_char('H'_aa10li), 'H');
EXPECT_EQ(seqan3::to_char('I'_aa10li), 'I');
EXPECT_EQ(seqan3::to_char('J'_aa10li), 'J');
EXPECT_EQ(seqan3::to_char('K'_aa10li), 'K');
EXPECT_EQ(seqan3::to_char('P'_aa10li), 'P');

EXPECT_EQ(seqan3::to_char('*'_aa10li), 'F');
EXPECT_EQ(seqan3::to_char('!'_aa10li), 'A');
}

TEST(literals, vector)
{
aa10li_vector v20;
seqan3::aa10li_vector v20;
v20.resize(5, 'D'_aa10li);
EXPECT_EQ(v20, "BBBBB"_aa10li);

std::vector<aa10li> w20{'A'_aa10li, 'D'_aa10li, 'N'_aa10li, 'O'_aa10li, 'U'_aa10li, 'X'_aa10li, 'R'_aa10li, '!'_aa10li,
'*'_aa10li, '*'_aa10li};
std::vector<seqan3::aa10li> w20{'A'_aa10li, 'D'_aa10li, 'N'_aa10li, 'O'_aa10li, 'U'_aa10li, 'X'_aa10li, 'R'_aa10li,
'!'_aa10li, '*'_aa10li, '*'_aa10li};
EXPECT_EQ(w20, "ABHKCAKAF*"_aa10li);
}

TEST(aa10li, char_is_valid)
{
constexpr auto aa27_validator = (is_alpha || is_char<'*'>);
constexpr auto aa27_validator = (seqan3::is_alpha || seqan3::is_char<'*'>);

for (char c : std::views::iota(std::numeric_limits<char>::min(), std::numeric_limits<char>::max()))
{
Expand All @@ -124,6 +126,6 @@ TEST(aa10li, char_is_valid)
break;
}

EXPECT_EQ(aa10li::char_is_valid(c), expect);
EXPECT_EQ(seqan3::aa10li::char_is_valid(c), expect);
}
}
Loading

0 comments on commit 97d7646

Please sign in to comment.