Skip to content

Commit

Permalink
Merge 05ee914 into 81b6174
Browse files Browse the repository at this point in the history
  • Loading branch information
toxeus committed Aug 17, 2018
2 parents 81b6174 + 05ee914 commit b176b75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/bitcoin/bitcoin/config/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class BC_API block
*/
block(const block& other);

/**
* Copy assignment operator.
* @param[in] other The object to copy into self on assignment.
*/
block& operator=(const block& other);

/**
* Move assignment operator.
* @param[in] other The object to move into self on assignment.
Expand Down
7 changes: 7 additions & 0 deletions src/config/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ block::block(const block& other)
{
}

block& block::operator=(const block& other)
{
chain::block value = block(other);
value_ = std::move(value);
return *this;
}

block& block::operator=(chain::block&& other)
{
value_ = std::move(other);
Expand Down
6 changes: 6 additions & 0 deletions test/config/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ BOOST_AUTO_TEST_CASE(block__construct__copy__expected)
BOOST_REQUIRE_EQUAL(block, genesis_block);
}

BOOST_AUTO_TEST_CASE(block__copy_assign__always__expected)
{
const auto block = genesis_block;
BOOST_REQUIRE_EQUAL(block, genesis_block);
}

BOOST_AUTO_TEST_CASE(block__construct__string__expected)
{
const block block(encoded_genesis_block);
Expand Down

0 comments on commit b176b75

Please sign in to comment.