Added test cases using catch for reflex map parser

This commit is contained in:
2017-07-15 00:14:50 -07:00
parent c2fc685cb4
commit e17e13372c
8 changed files with 80 additions and 34 deletions

View File

@ -1,7 +0,0 @@
0.000000 0.000000 1.000000 1.000000 0.000000 5 2 7 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 6 5 7 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 3 1 0 4 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 0 1 2 5 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 4 0 5 6 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 2 1 3 7 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 3 4 6 7 0xffffffff common/materials/metal/aluminum"

View File

@ -1,5 +0,0 @@
0.000000 0.000000 1.000000 1.000000 0.000000 2 0 4 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 1 3 5 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 0 3 1 4 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 3 0 2 5 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 2 4 1 5 0xffa5a5a5 common/materials/metal/p_metal3

View File

@ -1,11 +0,0 @@
0.000000 0.000000 1.000000 1.000000 0.000000 1 0 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 1 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 1 2 5 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 1 5 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 4 0 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 5 2 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 5 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 1 3 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 2 1 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 6 2 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 4 6 7 0xff727278 common/materials/stone/stone"

View File

@ -0,0 +1,16 @@
0.000000 0.000000 1.000000 1.000000 0.000000 5 2 7 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 6 5 7 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 1 2 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 1 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 3 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 4 2 5 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 4 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 4 5 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 5 2 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 2 0 4 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 1 3 5 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 1 0 3 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 0 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 4 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 6 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 6 0 7 0xff727278 common/materials/stone/stone

View File

@ -0,0 +1,10 @@
0.000000 0.000000 1.000000 1.000000 0.000000 3 1 0 4 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 0 1 2 5 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 4 0 5 6 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 2 1 3 7 0xffffffff common/materials/metal/aluminum
0.000000 0.000000 1.000000 1.000000 0.000000 3 4 6 7 0xffffffff common/materials/metal/aluminum"
0.000000 0.000000 1.000000 1.000000 0.000000 0 3 1 4 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 3 0 2 5 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 2 4 1 5 0xffa5a5a5 common/materials/metal/p_metal3
0.000000 0.000000 1.000000 1.000000 0.000000 0 1 2 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 2 1 3 7 0xff727278 common/materials/stone/stone

View File

@ -1,8 +0,0 @@
0.000000 0.000000 1.000000 1.000000 0.000000 1 2 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 1 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 3 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 4 2 5 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 4 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 4 5 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 5 2 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 6 2 1 3 0xff727278 common/materials/stone/stone

View File

@ -1,8 +1,7 @@
0.000000 0.000000 1.000000 1.000000 0.000000 2 7 5 7 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 6 2 1 3 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 1 0 3 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 0 6 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 4 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 3 6 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 6 0 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 0 1 2 4 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 2 1 3 7 0xff727278 common/materials/stone/stone
0.000000 0.000000 1.000000 1.000000 0.000000 2 7 5 7 4 0xff727278 common/materials/stone/stone

View File

@ -0,0 +1,52 @@
#include "oopless-parser.hpp"
#include "catch.hpp"
#include <iostream>
#include <algorithm>
#include <iterator>
#include <sstream>
using namespace std;
vector<string> 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<string> output;
string data;
while (getline(fin, data)) {
output.push_back(data);
}
return output;
}
bool test_parseface(const string &filename, const int &cnt_indices) {
vector<string> test = readin(filename);
stringstream ss;
copy(test.begin(), test.end(), ostream_iterator<string>(ss, "\n"));
vector<TFace> x = parse_face<stringstream>(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);
}