Add unit test for issue 177.

This commit is contained in:
Syoyo Fujita
2018-07-03 18:37:41 +02:00
parent d541711a79
commit 7a88cddefc
3 changed files with 71 additions and 0 deletions

24
tests/issue-177.mtl Normal file
View File

@@ -0,0 +1,24 @@
newmtl white
Ka 0 0 0
Kd 1 1 1
Ks 0 0 0
newmtl red
Ka 0 0 0
Kd 1 0 0
Ks 0 0 0
newmtl green
Ka 0 0 0
Kd 0 1 0
Ks 0 0 0
newmtl blue
Ka 0 0 0
Kd 0 0 1
Ks 0 0 0
newmtl light
Ka 20 20 20
Kd 1 1 1
Ks 0 0 0

31
tests/issue-177.obj Normal file
View File

@@ -0,0 +1,31 @@
mtllib issue-177.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 front cube
usemtl white
f 1 2 3 4
g back cube
# expects white material
f 8 7 6 5
g right cube
usemtl red
f 4 3 7 8
g top cube
usemtl white
f 5 1 4 8
g left cube
usemtl green
f 5 6 2 1
g bottom cube
usemtl white
f 2 6 7 3
# 6 elements

View File

@@ -768,6 +768,22 @@ TEST_CASE("invalid-face-definition", "[face]") {
REQUIRE(0 == shapes[0].mesh.indices.size());
}
TEST_CASE("Empty mtl basedir", "[Issue177]") {
// Win32 spesific?
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, "issue-177.obj");
if (!err.empty()) {
std::cerr << "[Issue177] " << err << std::endl;
}
REQUIRE(true == ret);
}
// Fuzzer test.
// Just check if it does not crash.
// Disable by default since Windows filesystem can't create filename of afl testdata