@@ -858,6 +858,50 @@ void test_zero_face_idx_value_issue140() {
858858 TEST_CHECK (!err.empty ());
859859}
860860
861+ void test_invalid_relative_vertex_index () {
862+ tinyobj::attrib_t attrib;
863+ std::vector<tinyobj::shape_t > shapes;
864+ std::vector<tinyobj::material_t > materials;
865+
866+ std::string warn;
867+ std::string err;
868+ bool ret =
869+ tinyobj::LoadObj (&attrib, &shapes, &materials, &warn, &err,
870+ " ../models/invalid-relative-vertex-index.obj" , gMtlBasePath );
871+
872+ if (!warn.empty ()) {
873+ std::cout << " WARN: " << warn << std::endl;
874+ }
875+
876+ if (!err.empty ()) {
877+ std::cerr << " ERR: " << err << std::endl;
878+ }
879+ TEST_CHECK (false == ret);
880+ TEST_CHECK (!err.empty ());
881+ }
882+
883+ void test_invalid_texture_vertex_index () {
884+ tinyobj::attrib_t attrib;
885+ std::vector<tinyobj::shape_t > shapes;
886+ std::vector<tinyobj::material_t > materials;
887+
888+ std::string warn;
889+ std::string err;
890+ bool ret =
891+ tinyobj::LoadObj (&attrib, &shapes, &materials, &warn, &err,
892+ " ../models/invalid-relative-texture-vertex-index.obj" , gMtlBasePath );
893+
894+ if (!warn.empty ()) {
895+ std::cout << " WARN: " << warn << std::endl;
896+ }
897+
898+ if (!err.empty ()) {
899+ std::cerr << " ERR: " << err << std::endl;
900+ }
901+ TEST_CHECK (false == ret);
902+ TEST_CHECK (!err.empty ());
903+ }
904+
861905void test_texture_name_whitespace_issue145 () {
862906 tinyobj::attrib_t attrib;
863907 std::vector<tinyobj::shape_t > shapes;
@@ -1467,4 +1511,8 @@ TEST_LIST = {
14671511 test_mtl_filename_with_whitespace_issue46},
14681512 {" test_face_missing_issue295" ,
14691513 test_face_missing_issue295},
1514+ {" test_invalid_relative_vertex_index" ,
1515+ test_invalid_relative_vertex_index},
1516+ {" test_invalid_texture_vertex_index" ,
1517+ test_invalid_texture_vertex_index},
14701518 {NULL , NULL }};
0 commit comments