#include "oopless-parser.hpp" #include "catch.hpp" #include #include #include #include using namespace std; vector readin(const string &filename, const int ln = 0) { ifstream fin; fin.open(filename); if (!fin.good()) { cerr << "error: can not open file with test cases." << endl; } vector output; string data; while (getline(fin, data)) { output.push_back(data); } return output; } bool test_parseface(const string &filename, const int &cnt_indices) { vector test = readin(filename); stringstream ss; copy(test.begin(), test.end(), ostream_iterator(ss, "\n")); 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 " ) { bool k = test_parseface("cases-faces/parser-face-3indices.txt", 3); REQUIRE (k == true); } TEST_CASE ("face parsing case: faces with 4 indices ") { bool k = test_parseface("cases-faces/parser-face-4indices.txt", 4); REQUIRE (k == true); } TEST_CASE ("face parsing case: faces with 5 indices ") { bool k = test_parseface("cases-faces/parser-face-5indices.txt", 5); REQUIRE (k == true); }