| 286 | } // namespace |
| 287 | |
| 288 | void MultiDiskAdaptorTest::testWriteData() |
| 289 | { |
| 290 | auto fileEntries = createEntries(); |
| 291 | adaptor->setFileEntries(std::begin(fileEntries), std::end(fileEntries)); |
| 292 | |
| 293 | adaptor->openFile(); |
| 294 | std::string msg = "12345"; |
| 295 | adaptor->writeData((const unsigned char*)msg.c_str(), msg.size(), 0); |
| 296 | adaptor->closeFile(); |
| 297 | |
| 298 | CPPUNIT_ASSERT(File(A2_TEST_OUT_DIR "/file0.txt").isFile()); |
| 299 | char buf[128]; |
| 300 | readFile(A2_TEST_OUT_DIR "/file1.txt", buf, 5); |
| 301 | buf[5] = '\0'; |
| 302 | CPPUNIT_ASSERT_EQUAL(msg, std::string(buf)); |
| 303 | |
| 304 | adaptor->openFile(); |
| 305 | std::string msg2 = "67890ABCDEF"; |
| 306 | adaptor->writeData((const unsigned char*)msg2.c_str(), msg2.size(), 5); |
| 307 | adaptor->closeFile(); |
| 308 | |
| 309 | readFile(A2_TEST_OUT_DIR "/file1.txt", buf, 15); |
| 310 | buf[15] = '\0'; |
| 311 | CPPUNIT_ASSERT_EQUAL(std::string("1234567890ABCDE"), std::string(buf)); |
| 312 | readFile(A2_TEST_OUT_DIR "/file2.txt", buf, 1); |
| 313 | buf[1] = '\0'; |
| 314 | CPPUNIT_ASSERT_EQUAL(std::string("F"), std::string(buf)); |
| 315 | |
| 316 | adaptor->openFile(); |
| 317 | std::string msg3 = "12345123456712"; |
| 318 | adaptor->writeData((const unsigned char*)msg3.c_str(), msg3.size(), 10); |
| 319 | adaptor->closeFile(); |
| 320 | |
| 321 | readFile(A2_TEST_OUT_DIR "/file1.txt", buf, 15); |
| 322 | buf[15] = '\0'; |
| 323 | CPPUNIT_ASSERT_EQUAL(std::string("123456789012345"), std::string(buf)); |
| 324 | readFile(A2_TEST_OUT_DIR "/file2.txt", buf, 7); |
| 325 | buf[7] = '\0'; |
| 326 | CPPUNIT_ASSERT_EQUAL(std::string("1234567"), std::string(buf)); |
| 327 | |
| 328 | CPPUNIT_ASSERT(File(A2_TEST_OUT_DIR "/file3.txt").isFile()); |
| 329 | |
| 330 | readFile(A2_TEST_OUT_DIR "/file4.txt", buf, 2); |
| 331 | buf[2] = '\0'; |
| 332 | CPPUNIT_ASSERT_EQUAL(std::string("12"), std::string(buf)); |
| 333 | |
| 334 | CPPUNIT_ASSERT(File(A2_TEST_OUT_DIR "/file5.txt").isFile()); |
| 335 | } |
| 336 | |
| 337 | void MultiDiskAdaptorTest::testReadData() |
| 338 | { |
nothing calls this directly
no test coverage detected