guess_extension.cpp 782 B

123456789101112131415161718192021222324252627282930
  1. #include <test_common.h>
  2. #include <igl/guess_extension.h>
  3. #include <igl/pathinfo.h>
  4. #include <cstdio>
  5. class guess_extension : public ::testing::TestWithParam<std::string> {};
  6. TEST_P(guess_extension, all_meshes)
  7. {
  8. Eigen::MatrixXd V;
  9. Eigen::MatrixXi F;
  10. std::string path(test_common::data_path(GetParam()));
  11. // Load example mesh: GetParam() will be name of mesh file
  12. std::string d,b,e,f;
  13. igl::pathinfo(path,d,b,e,f);
  14. // Convert extension to lower case
  15. std::transform(e.begin(), e.end(), e.begin(), ::tolower);
  16. FILE * fp = fopen(path.c_str(),"r");
  17. std::string guess = igl::guess_extension(fp);
  18. ASSERT_EQ(guess,e);
  19. }
  20. INSTANTIATE_TEST_CASE_P
  21. (
  22. all_meshes,
  23. guess_extension,
  24. ::testing::ValuesIn(test_common::all_meshes()),
  25. test_common::string_test_name
  26. );