path_to_edges.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <test_common.h>
  2. #include <igl/path_to_edges.h>
  3. #include <vector>
  4. TEST_CASE("igl_path_to_edges: basic_test", "[igl]")
  5. {
  6. const Eigen::VectorXi I = (Eigen::VectorXi(6)<<0,1,2,3,4,5).finished();
  7. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(5,2)<<0,1, 1,2, 2,3, 3,4, 4,5).finished();
  8. Eigen::MatrixXi Eactual;
  9. igl::path_to_edges(I, Eactual);
  10. test_common::assert_eq(Eactual, Eexpected);
  11. }
  12. #include <iostream>
  13. TEST_CASE("igl_path_to_edges: loop_test", "[igl]")
  14. {
  15. const Eigen::VectorXi I = (Eigen::VectorXi(6)<<0,1,2,3,4,5).finished();
  16. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(6,2)<<0,1, 1,2, 2,3, 3,4, 4,5, 5,0).finished();
  17. Eigen::MatrixXi Eactual;
  18. const bool make_loop = true;
  19. igl::path_to_edges(I, Eactual, make_loop);
  20. test_common::assert_eq(Eactual, Eexpected);
  21. }
  22. TEST_CASE("igl_path_to_edges: vector_basic_test", "[igl]")
  23. {
  24. const std::vector<int> I{0,1,2,3,4,5};
  25. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(5,2)<<0,1, 1,2, 2,3, 3,4, 4,5).finished();
  26. Eigen::MatrixXi Eactual;
  27. igl::path_to_edges(I, Eactual);
  28. test_common::assert_eq(Eactual, Eexpected);
  29. }
  30. TEST_CASE("igl_path_to_edges: vector_loop_test", "[igl]")
  31. {
  32. const std::vector<int> I{0,1,2,3,4,5};
  33. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(6,2)<<0,1, 1,2, 2,3, 3,4, 4,5, 5,0).finished();
  34. Eigen::MatrixXi Eactual;
  35. const bool make_loop = true;
  36. igl::path_to_edges(I, Eactual, make_loop);
  37. test_common::assert_eq(Eactual, Eexpected);
  38. }