test_name_component.cpp 2.97 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
//----------------------------------------------------------------------------//
//  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 TestNameComponent
#include <boost/mpl/list.hpp>
#include <boost/test/unit_test.hpp>

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

namespace bsq = boost::bioseq;

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

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

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

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

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

53
54
55
56
57
58
59
60
61
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_noname, T, seqnn_type)
{
    T s;
    T c(s);

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

62
63
64
65
66
67
68
69
70
71
72
73
BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor, T, seq_type)
{
    T s;
    s.name("moved");
    T m(std::move(s));

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

74
BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor_noname, T, seqnn_type)
75
76
{
    T s;
77
78
79
80
81
82
83
84
85
86
87
    T m(std::move(s));

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

BOOST_AUTO_TEST_CASE_TEMPLATE(copy_assignment_operator, T, seq_type)
{
    T s;
    s.name("copied");
    T c = s;
88
89

    BOOST_CHECK( s.empty() );
90
    BOOST_CHECK_EQUAL( s.name(), "copied" );
91
    BOOST_CHECK( c.empty() );
92
    BOOST_CHECK_EQUAL( c.name(), "copied" );
93
94
}

95
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_assignment_operator_noname, T, seqnn_type)
96
97
{
    T s;
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
    T c = s;

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

BOOST_AUTO_TEST_CASE_TEMPLATE(move_assignment_operator, T, seq_type)
{
    T s;
    s.name("moved");
    T m = std::move(s);

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

BOOST_AUTO_TEST_CASE_TEMPLATE(move_assignment_operator_noname, T, seqnn_type)
{
    T s;
    T m = std::move(s);
120
121
122
123

    BOOST_CHECK( s.empty() );
    BOOST_CHECK( m.empty() );
}
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

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() );
}