posix_file.cpp 520 B

1234567891011121314151617181920212223242526272829
  1. #include<__vic/posix/file.h>
  2. #include<__vic/error.h>
  3. #include<iostream>
  4. #include<exception>
  5. #include<cassert>
  6. void run_tests()
  7. {
  8. __vic::posix::file file("posix_file.cpp", O_RDONLY);
  9. if(!file.is_open()) throw __vic::libc_error("Cannot open file");
  10. char buf[256];
  11. size_t n = file.read_max(buf, sizeof buf);
  12. assert(n > 0);
  13. }
  14. int main()
  15. {
  16. try
  17. {
  18. run_tests();
  19. return 0;
  20. }
  21. catch(const std::exception &ex)
  22. {
  23. std::cerr << ex.what() << '\n';
  24. }
  25. return 1;
  26. }