posix_add_trailing_slash.cpp 519 B

1234567891011121314151617181920212223242526272829
  1. #include<__vic/posix/fs.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. void run_tests()
  6. {
  7. std::string path("/a/b");
  8. __vic::posix::add_trailing_slash(path);
  9. assert(*path.rbegin() == '/');
  10. assert(__vic::posix::with_trailing_slash("/a") == "/a/");
  11. assert(__vic::posix::with_trailing_slash("/a/") == "/a/");
  12. }
  13. int main()
  14. {
  15. try
  16. {
  17. run_tests();
  18. return 0;
  19. }
  20. catch(const std::exception &ex)
  21. {
  22. std::cerr << ex.what() << '\n';
  23. }
  24. return 1;
  25. }