posix_file_stat.cpp 692 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include<__vic/posix/file_stat.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. void run_tests()
  6. {
  7. __vic::posix::file_stat s;
  8. assert(s.get_if_exists("posix_file_stat.cpp") == true);
  9. s.get("posix_file_stat.cpp");
  10. assert(s.is_regular());
  11. assert(s.get_if_exists("posix_file_stat.doesnotexist") == false);
  12. try {
  13. s.get("posix_file_stat.doesnotexist");
  14. assert(false);
  15. } catch(const std::exception &) {
  16. // OK
  17. }
  18. struct ::stat ss = s;
  19. s = ss;
  20. }
  21. int main()
  22. {
  23. try
  24. {
  25. run_tests();
  26. return 0;
  27. }
  28. catch(const std::exception &ex)
  29. {
  30. std::cerr << ex.what() << '\n';
  31. }
  32. return 1;
  33. }