diff options
author | TheCharlatan <seb.kung@gmail.com> | 2023-11-11 13:21:01 +0100 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2023-11-13 14:18:09 +0100 |
commit | 1e5b86171e81ab4b022b9746bb06e1968ecf4086 (patch) | |
tree | acfcfb4227a27e3fe02ae0e841f31ba648bb9ef6 | |
parent | d49d1988406f2f0d350bc5b552625f9823090130 (diff) |
test: Add test for array serialization
-rw-r--r-- | src/test/serialize_tests.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 49827be559..ec4ffbfb7c 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -85,6 +85,8 @@ BOOST_AUTO_TEST_CASE(sizes) BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U); BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U); BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}, 0), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}, 0), 2U); } BOOST_AUTO_TEST_CASE(varints) @@ -179,6 +181,16 @@ BOOST_AUTO_TEST_CASE(vector_bool) BOOST_CHECK((HashWriter{} << vec1).GetHash() == (HashWriter{} << vec2).GetHash()); } +BOOST_AUTO_TEST_CASE(array) +{ + 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}; + DataStream ds; + ds << array1; + std::array<uint8_t, 32> array2; + ds >> array2; + BOOST_CHECK(array1 == array2); +} + BOOST_AUTO_TEST_CASE(noncanonical) { // Write some non-canonical CompactSize encodings, and |