Skip to content

Commit fa71114

Browse files
author
MarcoFalke
committed
test: Inline expected_xor
1 parent 3ace3a1 commit fa71114

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/test/streams_tests.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <boost/test/unit_test.hpp>
1010

11+
using namespace std::string_literals;
12+
1113
BOOST_FIXTURE_TEST_SUITE(streams_tests, BasicTestingSetup)
1214

1315
BOOST_AUTO_TEST_CASE(streams_vector_writer)
@@ -162,46 +164,34 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
162164
BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
163165
{
164166
std::vector<std::byte> in;
165-
std::vector<char> expected_xor;
166167
CDataStream ds(in, 0, 0);
167168

168169
// Degenerate case
169170
ds.Xor({0x00, 0x00});
170-
BOOST_CHECK_EQUAL(
171-
std::string(expected_xor.begin(), expected_xor.end()),
172-
ds.str());
171+
BOOST_CHECK_EQUAL(""s, ds.str());
173172

174173
in.push_back(std::byte{0x0f});
175174
in.push_back(std::byte{0xf0});
176-
expected_xor.push_back('\xf0');
177-
expected_xor.push_back('\x0f');
178175

179176
// Single character key
180177

181178
ds.clear();
182179
ds.insert(ds.begin(), in.begin(), in.end());
183180

184181
ds.Xor({0xff});
185-
BOOST_CHECK_EQUAL(
186-
std::string(expected_xor.begin(), expected_xor.end()),
187-
ds.str());
182+
BOOST_CHECK_EQUAL("\xf0\x0f"s, ds.str());
188183

189184
// Multi character key
190185

191186
in.clear();
192-
expected_xor.clear();
193187
in.push_back(std::byte{0xf0});
194188
in.push_back(std::byte{0x0f});
195-
expected_xor.push_back('\x0f');
196-
expected_xor.push_back('\x00');
197189

198190
ds.clear();
199191
ds.insert(ds.begin(), in.begin(), in.end());
200192

201193
ds.Xor({0xff, 0x0f});
202-
BOOST_CHECK_EQUAL(
203-
std::string(expected_xor.begin(), expected_xor.end()),
204-
ds.str());
194+
BOOST_CHECK_EQUAL("\x0f\x00"s, ds.str());
205195
}
206196

207197
BOOST_AUTO_TEST_CASE(streams_buffered_file)

0 commit comments

Comments
 (0)