Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Armin Sobhani
bioseq
Commits
f0753f40
Commit
f0753f40
authored
Jul 09, 2018
by
Armin Sobhani
Browse files
add description_component and unit tests
parent
b922fe69
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/boost/bioseq/components/description.hpp
0 → 100644
View file @
f0753f40
//----------------------------------------------------------------------------//
// 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)
//
//----------------------------------------------------------------------------//
#ifndef BOOST_BIOSEQ_COMPONENTS_DESCRIPTION_HPP
#define BOOST_BIOSEQ_COMPONENTS_DESCRIPTION_HPP
namespace
boost
{
namespace
bioseq
{
namespace
component
{
//----------------------------------------------------------------------------//
template
<
typename
CharT
=
char
>
class
description_component
{
public:
/// \name Construction
//@{
description_component
()
{}
//@}
/// \name Attributes
//@{
std
::
basic_string
<
CharT
>
description
()
const
{
return
_description
;
}
void
description
(
std
::
basic_string
<
CharT
>
dscr
)
{
_description
=
dscr
;
}
//@}
// Implementation
protected:
std
::
basic_string
<
CharT
>
_description
;
};
template
<
typename
CharT
=
char
>
using
description
=
description_component
<
CharT
>
;
//----------------------------------------------------------------------------//
}
// end component namespace
}
// end bioseq namespace
}
// end boost namespace
#endif // BOOST_BIOSEQ_COMPONENTS_DESCRIPTION_HPP
include/boost/bioseq/has_component.hpp
View file @
f0753f40
...
...
@@ -45,8 +45,9 @@ struct has_##component \
//----------------------------------------------------------------------------//
GENERATE_HAS_COMPONENT
(
c_str
)
// create has_c_str
GENERATE_HAS_COMPONENT
(
name_component
)
// create has_name_component
GENERATE_HAS_COMPONENT
(
c_str
)
// create has_c_str
GENERATE_HAS_COMPONENT
(
name_component
)
// create has_name_component
GENERATE_HAS_COMPONENT
(
description_component
)
// create has_description_component
//----------------------------------------------------------------------------//
...
...
include/boost/bioseq/sequence.hpp
View file @
f0753f40
...
...
@@ -68,6 +68,7 @@ public:
{
// std::cout << "copy called" << std::endl;
copy_name
(
other
,
has_name_component
<
self_type
>
());
copy_dscr
(
other
,
has_description_component
<
self_type
>
());
}
sequence_host
(
...
...
@@ -79,6 +80,9 @@ public:
move_name
(
std
::
forward
<
sequence_host
>
(
other
)
,
has_name_component
<
self_type
>
()
);
move_dscr
(
std
::
forward
<
sequence_host
>
(
other
)
,
has_description_component
<
self_type
>
()
);
}
sequence_host
(
...
...
@@ -92,11 +96,19 @@ public:
{
self_type
::
_name
=
other
.
_name
;
}
void
copy_name
(
const
sequence_host
&
other
,
std
::
false_type
)
{}
void
copy_dscr
(
const
sequence_host
&
other
,
std
::
true_type
)
{
self_type
::
_description
=
other
.
_description
;
}
void
copy_dscr
(
const
sequence_host
&
other
,
std
::
false_type
)
{}
void
move_name
(
sequence_host
&&
other
,
std
::
true_type
)
{
self_type
::
_name
=
std
::
move
(
other
.
_name
);
}
void
move_name
(
sequence_host
&&
other
,
std
::
false_type
)
{}
void
move_dscr
(
sequence_host
&&
other
,
std
::
true_type
)
{
self_type
::
_description
=
std
::
move
(
other
.
_description
);
}
void
move_dscr
(
sequence_host
&&
other
,
std
::
false_type
)
{}
};
//----------------------------------------------------------------------------//
...
...
test/CMakeLists.txt
View file @
f0753f40
...
...
@@ -48,4 +48,5 @@ endfunction()
add_bioseq_test
(
"sequence"
test_sequence.cpp
)
add_bioseq_test
(
"name.component"
test_name_component.cpp
)
add_bioseq_test
(
"description.component"
test_description_component.cpp
)
add_bioseq_test
(
"io.fasta"
test_io_fasta.cpp
)
test/test_description_component.cpp
0 → 100644
View file @
f0753f40
//----------------------------------------------------------------------------//
// 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
()
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment