diff --git a/ReflexToQ3/test/catch-parser.cpp b/ReflexToQ3/test/catch-parser.cpp index 47792c5..d254ed3 100644 --- a/ReflexToQ3/test/catch-parser.cpp +++ b/ReflexToQ3/test/catch-parser.cpp @@ -1,8 +1,6 @@ #include "oopless-parser.hpp" #include "catch.hpp" -#include -#include -#include +#include std::vector getfaces(const std::string &test) { using namespace std; @@ -58,3 +56,34 @@ TEST_CASE("face parsing case: face's color code is preserved", "[Parser]") { struct TFace f = getfaces(sample).front(); REQUIRE (f.hex == answer); } + +TEST_CASE("brush parser case: returns populated Vertices and Faces list", "[Parser]") { + std::string sample = " vertices\n\ + -23.000000 -20.000000 15.000000\n\ + 9.000000 -20.000000 15.000000\n\ + 9.000000 -20.000000 -17.000000\n\ + -15.000000 -24.000000 -9.000000\n\ + -23.000000 -20.000000 -17.000000\n\ + 1.000000 -24.000000 7.000000\n\ + 1.000000 -24.000000 -9.000000\n\ + -15.000000 -24.000000 7.000000\n\ + faces\n\ + 0.000000 0.000000 1.000000 1.000000 0.000000 0 1 2 4 0xff888888 common/materials/metal/p_metal3\n\ + 0.000000 0.000000 1.000000 1.000000 0.000000 3 4 2 6 0xff888888 common/materials/metal/p_metal3\n\ + 0.000000 0.000000 1.000000 1.000000 0.000000 2 1 5 6 0xff888888 common/materials/metal/p_metal3\n\ + 0.000000 0.000000 1.000000 1.000000 0.000000 0 4 3 7 0xff888888 common/materials/metal/p_metal3\n\ + 0.000000 0.000000 1.000000 1.000000 131.810318 5 1 0 7 0xff888888 common/materials/metal/p_metal3\n\ + 0.000000 0.000000 1.000000 1.000000 0.000000 3 6 5 7 0xff888888 common/materials/metal/p_metal3"; + std::stringstream ss; + ss << sample; + struct TBrush b = parse_brush(ss); + REQUIRE ((b.m_Vertices.size() == 8 && b.m_Faces.size() == 6)); +} + +TEST_CASE("brush parser case: returns empty when given empty input", "[Parser]") { + std::string empty; + std::stringstream ss; + ss << empty; + struct TBrush b = parse_brush(ss); + REQUIRE ((b.m_Vertices.size() == 0 && b.m_Faces.size() == 0)); +}