test_description_component.cpp 1.85 KB
Newer Older
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
//----------------------------------------------------------------------------//
//  Copyright (c) 2018 Armin Sobhani <arminms@gmail.com>
//
//  Distributed under the Boost Software License Version 1.0.
//  (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
//----------------------------------------------------------------------------//

#define BOOST_TEST_MODULE TestDescriptionComponent
#include <boost/mpl/list.hpp>
#include <boost/test/unit_test.hpp>

#include <boost/bioseq/type_traits.hpp>
#include <boost/bioseq/components/description.hpp>
#include <boost/bioseq/sequence.hpp>

namespace bsq = boost::bioseq;

typedef
    bsq::sequence_host
<
    char
,   std::allocator
,   std::vector
,   bsq::component::description<>
>   seq;

typedef
    bsq::sequence_host
<
    char
,   std::allocator
,   std::vector
>   seq_nodscr;

// adding sequence types to the test list
typedef boost::mpl::list<seq> seq_type;
typedef boost::mpl::list<seq_nodscr> seqnd_type;

BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor, T, seq_type)
{
    T s;
    s.description("copied");
    T c(s);

    BOOST_CHECK( s.empty() );
    BOOST_CHECK_EQUAL( s.description(), "copied" );
    BOOST_CHECK( c.empty() );
    BOOST_CHECK_EQUAL( c.description(), "copied" );
}

BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor, T, seq_type)
{
    T s;
    s.description("moved");
    T m(std::move(s));

    BOOST_CHECK( s.empty() );
    BOOST_CHECK( s.description().empty() );
    BOOST_CHECK( m.empty() );
    BOOST_CHECK_EQUAL( m.description(), "moved" );
}

BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_nodscr, T, seqnd_type)
{
    T s;
    T c(s);

    BOOST_CHECK( s.empty() );
    BOOST_CHECK( c.empty() );
}

BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor_noname, T, seqnd_type)
{
    T s;
    T m(std::move(s));

    BOOST_CHECK( s.empty() );
    BOOST_CHECK( m.empty() );
}