ソースを参照

Introduce simple export test for assbin.

Kim Kulling 7 年 前
コミット
081365df48
2 ファイル変更17 行追加6 行削除
  1. 9 5
      code/AssbinLoader.cpp
  2. 8 1
      test/unit/utAssbinImportExport.cpp

+ 9 - 5
code/AssbinLoader.cpp

@@ -188,13 +188,17 @@ aiQuatKey Read<aiQuatKey>(IOStream * stream)
 }
 
 template <typename T>
-void ReadArray(IOStream * stream, T * out, unsigned int size)
-{
-    for (unsigned int i=0; i<size; i++) out[i] = Read<T>(stream);
+void ReadArray( IOStream *stream, T * out, unsigned int size) {
+    ai_assert( nullptr != stream );
+    ai_assert( nullptr != out );
+
+    for (unsigned int i=0; i<size; i++) {
+        out[i] = Read<T>(stream);
+    }
 }
 
-template <typename T> void ReadBounds( IOStream * stream, T* /*p*/, unsigned int n )
-{
+template <typename T>
+void ReadBounds( IOStream * stream, T* /*p*/, unsigned int n ) {
     // not sure what to do here, the data isn't really useful.
     stream->Seek( sizeof(T) * n, aiOrigin_CUR );
 }

+ 8 - 1
test/unit/utAssbinImportExport.cpp

@@ -54,6 +54,7 @@ public:
     virtual bool importerTest() {
         Assimp::Importer importer;
         const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
+
         Exporter exporter;
         EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "assbin", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.assbin" ) );
         const aiScene *newScene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.assbin", aiProcess_ValidateDataStructure );
@@ -62,6 +63,12 @@ public:
     }
 };
 
-TEST_F( utAssbinImportExport, import3DFromFileTest ) {
+TEST_F( utAssbinImportExport, exportAssbin3DFromFileTest ) {
+    Assimp::Importer importer;
+    const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
+    EXPECT_NE( nullptr, scene );
+}
+
+TEST_F( utAssbinImportExport, import3ExportAssbinDFromFileTest ) {
     EXPECT_TRUE( importerTest() );
 }