[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29038] branches/soc-2010-leifandersen: 1.

Leif Andersen leif.a.andersen at gmail.com
Fri May 28 01:17:16 CEST 2010


Revision: 29038
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29038
Author:   leifandersen
Date:     2010-05-28 01:17:16 +0200 (Fri, 28 May 2010)

Log Message:
-----------
1.  Added some of Andrea's code that I failed to put under version control

2.  Added a tests module,  which can be called on in other scripts.  Can be found in release/scripts/modules/tests The current hashcode() function should take more into account.  Also, it reliess on hash() for a string, and a double (or however python handles floating point arrithmatic), to be a good method.

3.  Added (then removed when realized it was bad form), a hash code operator, kept momentatirly for archival purposes in tests/scripts.

4.  Added a bit more to Gtest, currently it fails, do to roundoff error in floats, will be fixed.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp

Added Paths:
-----------
    branches/soc-2010-leifandersen/release/scripts/modules/tests/
    branches/soc-2010-leifandersen/release/scripts/modules/tests/Scene_Hash.py
    branches/soc-2010-leifandersen/release/scripts/modules/tests/__init__.py
    branches/soc-2010-leifandersen/tests/gtest/blendertests.cpp
    branches/soc-2010-leifandersen/tests/gtest/buildinfo.c
    branches/soc-2010-leifandersen/tests/gtest/sampletest.cpp
    branches/soc-2010-leifandersen/tests/gtest/teststubs.c
    branches/soc-2010-leifandersen/tests/hashtests/
    branches/soc-2010-leifandersen/tests/scripts/
    branches/soc-2010-leifandersen/tests/scripts/README.txt
    branches/soc-2010-leifandersen/tests/scripts/Scene_Hash.py
    branches/soc-2010-leifandersen/tests/scripts/Scene_Hash_Operator.py

Added: branches/soc-2010-leifandersen/release/scripts/modules/tests/Scene_Hash.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/modules/tests/Scene_Hash.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/release/scripts/modules/tests/Scene_Hash.py	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1,17 @@
+def hashcode(scene):
+    hashcode = 0
+    hashcode += hash(scene.name)
+    for ob in scene.objects:
+        hashcode += hash(ob.name)
+        for num in ob.rotation_euler:
+            hashcode += hash(round(num, 6))
+        hashcode += hash(ob.type)
+        if ob.type == 'MESH':
+            for vert in ob.data.verts:
+                for co in vert.co:
+                    hashcode += hash(co)
+    return hashcode
+
+if __name__ == "__main__":
+    for scene in bpy.data.scenes:
+        print(scene.name+": "+str(hashcode(scene)))
\ No newline at end of file

Added: branches/soc-2010-leifandersen/release/scripts/modules/tests/__init__.py
===================================================================

