Changeset View
Changeset View
Standalone View
Standalone View
src/test/streams_tests.cpp
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(streams_serializedata_xor) { | ||||
key.clear(); | key.clear(); | ||||
key += '\xff', '\x0f'; | key += '\xff', '\x0f'; | ||||
ds.Xor(key); | ds.Xor(key); | ||||
BOOST_CHECK_EQUAL(std::string(expected_xor.begin(), expected_xor.end()), | BOOST_CHECK_EQUAL(std::string(expected_xor.begin(), expected_xor.end()), | ||||
std::string(ds.begin(), ds.end())); | std::string(ds.begin(), ds.end())); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(streams_empty_vector) { | |||||
std::vector<char> in; | |||||
CDataStream ds(in, 0, 0); | |||||
// read 0 bytes used to cause a segfault on some older systems. | |||||
ds.read(nullptr, 0); | |||||
// Same goes for writing 0 bytes from a vector ... | |||||
const std::vector<char> vdata{'f', 'o', 'o', 'b', 'a', 'r'}; | |||||
ds.insert(ds.begin(), vdata.begin(), vdata.begin()); | |||||
ds.insert(ds.begin(), vdata.begin(), vdata.end()); | |||||
// ... or an array. | |||||
const char adata[6] = {'f', 'o', 'o', 'b', 'a', 'r'}; | |||||
ds.insert(ds.begin(), &adata[0], &adata[0]); | |||||
ds.insert(ds.begin(), &adata[0], &adata[6]); | |||||
} | |||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |