#include "oopless-parser.hpp" #include "catch.hpp" #include #include #include #include std::vector readin(const std::string &filename, const int ln = 0) { std::ifstream fin; fin.open(filename); if (!fin.good()) { std::cerr << "error: can not open file with test cases." << std::endl; } std::vector output; std::string data; while (getline(fin, data)) { output.push_back(data); } return output; } bool test_parseface(const std::string &filename, const int &cnt_indices) { std::vector test = readin(filename); std::stringstream ss; copy(test.begin(), test.end(), std::ostream_iterator(ss, "\n")); std::vector x = parse_face(ss); bool is_ok = true; for (struct TFace face : x) { if (face.m_Indices.size() != cnt_indices) { is_ok = false; break; } } return is_ok; } TEST_CASE ("face parsing case: faces with 3 indices", "[Parser]" ) { bool k = test_parseface("ReflexToQ3/test/cases-face/parser-face-3indices.txt", 3); REQUIRE (k == true); } TEST_CASE ("face parsing case: faces with 4 indices", "[Parser]") { bool k = test_parseface("ReflexToQ3/test/cases-face/parser-face-4indices.txt", 4); REQUIRE (k == true); } TEST_CASE ("face parsing case: faces with 5 indices", "[Parser]") { bool k = test_parseface("ReflexToQ3/test/cases-face/parser-face-5indices.txt", 5); REQUIRE (k == true); }