From e17e13372c1db3a1d05be48114c9b1c4cb7bd7d6 Mon Sep 17 00:00:00 2001 From: <> Date: Sat, 15 Jul 2017 00:14:50 -0700 Subject: [PATCH] Added test cases using catch for reflex map parser --- .../cases-face/parser-face-3indices-0.txt | 7 --- .../cases-face/parser-face-3indices-1.txt | 5 -- .../cases-face/parser-face-3indices-2.txt | 11 ---- .../test/cases-face/parser-face-3indices.txt | 16 ++++++ .../test/cases-face/parser-face-4indices.txt | 10 ++++ .../cases-face/parser-face-5indices-0.txt | 8 --- ...indices-1.txt => parser-face-5indices.txt} | 5 +- ReflexToQ3/test/catch-parser.cpp | 52 +++++++++++++++++++ 8 files changed, 80 insertions(+), 34 deletions(-) delete mode 100644 ReflexToQ3/test/cases-face/parser-face-3indices-0.txt delete mode 100644 ReflexToQ3/test/cases-face/parser-face-3indices-1.txt delete mode 100644 ReflexToQ3/test/cases-face/parser-face-3indices-2.txt create mode 100644 ReflexToQ3/test/cases-face/parser-face-3indices.txt create mode 100644 ReflexToQ3/test/cases-face/parser-face-4indices.txt delete mode 100644 ReflexToQ3/test/cases-face/parser-face-5indices-0.txt rename ReflexToQ3/test/cases-face/{parser-face-5indices-1.txt => parser-face-5indices.txt} (70%) create mode 100644 ReflexToQ3/test/catch-parser.cpp diff --git a/ReflexToQ3/test/cases-face/parser-face-3indices-0.txt b/ReflexToQ3/test/cases-face/parser-face-3indices-0.txt deleted file mode 100644 index 12dfa18..0000000 --- a/ReflexToQ3/test/cases-face/parser-face-3indices-0.txt +++ /dev/null @@ -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" \ No newline at end of file diff --git a/ReflexToQ3/test/cases-face/parser-face-3indices-1.txt b/ReflexToQ3/test/cases-face/parser-face-3indices-1.txt deleted file mode 100644 index 11fd47d..0000000 --- a/ReflexToQ3/test/cases-face/parser-face-3indices-1.txt +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ReflexToQ3/test/cases-face/parser-face-3indices-2.txt b/ReflexToQ3/test/cases-face/parser-face-3indices-2.txt deleted file mode 100644 index b86a57c..0000000 --- a/ReflexToQ3/test/cases-face/parser-face-3indices-2.txt +++ /dev/null @@ -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" \ No newline at end of file diff --git a/ReflexToQ3/test/cases-face/parser-face-3indices.txt b/ReflexToQ3/test/cases-face/parser-face-3indices.txt new file mode 100644 index 0000000..21b5c87 --- /dev/null +++ b/ReflexToQ3/test/cases-face/parser-face-3indices.txt @@ -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 \ No newline at end of file diff --git a/ReflexToQ3/test/cases-face/parser-face-4indices.txt b/ReflexToQ3/test/cases-face/parser-face-4indices.txt new file mode 100644 index 0000000..04ec09d --- /dev/null +++ b/ReflexToQ3/test/cases-face/parser-face-4indices.txt @@ -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 diff --git a/ReflexToQ3/test/cases-face/parser-face-5indices-0.txt b/ReflexToQ3/test/cases-face/parser-face-5indices-0.txt deleted file mode 100644 index c507c0c..0000000 --- a/ReflexToQ3/test/cases-face/parser-face-5indices-0.txt +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ReflexToQ3/test/cases-face/parser-face-5indices-1.txt b/ReflexToQ3/test/cases-face/parser-face-5indices.txt similarity index 70% rename from ReflexToQ3/test/cases-face/parser-face-5indices-1.txt rename to ReflexToQ3/test/cases-face/parser-face-5indices.txt index df6b30a..24c3eda 100644 --- a/ReflexToQ3/test/cases-face/parser-face-5indices-1.txt +++ b/ReflexToQ3/test/cases-face/parser-face-5indices.txt @@ -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 \ No newline at end of file diff --git a/ReflexToQ3/test/catch-parser.cpp b/ReflexToQ3/test/catch-parser.cpp new file mode 100644 index 0000000..431650c --- /dev/null +++ b/ReflexToQ3/test/catch-parser.cpp @@ -0,0 +1,52 @@ +#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); +} +