소스 검색

Added unit test for SharedPostProcessInfo

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@165 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 17 년 전
부모
커밋
832f9cf672
2개의 변경된 파일98개의 추가작업 그리고 0개의 파일을 삭제
  1. 59 0
      test/unit/utSharedPPData.cpp
  2. 39 0
      test/unit/utSharedPPData.h

+ 59 - 0
test/unit/utSharedPPData.cpp

@@ -0,0 +1,59 @@
+
+#include "utSharedPPData.h"
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION (SharedPPDataTest);
+
+static bool destructed;
+
+struct TestType
+{
+	~TestType()
+	{
+		destructed = true;
+	}
+};
+
+void SharedPPDataTest :: setUp (void)
+{
+	shared = new SharedPostProcessInfo();
+	destructed = false;
+}
+
+void SharedPPDataTest :: tearDown (void)
+{
+	
+}
+
+void  SharedPPDataTest :: testPODProperty (void)
+{
+	int i = 5;
+	shared->AddProperty("test",i);
+	int o;
+	CPPUNIT_ASSERT(shared->GetProperty("test",o) && 5 == o);
+	CPPUNIT_ASSERT(!shared->GetProperty("test2",o) && 5 == o);
+
+	float f = 12.f, m;
+	shared->AddProperty("test",f);
+	CPPUNIT_ASSERT(shared->GetProperty("test",m) && 12.f == m);
+}
+
+void  SharedPPDataTest :: testPropertyPointer (void)
+{
+	int *i = new int[35];
+	shared->AddProperty("test16",i);
+	int* o;
+	CPPUNIT_ASSERT(shared->GetProperty("test16",o) && o == i);
+	shared->RemoveProperty("test16");
+	CPPUNIT_ASSERT(!shared->GetProperty("test16",o));
+}
+
+void  SharedPPDataTest :: testPropertyDeallocation (void)
+{
+	TestType *out, * pip = new TestType();
+	shared->AddProperty("quak",pip);
+	CPPUNIT_ASSERT(shared->GetProperty("quak",out) && out == pip);
+
+	delete shared;
+	CPPUNIT_ASSERT(destructed);
+}

+ 39 - 0
test/unit/utSharedPPData.h

@@ -0,0 +1,39 @@
+#ifndef TESTPPD_H
+#define TESTPPD_H
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <aiTypes.h>
+#include <aiScene.h>
+#include <BaseProcess.h>
+
+
+using namespace std;
+using namespace Assimp;
+
+class SharedPPDataTest : public CPPUNIT_NS :: TestFixture
+{
+    CPPUNIT_TEST_SUITE (SharedPPDataTest);
+    CPPUNIT_TEST (testPODProperty);
+	CPPUNIT_TEST (testPropertyPointer);
+	CPPUNIT_TEST (testPropertyDeallocation);
+    CPPUNIT_TEST_SUITE_END ();
+
+    public:
+        void setUp (void);
+        void tearDown (void);
+
+    protected:
+
+        void  testPODProperty (void);
+		void  testPropertyPointer (void);
+		void  testPropertyDeallocation (void);
+   
+	private:
+
+		SharedPostProcessInfo* shared;
+	
+};
+
+#endif