From 4978f69d7afa9511702419ea0b919a3d1a30bd92 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Mon, 14 Dec 2020 14:45:24 -0500 Subject: Fix byte_stream::put_n --- tests/unit_tests/epee_utils.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/unit_tests/epee_utils.cpp') diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp index 207c4a7dc..256f8c3c2 100644 --- a/tests/unit_tests/epee_utils.cpp +++ b/tests/unit_tests/epee_utils.cpp @@ -982,6 +982,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; + + std::vector 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; -- cgit v1.2.3