Added: branches/soc-2010-leifandersen/tests/gtest/blendertests.cpp
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/blendertests.cpp	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/gtest/blendertests.cpp	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1,7 @@
+#include <gtest/gtest.h>
+
+int main(int argc, char **argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+

Modified: branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp	2010-05-27 21:51:16 UTC (rev 29037)
+++ branches/soc-2010-leifandersen/tests/gtest/blenlib/BLI_math_base_test.cpp	2010-05-27 23:17:16 UTC (rev 29038)
@@ -36,7 +36,7 @@
 	EXPECT_EQ(0, maxf(0,-7));
 	
 	// Test floating point arrithmatic
-//	EXPECT_EQ(5.3, maxf(0.1, 5.3));
+	EXPECT_EQ(5.3, maxf(0.1, 5.3));
 	
 	// Preform a Random test
 	fnumpair nums;

Added: branches/soc-2010-leifandersen/tests/gtest/buildinfo.c
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/buildinfo.c	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/gtest/buildinfo.c	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1,39 @@
+/*
+ * $Id: buildinfo.c 28254 2010-04-18 10:28:37Z campbellbarton $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#define STRINGIFY(x) XSTRINGIFY(x)
+#define XSTRINGIFY(x) #x
+
+#ifdef BUILD_DATE
+char build_date[]= STRINGIFY(BUILD_DATE);
+char build_time[]= STRINGIFY(BUILD_TIME);
+char build_rev[]= STRINGIFY(BUILD_REV);
+char build_platform[]= STRINGIFY(BUILD_PLATFORM);
+char build_type[]= STRINGIFY(BUILD_TYPE);
+#endif

Added: branches/soc-2010-leifandersen/tests/gtest/sampletest.cpp
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/sampletest.cpp	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/gtest/sampletest.cpp	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1,18 @@
+#include <gtest/gtest.h>
+
+extern "C" {
+	#include "BLI_path_util.h"
+//	#include "BKE_bmesh.h"
+}
+
+// Tests that the Foo::Bar() method does Abc.
+TEST(PathUtilTest, SwitchesChar) {
+//	char path[256] = "C:/Data/Foo";
+//	BLI_char_switch(path, '/', '\\');
+//	ASSERT_STREQ("C:\\Data\\Foo",path);
+//	BLI_rand();
+//	PIL_check_seconds_timer();
+//	EXPECT_EQ(2, sqrt3d(8));
+	
+}
+

Added: branches/soc-2010-leifandersen/tests/gtest/teststubs.c
===================================================================
--- branches/soc-2010-leifandersen/tests/gtest/teststubs.c	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/gtest/teststubs.c	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1,5 @@
+
+char btempdir[256] = "";
+char bprogname[256] = "";
+char blender_path[256] = "";
+

Added: branches/soc-2010-leifandersen/tests/scripts/README.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/scripts/README.txt	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/scripts/README.txt	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1 @@
+A bunch of functions I've used for building tests.  This has been merged into release/scripts/modules/tests, still may be further incorperated into RNA, if appropriate.  This file has been kept arround on the off change that an operator is appropriate, but that is unlikely, this folder will be removed soon.  (As soon as it's obvious it won't be needed).

Added: branches/soc-2010-leifandersen/tests/scripts/Scene_Hash.py
===================================================================
--- branches/soc-2010-leifandersen/tests/scripts/Scene_Hash.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/scripts/Scene_Hash.py	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1,17 @@
+def hashcode(scene):
+    hashcode = 0
+    hashcode += hash(scene.name)
+    for ob in scene.objects:
+        hashcode += hash(ob.name)
+        for num in ob.rotation_euler:
+            hashcode += hash(round(num, 6))
+        hashcode += hash(ob.type)
+        if ob.type == 'MESH':
+            for vert in ob.data.verts:
+                for co in vert.co:
+                    hashcode += hash(co)
+    return hashcode
+
+if __name__ == "__main__":
+    for scene in bpy.data.scenes:
+        print(scene.name+": "+str(hashcode(scene)))
\ No newline at end of file

Added: branches/soc-2010-leifandersen/tests/scripts/Scene_Hash_Operator.py
===================================================================
--- branches/soc-2010-leifandersen/tests/scripts/Scene_Hash_Operator.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/scripts/Scene_Hash_Operator.py	2010-05-27 23:17:16 UTC (rev 29038)
@@ -0,0 +1,36 @@
+import bpy
+
+def main(context):
+    hashcode = 0
+    hashcode += hash(context.scene.name)
+    for ob in context.scene.objects:
+        hashcode += hash(ob.name)
+        for num in ob.rotation_euler:
+            hashcode += hash(round(num, 6))
+        hashcode += hash(ob.type)
+        if ob.type == 'MESH':
+            for vert in ob.data.verts:
+                for co in vert.co:
+                    hashcode += hash(co)
+    return hashcode
+
+class HashOperator(bpy.types.Operator):
+    ''''''
+    bl_idname = "scene.hash_code"
+    bl_label = "Simple Scene Hash Code"
+
+    def poll(self, context):
+        return True # Assuming that there will always be an active scene
+
+    def execute(self, context):
+        print(main(context))
+        return {'FINISHED'}
+
+def register():
+    bpy.types.register(HashOperator)
+
+def unregister():
+    bpy.types.unregister(HashOperator)
+
+if __name__ == "__main__":
+    register()
\ No newline at end of file





More information about the Bf-blender-cvs mailing list