Skip to content

Commit

Permalink
Merge pull request #2318 from assimp/issue_2297
Browse files Browse the repository at this point in the history
closes #2297: introduce obj-un…
  • Loading branch information
kimkulling committed Feb 3, 2019
2 parents 475e51d + acc8826 commit 6c4fde7
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions test/unit/utObjImportExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static const float VertComponents[ 24 * 3 ] = {
0.500000, -0.500000, 0.500000f
};

static const std::string ObjModel =
static const char *ObjModel =
"o 1\n"
"\n"
"# Vertex list\n"
Expand All @@ -105,7 +105,7 @@ static const std::string ObjModel =
"\n"
"# End of file\n";

static const std::string ObjModel_Issue1111 =
static const char *ObjModel_Issue1111 =
"o 1\n"
"\n"
"# Vertex list\n"
Expand Down Expand Up @@ -231,7 +231,7 @@ TEST_F( utObjImportExport, exportObjFromFileTest ) {
#endif // ASSIMP_BUILD_NO_EXPORT

TEST_F( utObjImportExport, obj_import_test ) {
const aiScene *scene = m_im->ReadFileFromMemory( (void*) ObjModel.c_str(), ObjModel.size(), 0 );
const aiScene *scene = m_im->ReadFileFromMemory( (void*) ObjModel, strlen(ObjModel), 0 );
aiScene *expected = createScene();
EXPECT_NE( nullptr, scene );

Expand All @@ -252,7 +252,7 @@ TEST_F( utObjImportExport, obj_import_test ) {
}

TEST_F( utObjImportExport, issue1111_no_mat_name_Test ) {
const aiScene *scene = m_im->ReadFileFromMemory( ( void* ) ObjModel_Issue1111.c_str(), ObjModel_Issue1111.size(), 0 );
const aiScene *scene = m_im->ReadFileFromMemory( ( void* ) ObjModel_Issue1111, strlen(ObjModel_Issue1111), 0 );
EXPECT_NE( nullptr, scene );
}

Expand Down Expand Up @@ -290,7 +290,7 @@ TEST_F( utObjImportExport, issue1923_vertex_color_Test ) {
}

TEST_F( utObjImportExport, issue1453_segfault ) {
static const std::string ObjModel =
static const char *ObjModel =
"v 0.0 0.0 0.0\n"
"v 0.0 0.0 1.0\n"
"v 0.0 1.0 0.0\n"
Expand All @@ -301,20 +301,20 @@ TEST_F( utObjImportExport, issue1453_segfault ) {
"v 1.0 1.0 1.0\nB";

Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory( ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure );
const aiScene *scene = myimporter.ReadFileFromMemory( ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure );
EXPECT_EQ( nullptr, scene );
}

TEST_F(utObjImportExport, relative_indices_Test) {
static const std::string ObjModel =
static const char *ObjModel =
"v -0.500000 0.000000 0.400000\n"
"v -0.500000 0.000000 -0.800000\n"
"v -0.500000 1.000000 -0.800000\n"
"v -0.500000 1.000000 0.400000\n"
"f -4 -3 -2 -1\nB";

Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);

EXPECT_EQ(scene->mNumMeshes, 1U);
Expand All @@ -331,14 +331,14 @@ TEST_F(utObjImportExport, relative_indices_Test) {
}

TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
static const std::string ObjModel =
static const char *ObjModel =
"v -0.500000 0.000000 0.400000 0.50000\n"
"v -0.500000 0.000000 -0.800000 1.00000\n"
"v 0.500000 1.000000 -0.800000 0.5000\n"
"f 1 2 3\nB";

Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);

EXPECT_EQ(scene->mNumMeshes, 1U);
Expand All @@ -354,26 +354,26 @@ TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
}

TEST_F(utObjImportExport, homogeneous_coordinates_divide_by_zero_Test) {
static const std::string ObjModel =
static const char *ObjModel =
"v -0.500000 0.000000 0.400000 0.\n"
"v -0.500000 0.000000 -0.800000 1.00000\n"
"v 0.500000 1.000000 -0.800000 0.5000\n"
"f 1 2 3\nB";

Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
EXPECT_EQ(nullptr, scene);
}

TEST_F(utObjImportExport, 0based_array_Test) {
static const std::string ObjModel =
static const char *ObjModel =
"v -0.500000 0.000000 0.400000\n"
"v -0.500000 0.000000 -0.800000\n"
"v -0.500000 1.000000 -0.800000\n"
"f 0 1 2\nB";

Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), 0);
Assimp::Importer myImporter;
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
EXPECT_EQ(nullptr, scene);
}

Expand All @@ -396,3 +396,8 @@ TEST_F(utObjImportExport, import_point_cloud) {
ASSERT_NE(nullptr, scene);
}

TEST_F(utObjImportExport, import_without_linend) {
Assimp::Importer myImporter;
const aiScene *scene = myImporter.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/box_without_lineending.obj", 0);
ASSERT_NE(nullptr, scene);
}

0 comments on commit 6c4fde7

Please sign in to comment.