Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2020-08-07 17:43:42 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-08-10 19:14:00 +0300
commit53d203dea8230da4e80f3cc61468a4e24ff6759c (patch)
tree3f1b7498fb1a3108e60a4355bec0e4eef76110e4 /source/blender/bmesh
parentaf77bf1f0f94cb07d5bf681d1f771d4106873780 (diff)
Tests: move remaining gtests into their own module folders
And make them part of the blender_test runner. The one exception is blenlib performance tests, which we don't want to run by default. They remain in their own executable. Differential Revision: https://developer.blender.org/D8498
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/CMakeLists.txt13
-rw-r--r--source/blender/bmesh/tests/bmesh_core_test.cc40
2 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index fca411e594f..b97b5cc95f2 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -204,3 +204,16 @@ if(WITH_FREESTYLE)
endif()
blender_add_lib(bf_bmesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/bmesh_core_test.cc
+ )
+ set(TEST_INC
+ )
+ set(TEST_LIB
+ bf_bmesh
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_bmesh_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+endif()
diff --git a/source/blender/bmesh/tests/bmesh_core_test.cc b/source/blender/bmesh/tests/bmesh_core_test.cc
new file mode 100644
index 00000000000..afbc11e0722
--- /dev/null
+++ b/source/blender/bmesh/tests/bmesh_core_test.cc
@@ -0,0 +1,40 @@
+#include "testing/testing.h"
+
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "bmesh.h"
+
+TEST(bmesh_core, BMVertCreate)
+{
+ BMesh *bm;
+ BMVert *bv1, *bv2, *bv3;
+ const float co1[3] = {1.0f, 2.0f, 0.0f};
+
+ BMeshCreateParams bm_params;
+ bm_params.use_toolflags = true;
+ bm = BM_mesh_create(&bm_mesh_allocsize_default, &bm_params);
+ EXPECT_EQ(bm->totvert, 0);
+ /* make a custom layer so we can see if it is copied properly */
+ BM_data_layer_add(bm, &bm->vdata, CD_PROP_FLOAT);
+ bv1 = BM_vert_create(bm, co1, NULL, BM_CREATE_NOP);
+ ASSERT_TRUE(bv1 != NULL);
+ EXPECT_EQ(bv1->co[0], 1.0f);
+ EXPECT_EQ(bv1->co[1], 2.0f);
+ EXPECT_EQ(bv1->co[2], 0.0f);
+ EXPECT_TRUE(is_zero_v3(bv1->no));
+ EXPECT_EQ(bv1->head.htype, (char)BM_VERT);
+ EXPECT_EQ(bv1->head.hflag, 0);
+ EXPECT_EQ(bv1->head.api_flag, 0);
+ 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_FLOAT, 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(BM_elem_float_data_get(&bm->vdata, bv3, CD_PROP_FLOAT), 1.5f);
+ EXPECT_EQ(BM_mesh_elem_count(bm, BM_VERT), 3);
+ BM_mesh_free(bm);
+}