Skip to content

Commit c392794

Browse files
committed
Add more Python tests
1 parent af5bb21 commit c392794

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

python/tests/tinyobjloader_tests/test_loader.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,67 @@ def test_numpy_face_vertices_mixed_arity_with_triangulate():
108108

109109
# Test.
110110
np.testing.assert_array_equal(shape.mesh.numpy_num_face_vertices(), expected_num_face_vertices)
111+
112+
113+
def test_numpy_index_array_two_quads():
114+
"""
115+
Test for https://github.com/tinyobjloader/tinyobjloader/issues/401
116+
"""
117+
118+
# Set up.
119+
loader = Loader(triangulate=False)
120+
loader.loads(TWO_QUADS)
121+
122+
shapes = loader.shapes
123+
assert len(shapes) == 1
124+
125+
# Confidence check.
126+
(shape,) = shapes
127+
expected_vertex_index = [0, 1, 2, 3, 4, 5, 6, 7]
128+
assert [x.vertex_index for x in shape.mesh.indices] == expected_vertex_index
129+
130+
# Test.
131+
expected_numpy_indices = [0, -1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, 5, -1, -1, 6, -1, -1, 7, -1, -1]
132+
np.testing.assert_array_equal(shape.mesh.numpy_indices(), expected_numpy_indices)
133+
134+
135+
def test_numpy_vertex_array_two_quads():
136+
"""
137+
Test for https://github.com/tinyobjloader/tinyobjloader/issues/401
138+
"""
139+
140+
# Set up.
141+
loader = Loader(triangulate=False)
142+
loader.loads(TWO_QUADS)
143+
144+
# Confidence check.
145+
expected_vertices = [
146+
0.0,
147+
0.0,
148+
0.0,
149+
0.0,
150+
0.0,
151+
0.0,
152+
0.0,
153+
0.0,
154+
0.0,
155+
0.0,
156+
0.0,
157+
0.0,
158+
46.367584,
159+
82.676086,
160+
8.867414,
161+
46.524185,
162+
82.81955,
163+
8.825487,
164+
46.59864,
165+
83.086678,
166+
8.88121,
167+
46.461926,
168+
82.834091,
169+
8.953863,
170+
]
171+
assert loader.attrib.vertices == expected_vertices
172+
173+
# Test.
174+
np.testing.assert_array_equal(loader.attrib.numpy_vertices(), expected_vertices)

0 commit comments

Comments
 (0)