Merge pull request #7152

cf4461f Fix byte_stream::put_n (Lee Clagett)
remotes/1691602464505633909/tmp_refs/heads/wonerujo-v0.10.1
luigi1111 3 years ago
commit ee8d740cba
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010

@ -188,7 +188,7 @@ namespace epee
void put_n(const std::uint8_t ch, const std::size_t count)
{
check(count);
std::memset(tellp(), count, ch);
std::memset(tellp(), ch, count);
next_write_ += count;
}

@ -972,6 +972,23 @@ TEST(ByteStream, Put)
EXPECT_TRUE(equal(bytes, byte_span{stream.data(), stream.size()}));
}
TEST(ByteStream, PutN)
{
using boost::range::equal;
using byte_span = epee::span<const std::uint8_t>;
std::vector<std::uint8_t> bytes;
bytes.resize(1000, 'f');
epee::byte_stream stream;
stream.put_n('f', 1000);
EXPECT_EQ(1000u, stream.size());
EXPECT_LE(1000u, stream.capacity());
EXPECT_EQ(stream.available(), stream.capacity() - stream.size());
EXPECT_TRUE(equal(bytes, byte_span{stream.data(), stream.size()}));
}
TEST(ByteStream, Reserve)
{
using boost::range::equal;

Loading…
Cancel
Save