pathinfo.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include <test_common.h>
  2. #include <igl/pathinfo.h>
  3. #include <string>
  4. #include <vector>
  5. #include <tuple>
  6. TEST_CASE("pathinfo: examples", "[igl]")
  7. {
  8. const std::vector<
  9. std::tuple<std::string,std::string,std::string,std::string,std::string> >
  10. examples =
  11. {
  12. std::make_tuple("/foo" ,"/" ,"foo" ,"" ,"foo"),
  13. std::make_tuple("/foo/" ,"/" ,"foo" ,"" ,"foo"),
  14. std::make_tuple("/foo//" ,"/" ,"foo" ,"" ,"foo"),
  15. std::make_tuple("/foo/./" ,"/foo" ,"." ,"" ,""),
  16. std::make_tuple("/foo/bar" ,"/foo" ,"bar" ,"" ,"bar"),
  17. std::make_tuple("/foo/bar." ,"/foo" ,"bar." ,"" ,"bar"),
  18. std::make_tuple("/foo/bar.txt" ,"/foo" ,"bar.txt" ,"txt","bar"),
  19. std::make_tuple("/foo/bar.txt.zip" ,"/foo" ,"bar.txt.zip","zip","bar.txt"),
  20. std::make_tuple("/foo/bar.dir/" ,"/foo" ,"bar.dir" ,"dir","bar"),
  21. std::make_tuple("/foo/bar.dir/file" ,"/foo/bar.dir","file" ,"" ,"file"),
  22. std::make_tuple("/foo/bar.dir/file.txt","/foo/bar.dir","file.txt" ,"txt","file")
  23. };
  24. for(const auto & example : examples)
  25. {
  26. std::string d,b,e,f;
  27. igl::pathinfo(std::get<0>(example),d,b,e,f);
  28. REQUIRE (d == std::get<1>(example));
  29. REQUIRE (b == std::get<2>(example));
  30. REQUIRE (e == std::get<3>(example));
  31. REQUIRE (f == std::get<4>(example));
  32. }
  33. }