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:
authorCampbell Barton <ideasman42@gmail.com>2018-09-19 05:05:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-19 05:12:21 +0300
commitbb3ec3ebafbc2c0e5d8530148a433242e0adad30 (patch)
treed30aaa3df2d03f90f6e7749bdc075445a5642045 /tests/gtests/blenlib/BLI_heap_test.cc
parent4c918efd44be11d47afc1efed684a15ad5579722 (diff)
BLI_utildefines: rename pointer conversion macros
Terms get/set don't make much sense when casting values. Name macros so the conversion is obvious, use common prefix for easier completion. - GET_INT_FROM_POINTER -> POINTER_AS_INT - SET_INT_IN_POINTER -> POINTER_FROM_INT - GET_UINT_FROM_POINTER -> POINTER_AS_UINT - SET_UINT_IN_POINTER -> POINTER_FROM_UINT
Diffstat (limited to 'tests/gtests/blenlib/BLI_heap_test.cc')
-rw-r--r--tests/gtests/blenlib/BLI_heap_test.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/gtests/blenlib/BLI_heap_test.cc b/tests/gtests/blenlib/BLI_heap_test.cc
index dd0bc3451ce..69566d8dca6 100644
--- a/tests/gtests/blenlib/BLI_heap_test.cc
+++ b/tests/gtests/blenlib/BLI_heap_test.cc
@@ -55,10 +55,10 @@ TEST(heap, Range)
const int items_total = SIZE;
Heap *heap = BLI_heap_new();
for (int in = 0; in < items_total; in++) {
- BLI_heap_insert(heap, (float)in, SET_INT_IN_POINTER(in));
+ BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
}
for (int out_test = 0; out_test < items_total; out_test++) {
- EXPECT_EQ(out_test, GET_INT_FROM_POINTER(BLI_heap_pop_min(heap)));
+ EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
@@ -70,10 +70,10 @@ TEST(heap, RangeReverse)
const int items_total = SIZE;
Heap *heap = BLI_heap_new();
for (int in = 0; in < items_total; in++) {
- BLI_heap_insert(heap, (float)-in, SET_INT_IN_POINTER(-in));
+ BLI_heap_insert(heap, (float)-in, POINTER_FROM_INT(-in));
}
for (int out_test = items_total - 1; out_test >= 0; out_test--) {
- EXPECT_EQ(-out_test, GET_INT_FROM_POINTER(BLI_heap_pop_min(heap)));
+ EXPECT_EQ(-out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
BLI_heap_free(heap, NULL);
@@ -85,14 +85,14 @@ TEST(heap, RangeRemove)
Heap *heap = BLI_heap_new();
HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__);
for (int in = 0; in < items_total; in++) {
- nodes[in] = BLI_heap_insert(heap, (float)in, SET_INT_IN_POINTER(in));
+ nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
}
for (int i = 0; i < items_total; i += 2) {
BLI_heap_remove(heap, nodes[i]);
nodes[i] = NULL;
}
for (int out_test = 1; out_test < items_total; out_test += 2) {
- EXPECT_EQ(out_test, GET_INT_FROM_POINTER(BLI_heap_pop_min(heap)));
+ EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
BLI_heap_free(heap, NULL);
@@ -107,7 +107,7 @@ TEST(heap, Duplicates)
BLI_heap_insert(heap, 1.0f, 0);
}
for (int out_test = 0; out_test < items_total; out_test++) {
- EXPECT_EQ(0, GET_INT_FROM_POINTER(BLI_heap_pop_min(heap)));
+ EXPECT_EQ(0, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
BLI_heap_free(heap, NULL);
@@ -122,10 +122,10 @@ static void random_heap_helper(
range_fl(values, items_total);
BLI_array_randomize(values, sizeof(float), items_total, random_seed);
for (int i = 0; i < items_total; i++) {
- BLI_heap_insert(heap, values[i], SET_INT_IN_POINTER((int)values[i]));
+ BLI_heap_insert(heap, values[i], POINTER_FROM_INT((int)values[i]));
}
for (int out_test = 0; out_test < items_total; out_test++) {
- EXPECT_EQ(out_test, GET_INT_FROM_POINTER(BLI_heap_pop_min(heap)));
+ EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
BLI_heap_free(heap, NULL);
@@ -143,14 +143,14 @@ TEST(heap, ReInsertSimple)
Heap *heap = BLI_heap_new();
HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__);
for (int in = 0; in < items_total; in++) {
- nodes[in] = BLI_heap_insert(heap, (float)in, SET_INT_IN_POINTER(in));
+ nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
}
for (int i = 0; i < items_total; i++) {
BLI_heap_node_value_update(heap, nodes[i], (float)(items_total + i));
}
for (int out_test = 0; out_test < items_total; out_test++) {
- EXPECT_EQ(out_test, GET_INT_FROM_POINTER(BLI_heap_pop_min(heap)));
+ EXPECT_EQ(out_test, POINTER_AS_INT(BLI_heap_pop_min(heap)));
}
EXPECT_TRUE(BLI_heap_is_empty(heap));
@@ -165,7 +165,7 @@ static void random_heap_reinsert_helper(
Heap *heap = BLI_heap_new();
HeapNode **nodes = (HeapNode **)MEM_mallocN(sizeof(HeapNode *) * items_total, __func__);
for (int in = 0; in < items_total; in++) {
- nodes[in] = BLI_heap_insert(heap, (float)in, SET_INT_IN_POINTER(in));
+ nodes[in] = BLI_heap_insert(heap, (float)in, POINTER_FROM_INT(in));
}
BLI_array_randomize(nodes, sizeof(HeapNode *), items_total, random_seed);
for (int i = 0; i < items_total; i++) {