-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEST] add test for alphabet customisation point
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
add_subdirectories() | ||
seqan3_test(custom_alphabet_test.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// ----------------------------------------------------------------------------------------------------- | ||
// Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin | ||
// Copyright (c) 2016-2019, Knut Reinert & MPI für molekulare Genetik | ||
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License | ||
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md | ||
// ----------------------------------------------------------------------------------------------------- | ||
|
||
#include <seqan3/core/platform.hpp> | ||
#include <cereal/types/common.hpp> | ||
|
||
#include "alphabet_test_template.hpp" | ||
#include "alphabet_constexpr_test_template.hpp" | ||
|
||
// Tests the ADL-capabilities of the alphabet customisation point objects | ||
|
||
namespace my_namespace | ||
{ | ||
|
||
enum class my_alph | ||
{ | ||
ZERO, | ||
ONE, | ||
TWO | ||
}; | ||
|
||
constexpr size_t alphabet_size(my_alph const &) noexcept | ||
{ | ||
return 3; | ||
} | ||
|
||
constexpr size_t to_rank(my_alph const a) noexcept | ||
{ | ||
return static_cast<size_t>(a); | ||
} | ||
|
||
constexpr my_alph & assign_rank_to(size_t const r, my_alph & a) noexcept | ||
{ | ||
switch (r) | ||
{ | ||
case 0: a = my_alph::ZERO; return a; | ||
case 1: a = my_alph::ONE; return a; | ||
default: a = my_alph::TWO; return a; | ||
} | ||
} | ||
|
||
constexpr char to_char(my_alph const a) noexcept | ||
{ | ||
switch (a) | ||
{ | ||
case my_alph::ZERO: return '0'; | ||
case my_alph::ONE: return '1'; | ||
default: return '2'; | ||
} | ||
} | ||
|
||
constexpr my_alph & assign_char_to(char const c, my_alph & a) noexcept | ||
{ | ||
switch (c) | ||
{ | ||
case '0': a = my_alph::ZERO; return a; | ||
case '1': a = my_alph::ONE; return a; | ||
default: a = my_alph::TWO; return a; | ||
} | ||
} | ||
|
||
} | ||
|
||
INSTANTIATE_TYPED_TEST_CASE_P(my_alph, alphabet, my_namespace::my_alph); | ||
INSTANTIATE_TYPED_TEST_CASE_P(my_alph, alphabet_constexpr, my_namespace::my_alph); |