| 20 | using namespace std; |
| 21 | |
| 22 | UNIT_TEST(FilesContainer_Smoke) |
| 23 | { |
| 24 | string const fName = "files_container.tmp"; |
| 25 | FileWriter::DeleteFileX(fName); |
| 26 | size_t const count = 10; |
| 27 | |
| 28 | // fill container one by one |
| 29 | { |
| 30 | FilesContainerW writer(fName); |
| 31 | |
| 32 | for (size_t i = 0; i < count; ++i) |
| 33 | { |
| 34 | auto w = writer.GetWriter(strings::to_string(i)); |
| 35 | |
| 36 | for (uint32_t j = 0; j < i; ++j) |
| 37 | WriteVarUint(w, j); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // read container one by one |
| 42 | { |
| 43 | FilesContainerR reader(fName); |
| 44 | |
| 45 | for (size_t i = 0; i < count; ++i) |
| 46 | { |
| 47 | FilesContainerR::TReader r = reader.GetReader(strings::to_string(i)); |
| 48 | ReaderSource<FilesContainerR::TReader> src(r); |
| 49 | |
| 50 | for (uint32_t j = 0; j < i; ++j) |
| 51 | { |
| 52 | uint32_t const test = ReadVarUint<uint32_t>(src); |
| 53 | TEST_EQUAL(j, test, ()); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // append to container |
| 59 | uint32_t const arrAppend[] = {888, 777, 666}; |
| 60 | for (size_t i = 0; i < ARRAY_SIZE(arrAppend); ++i) |
| 61 | { |
| 62 | { |
| 63 | FilesContainerW writer(fName, FileWriter::OP_WRITE_EXISTING); |
| 64 | |
| 65 | auto w = writer.GetWriter(strings::to_string(arrAppend[i])); |
| 66 | WriteVarUint(w, arrAppend[i]); |
| 67 | } |
| 68 | |
| 69 | // read appended |
| 70 | { |
| 71 | FilesContainerR reader(fName); |
| 72 | |
| 73 | FilesContainerR::TReader r = reader.GetReader(strings::to_string(arrAppend[i])); |
| 74 | ReaderSource<FilesContainerR::TReader> src(r); |
| 75 | |
| 76 | uint32_t const test = ReadVarUint<uint32_t>(src); |
| 77 | TEST_EQUAL(arrAppend[i], test, ()); |
| 78 | } |
| 79 | } |
nothing calls this directly
no test coverage detected