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>2014-07-15 14:37:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-07-15 15:09:03 +0400
commit5c4180d89881c08c34e1829fc1998937381a6b59 (patch)
tree061f1984607e705a63c78e92389249d4a803207b /tests/gtests
parenta378f8d2d8f7d30eb699ee2f16e111f60b7900df (diff)
BLI_stack: various small additions
- add BLI_stack_count - add BLI_stack_pop_n to pop into an array - add BLI_stack_push_r, which returns a pointer that can be filled in Also remove sanity check in BLI_stack_pop, assert if the stack is empty.
Diffstat (limited to 'tests/gtests')
-rw-r--r--tests/gtests/blenlib/BLI_stack_test.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/gtests/blenlib/BLI_stack_test.cc b/tests/gtests/blenlib/BLI_stack_test.cc
index 8ad4d957813..c4884cb8940 100644
--- a/tests/gtests/blenlib/BLI_stack_test.cc
+++ b/tests/gtests/blenlib/BLI_stack_test.cc
@@ -17,6 +17,7 @@ TEST(stack, Empty)
stack = BLI_stack_new(sizeof(int), __func__);
EXPECT_EQ(BLI_stack_is_empty(stack), true);
+ EXPECT_EQ(BLI_stack_count(stack), 0);
BLI_stack_free(stack);
}
@@ -29,9 +30,11 @@ TEST(stack, One)
BLI_stack_push(stack, (void *)&in);
EXPECT_EQ(BLI_stack_is_empty(stack), false);
+ EXPECT_EQ(BLI_stack_count(stack), 1);
BLI_stack_pop(stack, (void *)&out);
EXPECT_EQ(in, out);
EXPECT_EQ(BLI_stack_is_empty(stack), true);
+ EXPECT_EQ(BLI_stack_count(stack), 0);
BLI_stack_free(stack);
}
@@ -79,7 +82,6 @@ TEST(stack, String)
*((int *)in) = i;
BLI_stack_pop(stack, (void *)&out);
EXPECT_STREQ(in, out);
-
}
EXPECT_EQ(BLI_stack_is_empty(stack), true);
@@ -133,5 +135,14 @@ TEST(stack, Reuse)
EXPECT_EQ(i, 0);
EXPECT_EQ(memcmp(sizes, sizes_test, sizeof(sizes) - sizeof(int)), 0);
+
+ /* finally test BLI_stack_pop_n */
+ for (i = ARRAY_SIZE(sizes); i--; ) {
+ BLI_stack_push(stack, (void *)&sizes[i]);
+ }
+ EXPECT_EQ(BLI_stack_count(stack), ARRAY_SIZE(sizes));
+ BLI_stack_pop_n(stack, (void *)sizes_test, ARRAY_SIZE(sizes));
+ EXPECT_EQ(memcmp(sizes, sizes_test, sizeof(sizes) - sizeof(int)), 0);
+
BLI_stack_free(stack);
}