2017-07-15 12:44:50 +05:30
|
|
|
#include "oopless-parser.hpp"
|
|
|
|
#include "catch.hpp"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iterator>
|
|
|
|
#include <sstream>
|
|
|
|
|
2017-07-17 13:17:41 +05:30
|
|
|
std::vector<TFace> getfaces(const std::string &test) {
|
|
|
|
using namespace std;
|
|
|
|
stringstream ss;
|
|
|
|
ss << test;
|
|
|
|
return parse_face<stringstream>(ss);
|
2017-07-15 12:44:50 +05:30
|
|
|
}
|
|
|
|
|
2017-07-15 13:56:03 +05:30
|
|
|
TEST_CASE ("face parsing case: faces with 3 indices", "[Parser]" ) {
|
2017-07-17 13:17:41 +05:30
|
|
|
std::string sample = " 0.000000 0.000000 1.000000 1.000000 0.000000 6 0 7 0xff727278 common/materials/stone/stone";
|
|
|
|
struct TFace f = getfaces(sample).front();
|
|
|
|
REQUIRE (f.m_Indices.size() == 3);
|
2017-07-15 12:44:50 +05:30
|
|
|
}
|
|
|
|
|
2017-07-15 13:56:03 +05:30
|
|
|
TEST_CASE ("face parsing case: faces with 4 indices", "[Parser]") {
|
2017-07-17 13:17:41 +05:30
|
|
|
std::string sample = " 0.000000 0.000000 1.000000 1.000000 0.000000 3 1 0 4 0xffffffff common/materials/metal/aluminum";
|
|
|
|
struct TFace f = getfaces(sample).front();
|
|
|
|
REQUIRE (f.m_Indices.size() == 4);
|
2017-07-15 12:44:50 +05:30
|
|
|
}
|
|
|
|
|
2017-07-15 13:56:03 +05:30
|
|
|
TEST_CASE ("face parsing case: faces with 5 indices", "[Parser]") {
|
2017-07-17 13:17:41 +05:30
|
|
|
std::string sample = " 0.000000 0.000000 1.000000 1.000000 0.000000 2 7 5 7 4 0xff727278 common/materials/stone/stone";
|
|
|
|
struct TFace f = getfaces(sample).front();
|
|
|
|
REQUIRE (f.m_Indices.size() == 5);
|
2017-07-15 12:44:50 +05:30
|
|
|
}
|
|
|
|
|
2017-07-17 13:17:41 +05:30
|
|
|
TEST_CASE ("face parsing case: faces with 9 indices", "[Parser]") {
|
|
|
|
std::string sample = " 0.000000 0.000000 1.000000 1.000000 0.000000 2 7 5 7 4 7 5 7 4 0xff727278 common/materials/stone/stone";
|
|
|
|
struct TFace f = getfaces(sample).front();
|
|
|
|
REQUIRE (f.m_Indices.size() == 9);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("face parsing case: faces with no material", "[Parser]") {
|
|
|
|
std::string sample =
|
|
|
|
" 0.000000 0.000000 1.000000 1.000000 0.000000 1 0 4 5 0x00000000 ";
|
|
|
|
std::string answer; //empty string
|
|
|
|
struct TFace f = getfaces(sample).front();
|
|
|
|
REQUIRE (f.m_Material == answer);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("face parsing case: face's material name is preserved", "[Parser]") {
|
|
|
|
std::string sample =
|
|
|
|
" 0.000000 0.000000 1.000000 1.000000 0.000000 3 1 0 4 0xffffffff common/materials/metal/aluminum";
|
|
|
|
std::string answer = "common/materials/metal/aluminum";
|
|
|
|
struct TFace f = getfaces(sample).front();
|
|
|
|
REQUIRE (f.m_Material == answer);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("face parsing case: face's color code is preserved", "[Parser]") {
|
|
|
|
std::string sample =
|
|
|
|
" 0.000000 0.000000 1.000000 1.000000 0.000000 2 4 1 5 0xffa5a5a5 common/materials/metal/p_metal3";
|
|
|
|
std::string answer = "0xffa5a5a5";
|
|
|
|
struct TFace f = getfaces(sample).front();
|
|
|
|
REQUIRE (f.hex == answer);
|
|
|
|
}
|