Browse Source

Cleaned up unit tests so they don't leave any junk around

BearishSun 10 years ago
parent
commit
ceb1efeb29
3 changed files with 26 additions and 30 deletions
  1. 18 15
      BansheeEditor/Source/BsEditorTestSuite.cpp
  2. 7 14
      MBansheeEditor/UnitTests.cs
  3. 1 1
      README.md

+ 18 - 15
BansheeEditor/Source/BsEditorTestSuite.cpp

@@ -167,7 +167,7 @@ namespace BansheeEngine
 	public:
 		friend class TestObjectARTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 	};
 
 	class TestObjectARTTI : public RTTIType < TestObjectA, IReflectable, TestObjectARTTI >
@@ -221,18 +221,18 @@ namespace BansheeEngine
 			BS_ADD_REFLPTR_FIELD_ARR(arrObjPtrB, 15);
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "TestObjectA";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_TestObjectA;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
 			return bs_shared_ptr_new<TestObjectA>();
 		}
@@ -251,18 +251,18 @@ namespace BansheeEngine
 			BS_ADD_PLAIN_FIELD(strA, 1);
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "TestObjectB";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_TestObjectB;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
 			return bs_shared_ptr_new<TestObjectB>();
 		}
@@ -310,7 +310,7 @@ namespace BansheeEngine
 	public:
 		friend class TestComponentCRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 
 	protected:
 		TestComponentC() {} // Serialization only
@@ -338,7 +338,7 @@ namespace BansheeEngine
 	public:
 		friend class TestComponentDRTTI;
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
+		virtual RTTITypeBase* getRTTI() const override;
 
 	protected:
 		TestComponentD() {} // Serialization only
@@ -355,18 +355,18 @@ namespace BansheeEngine
 			BS_ADD_REFL_FIELD(obj, 0);
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "TestComponentC";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_TestComponentC;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
 			return GameObjectRTTI::createGameObject<TestComponentC>();
 		}
@@ -383,18 +383,18 @@ namespace BansheeEngine
 			BS_ADD_REFL_FIELD(obj, 0);
 		}
 
-		virtual const String& getRTTIName()
+		virtual const String& getRTTIName() override
 		{
 			static String name = "TestComponentD";
 			return name;
 		}
 
-		virtual UINT32 getRTTIId()
+		virtual UINT32 getRTTIId() override
 		{
 			return TID_TestComponentD;
 		}
 
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
 		{
 			return GameObjectRTTI::createGameObject<TestComponentD>();
 		}
@@ -473,6 +473,7 @@ namespace BansheeEngine
 		BS_TEST_ASSERT(so0_0->getName() == "so0_0");
 
 		so0_0->destroy();
+		soExternal->destroy();
 	}
 
 	void EditorTestSuite::SceneObjectDelete_UndoRedo()
@@ -516,6 +517,7 @@ namespace BansheeEngine
 		BS_TEST_ASSERT(cmpB1_1->val1 == "InitialValue");
 
 		so0_0->destroy();
+		soExternal->destroy();
 	}
 
 	void EditorTestSuite::BinaryDiff()
@@ -707,6 +709,7 @@ namespace BansheeEngine
 		BS_TEST_ASSERT(ncmp3 != nullptr);
 
 		root->destroy();
+		newRoot->destroy();
 	}
 
 	void EditorTestSuite::TestFrameAlloc()

+ 7 - 14
MBansheeEditor/UnitTests.cs

@@ -93,6 +93,9 @@ namespace BansheeEditor
                 DebugUnit.Assert(otherComponent.listComplex[1].someValue == 99);
                 DebugUnit.Assert(otherComponent.listComplex2[0].anotherValue2 == "ListComplexAnotherValue");
             }
+
+            so.Destroy();
+            otherSO.Destroy();
         }
 
         /// <summary>
@@ -102,28 +105,18 @@ namespace BansheeEditor
         {
             SerializableObject obj = new SerializableObject(typeof(UT1_SerzCls), new UT1_SerzCls());
 
-            Debug.Log(obj.Fields.Length);
-            for (int i = 0; i < obj.Fields.Length; i++)
-            {
-                Debug.Log(i + ". " + obj.Fields[i].Name + " - " + obj.Fields[i].Type.ToString());
-            }
-
             SerializableProperty prop = obj.Fields[0].GetProperty();
-            Debug.Log("Old value: " + prop.GetValue<int>());
-            prop.SetValue<int>(33);
-            Debug.Log("New value: " + prop.GetValue<int>());
+            prop.SetValue(33);
+            DebugUnit.Assert(prop.GetValue<int>() == 33);
 
             SerializableProperty prop2 = obj.Fields[2].GetProperty();
-            Debug.Log("Old value: " + (prop2.GetValue<UT1_SerzCls>() == null));
 
             UT1_SerzCls child = new UT1_SerzCls();
             child.anotherValue2 = "potato";
             prop2.SetValue<UT1_SerzCls>(child);
 
-            if (prop2.GetValue<UT1_SerzCls>() == null)
-                Debug.Log("New value: null");
-            else
-                Debug.Log("New value: " + prop2.GetValue<UT1_SerzCls>().anotherValue2);
+            DebugUnit.Assert(prop2.GetValue<UT1_SerzCls>() != null);
+            DebugUnit.Assert(prop2.GetValue<UT1_SerzCls>().anotherValue2 == "potato");
         }
 
         /// <summary>

+ 1 - 1
README.md

@@ -76,7 +76,7 @@ To compile DirectX render systems you will also need a separately installed Dire
     * Asynchronous resource loading
     * Extensible importer system
     * Available importer plugins for:
-      * FXB, OBJ, DAE meshes
+      * FBX, OBJ, DAE meshes
       * PNG, PSD, BMP, JPG, ... images
       * OTF, TTF fonts
       * HLSL9, HLSL11, GLSL shaders