mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
streams: Accept URef obj for VectorReader unserialize
This commit is contained in:
parent
128b98fce3
commit
fa2204f6ad
2 changed files with 12 additions and 1 deletions
|
@ -167,7 +167,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
VectorReader& operator>>(T& obj)
|
||||
VectorReader& operator>>(T&& obj)
|
||||
{
|
||||
// Unserialize from this stream
|
||||
::Unserialize(*this, obj);
|
||||
|
|
|
@ -112,6 +112,17 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader)
|
|||
BOOST_CHECK_THROW(new_reader >> d, std::ios_base::failure);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(streams_vector_reader_rvalue)
|
||||
{
|
||||
std::vector<uint8_t> data{0x82, 0xa7, 0x31};
|
||||
VectorReader reader(SER_NETWORK, INIT_PROTO_VERSION, data, /* pos= */ 0);
|
||||
uint32_t varint = 0;
|
||||
// Deserialize into r-value
|
||||
reader >> VARINT(varint);
|
||||
BOOST_CHECK_EQUAL(varint, 54321);
|
||||
BOOST_CHECK(reader.empty());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
|
||||
{
|
||||
CDataStream data(SER_NETWORK, INIT_PROTO_VERSION);
|
||||
|
|
Loading…
Add table
Reference in a new issue