Commit 0b183d70 authored by Armin Sobhani's avatar Armin Sobhani
Browse files

add unit tests for copy and move assignment operators to sequence_host class template

parent a4fb26ce
......@@ -50,6 +50,15 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor, T, seq_type)
BOOST_CHECK_EQUAL( c.description(), "copied" );
}
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, T, seq_type)
{
T s;
......@@ -62,20 +71,54 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor, T, seq_type)
BOOST_CHECK_EQUAL( m.description(), "moved" );
}
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_nodscr, T, seqnd_type)
BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor_noname, T, seqnd_type)
{
T s;
T c(s);
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.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_noname, T, seqnd_type)
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_assignment_operator_nodscr, T, seqnd_type)
{
T s;
T m(std::move(s));
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.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(move_assignment_operator_noname, T, seqnd_type)
{
T s;
T m = std::move(s);
BOOST_CHECK( s.empty() );
BOOST_CHECK( m.empty() );
}
......@@ -50,6 +50,15 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor, T, seq_type)
BOOST_CHECK_EQUAL( c.name(), "copied" );
}
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_noname, T, seqnn_type)
{
T s;
T c(s);
BOOST_CHECK( s.empty() );
BOOST_CHECK( c.empty() );
}
BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor, T, seq_type)
{
T s;
......@@ -62,19 +71,52 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor, T, seq_type)
BOOST_CHECK_EQUAL( m.name(), "moved" );
}
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_noname, T, seqnn_type)
BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor_noname, T, seqnn_type)
{
T s;
T c(s);
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;
BOOST_CHECK( s.empty() );
BOOST_CHECK_EQUAL( s.name(), "copied" );
BOOST_CHECK( c.empty() );
BOOST_CHECK_EQUAL( c.name(), "copied" );
}
BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor_noname, T, seqnn_type)
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_assignment_operator_noname, T, seqnn_type)
{
T s;
T m(std::move(s));
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);
BOOST_CHECK( s.empty() );
BOOST_CHECK( m.empty() );
......
......@@ -196,6 +196,35 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor, T, seq_types)
BOOST_CHECK_EQUAL(*(++b), 'G');
}
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_assignment_operator, T, seq_types)
{
T seq("ATCG");
T copy = seq;
BOOST_CHECK_EQUAL(copy.size(), 4);
auto b = copy.cbegin();
BOOST_CHECK_EQUAL( *b , 'A');
BOOST_CHECK_EQUAL(*(++b), 'T');
BOOST_CHECK_EQUAL(*(++b), 'C');
BOOST_CHECK_EQUAL(*(++b), 'G');
}
BOOST_AUTO_TEST_CASE_TEMPLATE(move_assignment_operator, T, seq_types)
{
T seq("ATCG");
T moved = std::move(seq);
BOOST_CHECK( seq.empty() );
BOOST_CHECK_EQUAL(moved.size(), 4);
auto b = moved.cbegin();
BOOST_CHECK_EQUAL( *b , 'A');
BOOST_CHECK_EQUAL(*(++b), 'T');
BOOST_CHECK_EQUAL(*(++b), 'C');
BOOST_CHECK_EQUAL(*(++b), 'G');
}
BOOST_AUTO_TEST_CASE_TEMPLATE(constructor_initializer_list, T, seq_types)
{
T seq{ 'A', 'T', 'C', 'G'};
......
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