reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

filesystem.cpp (1414B)


      1 #include "helper.hpp"
      2 
      3 #include <filesystem.hpp>
      4 #include <index.hpp>
      5 
      6 static const char *M = "[filesystem]";
      7 static const Path RIPATH("test/indexes");
      8 
      9 TEST_CASE("open unicode file", M) {
     10   UseRootPath root(RIPATH);
     11   const Path &path = Index::pathFor("Новая папка");
     12 
     13   FILE *file = FS::open(path);
     14   REQUIRE(file);
     15   fclose(file);
     16 }
     17 
     18 TEST_CASE("file modification time", M) {
     19   UseRootPath root(RIPATH);
     20   const Path &path = Index::pathFor("Новая папка");
     21 
     22   time_t time = 0;
     23   REQUIRE(FS::mtime(path, &time));
     24   REQUIRE(time > 0);
     25 }
     26 
     27 TEST_CASE("file exists", M) {
     28   UseRootPath root(RIPATH);
     29 
     30   SECTION("file") {
     31     const Path &file = Index::pathFor("Новая папка");
     32     REQUIRE(FS::exists(file));
     33     REQUIRE_FALSE(FS::exists(file, true));
     34   }
     35 
     36   SECTION("directory") {
     37     REQUIRE_FALSE(FS::exists(Path("ReaPack")));
     38     REQUIRE(FS::exists(Path("ReaPack"), true));
     39   }
     40 }
     41 
     42 TEST_CASE("all files exists", M) {
     43   UseRootPath root(RIPATH);
     44 
     45   REQUIRE(FS::allExists(std::vector<Path>{}));
     46 
     47   REQUIRE(FS::allExists(std::set<Path>{
     48     Index::pathFor("future_version"),
     49     Index::pathFor("broken"),
     50   }));
     51 
     52   REQUIRE_FALSE(FS::allExists(std::list<Path>{
     53     Index::pathFor("future_version"),
     54     Index::pathFor("not_found"),
     55   }));
     56 
     57   REQUIRE_FALSE(FS::allExists(std::vector<std::string>{"ReaPack"})); // directory
     58   REQUIRE(FS::allExists(std::vector<std::string>{"ReaPack"}, true));
     59 }