9 #include <boost/test/unit_test.hpp>
11 using namespace std::string_literals;
19 unsigned char bytes[] = { 3, 4, 5, 6 };
20 std::vector<unsigned char> vch;
27 BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
29 BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
33 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
35 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
40 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
42 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
47 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
49 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
54 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
56 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
60 BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
62 BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
67 BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
69 BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
75 std::vector<unsigned char> vch = {1, 255, 3, 4, 5, 6};
120 std::vector<uint8_t> data{0x82, 0xa7, 0x31};
134 bit_writer.
Write(0, 1);
135 bit_writer.
Write(2, 2);
136 bit_writer.
Write(6, 3);
137 bit_writer.
Write(11, 4);
138 bit_writer.
Write(1, 5);
139 bit_writer.
Write(32, 6);
140 bit_writer.
Write(7, 7);
141 bit_writer.
Write(30497, 16);
145 uint32_t serialized_int1;
146 data >> serialized_int1;
148 uint16_t serialized_int2;
149 data >> serialized_int2;
166 std::vector<std::byte> in;
171 ds.
Xor({0x00, 0x00});
175 in.push_back(std::byte{0x0f});
176 in.push_back(std::byte{0xf0});
188 in.push_back(std::byte{0xf0});
189 in.push_back(std::byte{0x0f});
193 ds.
Xor({0xff, 0x0f});
200 fs::path streams_test_filename = m_args.GetDataDirBase() /
"streams_test_tmp";
204 for (uint8_t j = 0; j < 40; ++j) {
205 fwrite(&j, 1, 1, file);
214 }
catch (
const std::exception& e) {
216 "Rewind limit must be less than buffer size") !=
nullptr);
254 }
catch (
const std::exception& e) {
256 "Read attempted past buffer limit") !=
nullptr);
264 for (uint8_t j = 3; j < 10; ++j) {
297 for (uint8_t j = 0; j <
sizeof(a); ++j) {
307 }
catch (
const std::exception& e) {
309 "CBufferedFile::Fill: end of file") !=
nullptr);
330 fs::remove(streams_test_filename);
338 fs::path streams_test_filename = m_args.GetDataDirBase() /
"streams_test_tmp";
339 for (
int rep = 0; rep < 50; ++rep) {
342 for (uint8_t i = 0; i < fileSize; ++i) {
343 fwrite(&i, 1, 1, file);
350 size_t currentPos = 0;
352 for (
int step = 0; step < 100; ++step) {
353 if (currentPos >= fileSize)
367 if (currentPos + 1 > fileSize)
371 for (uint8_t i = 0; i < 1; ++i) {
379 if (currentPos + 2 > fileSize)
383 for (uint8_t i = 0; i < 2; ++i) {
391 if (currentPos + 5 > fileSize)
395 for (uint8_t i = 0; i < 5; ++i) {
404 if (find >= fileSize)
420 bool okay = bf.
SetPos(requestPos);
428 if (requestPos <= maxPos &&
429 maxPos > rewindSize &&
430 requestPos >= maxPos - rewindSize) {
437 if (maxPos < currentPos)
441 fs::remove(streams_test_filename);