aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2020-12-14 14:45:24 -0500
committerLee Clagett <code@leeclagett.com>2020-12-14 16:20:51 +0000
commitcf4461f40b92f300a3b5e1bea6c8065515939297 (patch)
treef0c28aa6975daef44163d4df2837db0cfc821ec3 /tests
parentMerge pull request #7122 (diff)
downloadmonero-cf4461f40b92f300a3b5e1bea6c8065515939297.tar.xz
Fix byte_stream::put_n
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/epee_utils.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp
index b365cad86..8c89968b9 100644
--- a/tests/unit_tests/epee_utils.cpp
+++ b/tests/unit_tests/epee_utils.cpp
@@ -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;