From 963d47574808d5b618e3875c544708666aa209b1 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:42:12 +0200 Subject: [PATCH 1/8] Add MD3 importer unit tests --- test/CMakeLists.txt | 1 + test/unit/ImportExport/utMD3Importer.cpp | 73 ++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 test/unit/ImportExport/utMD3Importer.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3d382490c..f5e87b2b6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -129,6 +129,7 @@ SET( IMPORTERS unit/ImportExport/utNFFImportExport.cpp unit/ImportExport/utXGLImportExport.cpp unit/ImportExport/utMD2Importer.cpp + unit/ImportExport/utMD3Importer.cpp unit/ImportExport/utMD5Importer.cpp unit/ImportExport/utMDLImporter.cpp unit/ImportExport/MDL/MDLHL1TestFiles.h diff --git a/test/unit/ImportExport/utMD3Importer.cpp b/test/unit/ImportExport/utMD3Importer.cpp new file mode 100644 index 000000000..212fb6338 --- /dev/null +++ b/test/unit/ImportExport/utMD3Importer.cpp @@ -0,0 +1,73 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" + +#include +#include +#include + + +using namespace Assimp; + + + +TEST(utMD3Importer, importWatercan) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan.md3", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD3Importer, importWatercan_dmg) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan_dmg.md3", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD3Importer, importEuropean_fnt_v2) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt_v2.md3", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From 2875f7fd5f04a5d541b481b867c1de1f636aa961 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:45:40 +0200 Subject: [PATCH 2/8] Refactor XGL unit test --- test/unit/ImportExport/utXGLImportExport.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/unit/ImportExport/utXGLImportExport.cpp b/test/unit/ImportExport/utXGLImportExport.cpp index 89e780e20..8f5c4bdfe 100644 --- a/test/unit/ImportExport/utXGLImportExport.cpp +++ b/test/unit/ImportExport/utXGLImportExport.cpp @@ -42,22 +42,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "UnitTestPCH.h" -#include "AbstractImportExportBase.h" #include #include + using namespace Assimp; -class utXGLImportExport : public AbstractImportExportBase { -public: - virtual bool importerTest() { - Assimp::Importer importer; - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", 0); - return true; - return nullptr != scene; - } -}; -TEST_F(utXGLImportExport, importXGLFromFileTest) { - EXPECT_TRUE(importerTest()); +TEST(utXGLImporter, importSample_official) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); } + From 69284bdef931dc8134be93a0a629b10fcff7115a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:50:11 +0200 Subject: [PATCH 3/8] Add more XGL unit tests --- test/unit/ImportExport/utXGLImportExport.cpp | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/unit/ImportExport/utXGLImportExport.cpp b/test/unit/ImportExport/utXGLImportExport.cpp index 8f5c4bdfe..4cace2904 100644 --- a/test/unit/ImportExport/utXGLImportExport.cpp +++ b/test/unit/ImportExport/utXGLImportExport.cpp @@ -49,9 +49,57 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; +TEST(utXGLImporter, importBCN_Epileptic) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/BCN_Epileptic.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importCubesWithAlpha) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/cubes_with_alpha.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + TEST(utXGLImporter, importSample_official) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", aiProcess_ValidateDataStructure); ASSERT_NE(nullptr, scene); } + +TEST(utXGLImporter, importSample_official_asxml) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official_asxml.xml", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importSphereWithMatGloss) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sphere_with_mat_gloss_10pc.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importSpiderASCII) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Spider_ascii.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importWuson) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Wuson.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importWusonDXF) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/wuson_dxf.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From 461f9923a7a70425d21f51f6903758034254d572 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:09:29 +0200 Subject: [PATCH 4/8] Refactor 3D import unit test --- test/unit/ut3DImportExport.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/test/unit/ut3DImportExport.cpp b/test/unit/ut3DImportExport.cpp index a3a3197cc..2d42d2829 100644 --- a/test/unit/ut3DImportExport.cpp +++ b/test/unit/ut3DImportExport.cpp @@ -42,23 +42,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "UnitTestPCH.h" -#include "SceneDiffer.h" -#include "AbstractImportExportBase.h" #include #include + using namespace Assimp; -class ut3DImportExport : public AbstractImportExportBase { -public: - virtual bool importerTest() { - Assimp::Importer importer; - const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure ); - return nullptr != scene; - } -}; -TEST_F( ut3DImportExport, import3DFromFileTest ) { - EXPECT_TRUE( importerTest() ); +TEST(ut3DImportExport, importBoxA) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); } From 0b776f16cb19c68655e5a135b0300cf190a51ffb Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:22:29 +0200 Subject: [PATCH 5/8] Add more 3D unit tests --- test/unit/ut3DImportExport.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/ut3DImportExport.cpp b/test/unit/ut3DImportExport.cpp index 2d42d2829..922d8c747 100644 --- a/test/unit/ut3DImportExport.cpp +++ b/test/unit/ut3DImportExport.cpp @@ -55,3 +55,17 @@ TEST(ut3DImportExport, importBoxA) { const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure); ASSERT_NE(nullptr, scene); } + + +TEST(ut3DImportExport, importBoxD) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_d.3d", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(ut3DImportExport, importBoxUC) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box.uc", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From c407892c9c3f20ab292a79b0cc4c31c292167fca Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:43:20 +0200 Subject: [PATCH 6/8] Refactor AC unit test --- test/unit/utACImportExport.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/test/unit/utACImportExport.cpp b/test/unit/utACImportExport.cpp index 192de16a0..4bac8bd3b 100644 --- a/test/unit/utACImportExport.cpp +++ b/test/unit/utACImportExport.cpp @@ -42,23 +42,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "UnitTestPCH.h" -#include "SceneDiffer.h" -#include "AbstractImportExportBase.h" #include #include + using namespace Assimp; -class utACImportExport : public AbstractImportExportBase { -public: - virtual bool importerTest() { - Assimp::Importer importer; - const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure ); - return nullptr != scene; - } -}; -TEST_F( utACImportExport, importACFromFileTest ) { - EXPECT_TRUE( importerTest() ); +TEST(utACImportExport, importWuson) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); } + + From d4d19b7062dd1f3d20dd58e3cc76322b09feb9cf Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:48:37 +0200 Subject: [PATCH 7/8] Add more AC unit tests --- test/unit/utACImportExport.cpp | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/unit/utACImportExport.cpp b/test/unit/utACImportExport.cpp index 4bac8bd3b..8a685056d 100644 --- a/test/unit/utACImportExport.cpp +++ b/test/unit/utACImportExport.cpp @@ -50,6 +50,63 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; +TEST(utACImportExport, importClosedLine) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/closedLine.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importNoSurfaces) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/nosurfaces.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importOpenLine) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/openLine.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSampleSubdiv) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/sample_subdiv.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLight) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLightUTF16) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight_UTF16LE.ac", aiProcess_ValidateDataStructure); + // FIXME: this is probably wrong, loading the file should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLightUTF8BOM) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight_UTF8BOM.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLightUvScaling4X) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLightUvScaling4X.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + TEST(utACImportExport, importWuson) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure); @@ -57,3 +114,9 @@ TEST(utACImportExport, importWuson) { } +TEST(utACImportExport, testFormatDetection) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/TestFormatDetection", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + From c2a74c61f40bbf0ea2a9464103fc746f3b039e8b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:56:31 +0200 Subject: [PATCH 8/8] Add more X unit tests --- test/unit/utXImporterExporter.cpp | 77 +++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/test/unit/utXImporterExporter.cpp b/test/unit/utXImporterExporter.cpp index 53e156bcc..15e19cf01 100644 --- a/test/unit/utXImporterExporter.cpp +++ b/test/unit/utXImporterExporter.cpp @@ -67,3 +67,80 @@ TEST_F( utXImporterExporter, heap_overflow_in_tokenizer ) { Assimp::Importer importer; EXPECT_NO_THROW( importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/OV_GetNextToken", 0 ) ); } + + +TEST(utXImporter, importAnimTest) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importBCNEpileptic) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importFromTrueSpaceBin32) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/fromtruespace_bin32.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, import_kwxport_test_cubewithvcolors) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/kwxport_test_cubewithvcolors.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestCubeBinary) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_binary.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestCubeCompressed) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_compressed.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestCubeText) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_text.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestWuson) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, TestFormatDetection) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/TestFormatDetection", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +#if 0 // FIXME: disabled because it leaks memory + + +TEST(utXImporter, importDwarf) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/X/dwarf.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +#endif // 0 +