tst_filemanager.cpp 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #include "tst_filemanager.h"
  2. void TST_FileManager::test()
  3. {
  4. CWF::FileManager fileManager;
  5. QString file("index.html");
  6. QVERIFY2(fileManager.fileExtention(file) == "html", "Should be html");
  7. fileManager.putFirstBar(file);
  8. QVERIFY2(file == "/index.html", "Should be /index.html");
  9. fileManager.removeFirstBar(file);
  10. QVERIFY2(file == "index.html", "Should be index.html");
  11. file += "/";
  12. fileManager.removeLastBar(file);
  13. QVERIFY2(file == "index.html", "Should be index.html");
  14. QVERIFY2(fileManager.extract(file, '.') == "html", "Should be html");
  15. file = "/config/" + file;
  16. QVERIFY2(fileManager.fileName(file) == "index.html", "Should be index.html");
  17. QFile::FileError fileErro;
  18. QVERIFY2(fileManager.readAll(QDir::currentPath() + "/server/config/CPPWeb.ini", fileErro).size() > 0, "Should be > 0");
  19. QVERIFY2(fileManager.readAll("xxxCPPWeb.ini", fileErro) == "No such file or directory", "Should be No such file or directory");
  20. QVERIFY2(fileErro == QFile::FileError::OpenError, "Should be QFile::FileError::OpenError");
  21. QVERIFY2(fileManager.copyDirectoryFiles("xyz", "abc", true), "Should return true");
  22. }