Skip to content

Commit 1e5b861

Browse files
committed
test: Add test for array serialization
1 parent d49d198 commit 1e5b861

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/serialize_tests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ BOOST_AUTO_TEST_CASE(sizes)
8585
BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U);
8686
BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U);
8787
BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U);
88+
BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}, 0), 1U);
89+
BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}, 0), 2U);
8890
}
8991

9092
BOOST_AUTO_TEST_CASE(varints)
@@ -179,6 +181,16 @@ BOOST_AUTO_TEST_CASE(vector_bool)
179181
BOOST_CHECK((HashWriter{} << vec1).GetHash() == (HashWriter{} << vec2).GetHash());
180182
}
181183

184+
BOOST_AUTO_TEST_CASE(array)
185+
{
186+
std::array<uint8_t, 32> array1{1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1};
187+
DataStream ds;
188+
ds << array1;
189+
std::array<uint8_t, 32> array2;
190+
ds >> array2;
191+
BOOST_CHECK(array1 == array2);
192+
}
193+
182194
BOOST_AUTO_TEST_CASE(noncanonical)
183195
{
184196
// Write some non-canonical CompactSize encodings, and

0 commit comments

Comments
 (0)