diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-02-03 19:36:19 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-02-03 20:16:41 +0100 |
commit | faee5f8dc23cd2fcfb6ad62a1d46ad3020ef0c5c (patch) | |
tree | c318abbcbe66788b8b1b396274f8499ca454c98e /src/test/streams_tests.cpp | |
parent | fa71114926490e84c9222d315a95684d250e8e34 (diff) |
test: Create fresh CDataStream each time
Can be reviewed with --ignore-all-space
Diffstat (limited to 'src/test/streams_tests.cpp')
-rw-r--r-- | src/test/streams_tests.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp index 6deb00ecfc..0925e2e9ee 100644 --- a/src/test/streams_tests.cpp +++ b/src/test/streams_tests.cpp @@ -164,22 +164,23 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer) BOOST_AUTO_TEST_CASE(streams_serializedata_xor) { std::vector<std::byte> in; - CDataStream ds(in, 0, 0); // Degenerate case - ds.Xor({0x00, 0x00}); - BOOST_CHECK_EQUAL(""s, ds.str()); + { + CDataStream ds{in, 0, 0}; + ds.Xor({0x00, 0x00}); + BOOST_CHECK_EQUAL(""s, ds.str()); + } in.push_back(std::byte{0x0f}); in.push_back(std::byte{0xf0}); // Single character key - - ds.clear(); - ds.insert(ds.begin(), in.begin(), in.end()); - - ds.Xor({0xff}); - BOOST_CHECK_EQUAL("\xf0\x0f"s, ds.str()); + { + CDataStream ds{in, 0, 0}; + ds.Xor({0xff}); + BOOST_CHECK_EQUAL("\xf0\x0f"s, ds.str()); + } // Multi character key @@ -187,11 +188,11 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) in.push_back(std::byte{0xf0}); in.push_back(std::byte{0x0f}); - ds.clear(); - ds.insert(ds.begin(), in.begin(), in.end()); - - ds.Xor({0xff, 0x0f}); - BOOST_CHECK_EQUAL("\x0f\x00"s, ds.str()); + { + CDataStream ds{in, 0, 0}; + ds.Xor({0xff, 0x0f}); + BOOST_CHECK_EQUAL("\x0f\x00"s, ds.str()); + } } BOOST_AUTO_TEST_CASE(streams_buffered_file) |