path_exists.cpp 819 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include<__vic/fs.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. namespace tests {
  6. bool check_path(const std::string &path)
  7. {
  8. bool res = __vic::path_exists(path);
  9. std::cout << path << ' ' << (res ? "exists" : "doesn't exist") << '\n';
  10. return res;
  11. }
  12. void run()
  13. {
  14. assert( check_path("."));
  15. assert( check_path("path_exists.cpp"));
  16. assert(!check_path("path_doesnt_exist"));
  17. assert( check_path("../src"));
  18. assert( __vic::file_exists("path_exists.cpp"));
  19. assert(!__vic::dir_exists("path_exists.cpp"));
  20. assert( __vic::dir_exists("."));
  21. assert(!__vic::file_exists("."));
  22. }
  23. } // namespace
  24. int main()
  25. {
  26. try
  27. {
  28. tests::run();
  29. return 0;
  30. }
  31. catch(const std::exception &ex)
  32. {
  33. std::cerr << ex.what() << '\n';
  34. }
  35. return 1;
  36. }