Added test cases for brushes.

This commit is contained in:
2017-07-17 22:21:15 -07:00
parent 36f3aa0a1b
commit 3784e2dca8

View File

@ -1,8 +1,6 @@
#include "oopless-parser.hpp"
#include "catch.hpp"
#include <algorithm>
#include <iterator>
#include <sstream>
#include <iostream>
std::vector<TFace> 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<std::stringstream>(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<std::stringstream>(ss);
REQUIRE ((b.m_Vertices.size() == 0 && b.m_Faces.size() == 0));
}