Commit 4a55aca2 authored by Armin Sobhani's avatar Armin Sobhani
Browse files

add short_name() to sequence_host with unit tests

parent 2641deb0
......@@ -91,6 +91,11 @@ public:
: ContainerT<CharT, AllocatorT<CharT>>(init, alloc)
{}
std::basic_string<CharT> short_name() const
{
return get_name(has_name_component<self_type>());
}
private:
void copy_name(const sequence_host& other, std::true_type)
{ self_type::_name = other._name; }
......@@ -109,6 +114,11 @@ public:
{ self_type::_description = std::move(other._description); }
void move_dscr(sequence_host&& other, std::false_type)
{}
std::basic_string<CharT> get_name(std::true_type) const
{ return self_type::_name; }
std::basic_string<CharT> get_name(std::false_type) const
{ return {}; }
};
//----------------------------------------------------------------------------//
......
......@@ -79,3 +79,20 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor_noname, T, seqnn_type)
BOOST_CHECK( s.empty() );
BOOST_CHECK( m.empty() );
}
BOOST_AUTO_TEST_CASE_TEMPLATE(short_name, T, seq_type)
{
T s;
s.name("named");
BOOST_CHECK( s.empty() );
BOOST_CHECK_EQUAL( s.short_name(), "named" );
}
BOOST_AUTO_TEST_CASE_TEMPLATE(short_name_noname, T, seqnn_type)
{
T s;
BOOST_CHECK( s.empty() );
BOOST_CHECK( s.short_name().empty() );
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment