[Bf-blender-cvs] [eaac6cb] master: Add a bmesh_core_test, a start at testing bmesh functionality.

Howard Trickey noreply at git.blender.org
Thu Jun 19 17:59:34 CEST 2014


Commit: eaac6cbcd9428533273091710759106131f92340
Author: Howard Trickey
Date:   Thu Jun 19 11:49:09 2014 -0400
https://developer.blender.org/rBeaac6cbcd9428533273091710759106131f92340

Add a bmesh_core_test, a start at testing bmesh functionality.

Needed to make the blender link libraries a global property
now that tests are parallel to source directory.
Current sort order for blender link libraries doesn't work
for tests that start with few defined symbols. Doubling the
lib list works, but a TODO to find a better way (probably
using CMake's own mechanism for tracking dependencies).

===================================================================

M	build_files/cmake/macros.cmake
M	source/creator/CMakeLists.txt
M	tests/gtests/CMakeLists.txt
A	tests/gtests/bmesh/CMakeLists.txt
A	tests/gtests/bmesh/bmesh_core_test.cc

===================================================================

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index f8720f0..c6caef4 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -645,6 +645,9 @@ macro(SETUP_BLENDER_SORTED_LIBS)
 	unset(SORTLIB)
 	unset(REMLIB)
 	unset(REM_MSG)
+
+	# for top-level tests
+	set_property(GLOBAL PROPERTY BLENDER_SORTED_LIBS_PROP ${BLENDER_SORTED_LIBS})
 endmacro()
 
 macro(TEST_SSE_SUPPORT
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index fb32357..f263043 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -176,7 +176,7 @@ if(WITH_BUILDINFO)
 	)
 
 	# make an object library so can load with it in tests
-	add_library(buildinofobj OBJECT buildinfo.c)
+	add_library(buildinfoobj OBJECT buildinfo.c)
 endif()
 
 # message(STATUS "Configuring blender")
diff --git a/tests/gtests/CMakeLists.txt b/tests/gtests/CMakeLists.txt
index 317f030..a3860ce 100644
--- a/tests/gtests/CMakeLists.txt
+++ b/tests/gtests/CMakeLists.txt
@@ -10,5 +10,6 @@ if(WITH_GTESTS)
 	add_subdirectory(testing)
 	add_subdirectory(blenlib)
 	add_subdirectory(guardedalloc)
+	add_subdirectory(bmesh)
 endif()
 
diff --git a/tests/gtests/bmesh/CMakeLists.txt b/tests/gtests/bmesh/CMakeLists.txt
new file mode 100644
index 0000000..aaee73d
--- /dev/null
+++ b/tests/gtests/bmesh/CMakeLists.txt
@@ -0,0 +1,43 @@
+# ***** 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) 2014, Blender Foundation
+# All rights reserved.
+#
+# Contributor(s): Howard Trickey
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	.
+	../
+	../../../source/blender/blenlib
+	../../../source/blender/makesdna
+	../../../source/blender/bmesh
+	../../../intern/guardedalloc
+)
+
+include_directories(${INC})
+
+setup_libdirs()
+get_property(BLENDER_SORTED_LIBS GLOBAL PROPERTY BLENDER_SORTED_LIBS_PROP)
+
+# Current BLENDER_SORTED_LIBS works with starting list of symbols in creator, but not
+# for this test. Doubling the list does let all the symbols be resolved, but link time is a bit painful.
+set(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} ${BLENDER_SORTED_LIBS})
+
+BLENDER_SRC_GTEST(bmesh_core "bmesh_core_test.cc;$<TARGET_OBJECTS:buildinfoobj>" "${BLENDER_SORTED_LIBS}")
+setup_liblinks(bmesh_core_test)
diff --git a/tests/gtests/bmesh/bmesh_core_test.cc b/tests/gtests/bmesh/bmesh_core_test.cc
new file mode 100644
index 0000000..9c389a8
--- /dev/null
+++ b/tests/gtests/bmesh/bmesh_core_test.cc
@@ -0,0 +1,36 @@
+#include "testing/testing.h"
+
+#include "BLI_utildefines.h"
+#include "bmesh.h"
+#include "BLI_math.h"
+
+TEST(bmesh_core, BMVertCreate) {
+	BMesh *bm;
+	BMVert *bv1, *bv2, *bv3;
+	const float co1[3] = {1.0f, 2.0f, 0.0f};
+
+	bm = BM_mesh_create(&bm_mesh_allocsize_default);
+	EXPECT_EQ(0, bm->totvert);
+	/* make a custom layer so we can see if it is copied properly */
+	BM_data_layer_add(bm, &bm->vdata, CD_PROP_FLT);
+	bv1 = BM_vert_create(bm, co1, NULL, BM_CREATE_NOP);
+	ASSERT_TRUE(bv1 != NULL);
+	EXPECT_EQ(1.0f, bv1->co[0]);
+	EXPECT_EQ(2.0f, bv1->co[1]);
+	EXPECT_EQ(0.0f, bv1->co[2]);
+	EXPECT_TRUE(is_zero_v3(bv1->no));
+	EXPECT_EQ((char)BM_VERT, bv1->head.htype);
+	EXPECT_EQ(0, bv1->head.hflag);
+	EXPECT_EQ(0, bv1->head.api_flag);
+	bv2 = BM_vert_create(bm, NULL, NULL, BM_CREATE_NOP);
+	ASSERT_TRUE(bv2 != NULL);
+	EXPECT_TRUE(is_zero_v3(bv2->co));
+	/* create with example should copy custom data but not select flag */
+	BM_vert_select_set(bm, bv2, true);
+	BM_elem_float_data_set(&bm->vdata, bv2, CD_PROP_FLT, 1.5f);
+	bv3 = BM_vert_create(bm, co1, bv2, BM_CREATE_NOP);
+	ASSERT_TRUE(bv3 != NULL);
+	EXPECT_FALSE(BM_elem_flag_test((BMElem *)bv3, BM_ELEM_SELECT));
+	EXPECT_EQ(1.5f, BM_elem_float_data_get(&bm->vdata, bv3, CD_PROP_FLT));
+	EXPECT_EQ(3, BM_mesh_elem_count(bm, BM_VERT));
+}




More information about the Bf-blender-cvs mailing list