Skip to content

Commit fd06fa4

Browse files
committed
Add unit test for parsing 'l'.
1 parent 0d68262 commit fd06fa4

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

models/line-prim.obj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
mtllib cube.mtl
2+
3+
v 0.000000 2.000000 2.000000
4+
v 0.000000 0.000000 2.000000
5+
v 2.000000 0.000000 2.000000
6+
v 2.000000 2.000000 2.000000
7+
v 0.000000 2.000000 0.000000
8+
v 0.000000 0.000000 0.000000
9+
v 2.000000 0.000000 0.000000
10+
v 2.000000 2.000000 0.000000
11+
# 8 vertices
12+
13+
g g0
14+
usemtl white
15+
l 1 2 3 4
16+
l 5 6 7

tests/tester.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,23 @@ TEST_CASE("Empty mtl basedir", "[Issue177]") {
790790
REQUIRE(true == ret);
791791
}
792792

793+
TEST_CASE("line-primitive", "[line]") {
794+
tinyobj::attrib_t attrib;
795+
std::vector<tinyobj::shape_t> shapes;
796+
std::vector<tinyobj::material_t> materials;
797+
798+
std::string err;
799+
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "../models/line-prim.obj", gMtlBasePath);
800+
801+
if (!err.empty()) {
802+
std::cerr << "[line] " << err << std::endl;
803+
}
804+
805+
REQUIRE(true == ret);
806+
REQUIRE(1 == shapes.size());
807+
REQUIRE(6 == shapes[0].path.indices.size());
808+
}
809+
793810
// Fuzzer test.
794811
// Just check if it does not crash.
795812
// Disable by default since Windows filesystem can't create filename of afl testdata

0 commit comments

Comments
 (0)