1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
// -----------------------------------------------------------------------------------------------------
// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
// Copyright (c) 2016-2020, 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 <type_traits>
#include <seqan3/search/configuration/hit.hpp>
#include <seqan3/search/configuration/max_error.hpp>
#include <seqan3/search/configuration/on_result.hpp>
#include <seqan3/search/configuration/output.hpp>
#include <seqan3/search/configuration/parallel.hpp>
#include <seqan3/search/configuration/result_type.hpp>
#include <seqan3/search/search_result.hpp>
#include <gtest/gtest.h>
template <typename T>
class search_configuration_test : public ::testing::Test
{};
using search_result_t = seqan3::search_result<seqan3::detail::empty_type,
seqan3::detail::empty_type,
seqan3::detail::empty_type,
seqan3::detail::empty_type>;
// Needed to test the on_result config.
inline constexpr auto on_result_caller = [] (auto &&) {};
using test_types = ::testing::Types<seqan3::search_cfg::max_error_total,
seqan3::search_cfg::max_error_substitution,
seqan3::search_cfg::max_error_insertion,
seqan3::search_cfg::max_error_deletion,
seqan3::search_cfg::hit_single_best,
seqan3::search_cfg::on_result<decltype(on_result_caller)>,
seqan3::search_cfg::output_query_id,
seqan3::search_cfg::output_reference_id,
seqan3::search_cfg::output_reference_begin_position,
seqan3::search_cfg::output_index_cursor,
seqan3::search_cfg::parallel,
seqan3::search_cfg::detail::result_type<search_result_t>>;
TYPED_TEST_SUITE(search_configuration_test, test_types, );
// TODO: this should go to a typed configuration test that also checks the alignment configuration
TEST(search_configuration_test, symmetric_configuration)
{
for (uint8_t i = 0; i < static_cast<uint8_t>(seqan3::detail::search_config_id::SIZE); ++i)
{
// no element can occur twice in a configuration
EXPECT_FALSE(seqan3::detail::compatibility_table<seqan3::detail::search_config_id>[i][i])
<< "There is a TRUE value on the diagonal of the search configuration matrix.";
for (uint8_t j = 0; j < i; ++j)
{
// symmetric matrix
EXPECT_EQ(seqan3::detail::compatibility_table<seqan3::detail::search_config_id>[i][j],
seqan3::detail::compatibility_table<seqan3::detail::search_config_id>[j][i])
<< "Search configuration matrix is not symmetric.";
}
}
}
TYPED_TEST(search_configuration_test, config_element_specialisation)
{
EXPECT_TRUE((seqan3::detail::config_element_specialisation<TypeParam>));
}
TYPED_TEST(search_configuration_test, configuration_exists)
{
seqan3::configuration cfg{TypeParam{}};
EXPECT_TRUE(decltype(cfg)::template exists<TypeParam>());
}
TEST(search_configuration_test, max_error_defaults)
{
// empty config defaults to 0 for every empty error configuration
EXPECT_EQ((seqan3::search_cfg::max_error_total{}.error),
(seqan3::search_cfg::max_error_total{seqan3::search_cfg::error_count{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_substitution{}.error),
(seqan3::search_cfg::max_error_substitution{seqan3::search_cfg::error_count{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_insertion{}.error),
(seqan3::search_cfg::max_error_insertion{seqan3::search_cfg::error_count{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_deletion{}.error),
(seqan3::search_cfg::max_error_deletion{seqan3::search_cfg::error_count{0}}.error));
// empty config defaults to 0 for every error_count
EXPECT_EQ((seqan3::search_cfg::max_error_total{seqan3::search_cfg::error_count{}}.error),
(seqan3::search_cfg::max_error_total{seqan3::search_cfg::error_count{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_substitution{seqan3::search_cfg::error_count{}}.error),
(seqan3::search_cfg::max_error_substitution{seqan3::search_cfg::error_count{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_insertion{seqan3::search_cfg::error_count{}}.error),
(seqan3::search_cfg::max_error_insertion{seqan3::search_cfg::error_count{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_deletion{seqan3::search_cfg::error_count{}}.error),
(seqan3::search_cfg::max_error_deletion{seqan3::search_cfg::error_count{0}}.error));
// empty config defaults to 0 for every error_rate
EXPECT_EQ((seqan3::search_cfg::max_error_total{seqan3::search_cfg::error_rate{}}.error),
(seqan3::search_cfg::max_error_total{seqan3::search_cfg::error_rate{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_substitution{seqan3::search_cfg::error_rate{}}.error),
(seqan3::search_cfg::max_error_substitution{seqan3::search_cfg::error_rate{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_insertion{seqan3::search_cfg::error_rate{}}.error),
(seqan3::search_cfg::max_error_insertion{seqan3::search_cfg::error_rate{0}}.error));
EXPECT_EQ((seqan3::search_cfg::max_error_deletion{seqan3::search_cfg::error_rate{}}.error),
(seqan3::search_cfg::max_error_deletion{seqan3::search_cfg::error_rate{0}}.error));
}
|