Add unit test for parsing 'l'.

This commit is contained in:
Syoyo Fujita
2018-07-25 21:42:23 +09:00
parent 0d68262246
commit fd06fa49e4
2 changed files with 33 additions and 0 deletions

16
models/line-prim.obj Normal file
View File

@@ -0,0 +1,16 @@
mtllib cube.mtl
v 0.000000 2.000000 2.000000
v 0.000000 0.000000 2.000000
v 2.000000 0.000000 2.000000
v 2.000000 2.000000 2.000000
v 0.000000 2.000000 0.000000
v 0.000000 0.000000 0.000000
v 2.000000 0.000000 0.000000
v 2.000000 2.000000 0.000000
# 8 vertices
g g0
usemtl white
l 1 2 3 4
l 5 6 7

View File

@@ -790,6 +790,23 @@ TEST_CASE("Empty mtl basedir", "[Issue177]") {
REQUIRE(true == ret);
}
TEST_CASE("line-primitive", "[line]") {
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err;
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "../models/line-prim.obj", gMtlBasePath);
if (!err.empty()) {
std::cerr << "[line] " << err << std::endl;
}
REQUIRE(true == ret);
REQUIRE(1 == shapes.size());
REQUIRE(6 == shapes[0].path.indices.size());
}
// Fuzzer test.
// Just check if it does not crash.
// Disable by default since Windows filesystem can't create filename of afl testdata