Included catch-parser.cpp in catch.cpp

This commit is contained in:
suhrke 2017-07-15 01:26:03 -07:00
parent 77ae309e3b
commit faf4d96ef3
3 changed files with 20 additions and 20 deletions

View File

@ -35,5 +35,5 @@ EntityConverter.o: includes/EntityConverter.cpp
$(CC) -c $^ $(CFLAGS) $(CC) -c $^ $(CFLAGS)
clean: clean:
rm *.o *.log $(EX) $(TESTEX) rm *.o *.log $(EX)

View File

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

View File

@ -3,7 +3,7 @@
* *
* Filename: catch.cpp * Filename: catch.cpp
* *
* Description: Unit Tests for EntityConverter * Description: Unit Tests using the Catch framework
* *
* Version: 1.0 * Version: 1.0
* Created: 07/03/2017 08:25:04 PM * Created: 07/03/2017 08:25:04 PM
@ -18,6 +18,7 @@
#ifndef CATCH_CONFIG_MAIN #ifndef CATCH_CONFIG_MAIN
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include "catch.hpp" #include "catch.hpp"
#include "catch-parser.cpp"
#include <cmath> #include <cmath>
#include <queue> #include <queue>
#include <vector> #include <vector>