You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 line
894 B

  1. #include <gtest/gtest.h>
  2. #include <cppfs.h>
  3. using namespace ::testing;
  4. using namespace ::cppfs;
  5. TEST(directory_tests, create)
  6. {
  7. EXPECT_ANY_THROW(directory("/fuu/bar/baz").create(false));
  8. EXPECT_FALSE(directory("/tmp/fuu/bar/baz").exists());
  9. directory("/tmp/fuu/bar/baz").create(true).remove(false);
  10. }
  11. TEST(directory_tests, exists)
  12. {
  13. EXPECT_TRUE (directory("./cppfs").exists());
  14. EXPECT_FALSE(directory("./cppfs/directory_tests.cpp").exists());
  15. }
  16. TEST(directory_tests, iterator)
  17. {
  18. directory dir("./cppfs");
  19. std::vector<std::string> files;
  20. std::transform(dir.begin(), dir.end(), std::back_inserter(files), [](auto& e) { return e.name; });
  21. std::sort(files.begin(), files.end());
  22. EXPECT_EQ(
  23. files,
  24. std::vector<std::string>({
  25. "directory_tests.cpp",
  26. "file_tests.cpp",
  27. "path_tests.cpp",
  28. }));
  29. }