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
path: root/tests
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-09-28 07:24:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-09-28 09:08:54 +0400
commita4c3b9229448e93f10a7706800822b1e0119c033 (patch)
tree7270a0f1596bc5b3f569441664de9f8115ad4818 /tests
parent99ef213dcbab68debe7047996a2e26380254d093 (diff)
BLI_Stack add BLI_stack_peek, BLI_stack_discard
also remove own incorrect assert
Diffstat (limited to 'tests')
-rw-r--r--tests/gtests/blenlib/BLI_stack_test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/gtests/blenlib/BLI_stack_test.cc b/tests/gtests/blenlib/BLI_stack_test.cc
index c4884cb8940..08701356816 100644
--- a/tests/gtests/blenlib/BLI_stack_test.cc
+++ b/tests/gtests/blenlib/BLI_stack_test.cc
@@ -88,6 +88,29 @@ TEST(stack, String)
BLI_stack_free(stack);
}
+TEST(stack, Peek)
+{
+ const int tot = SIZE;
+ int i;
+
+ BLI_Stack *stack;
+ const short in[] = {1, 10, 100, 1000};
+
+ stack = BLI_stack_new(sizeof(*in), __func__);
+
+ for (i = 0; i < tot; i++) {
+ BLI_stack_push(stack, &in[i % ARRAY_SIZE(in)]);
+ }
+
+ for (i = tot - 1; i >= 0; i--, BLI_stack_discard(stack)) {
+ short *ret = (short *)BLI_stack_peek(stack);
+ EXPECT_EQ(*ret, in[i % ARRAY_SIZE(in)]);
+ }
+
+ EXPECT_EQ(BLI_stack_is_empty(stack), true);
+}
+
+
TEST(stack, Reuse)
{
const int sizes[] = {3, 11, 81, 400, 999, 12, 1, 9721, 7, 99, 5, 0};