diff options
author | Jacques Lucke <mail@jlucke.com> | 2020-02-10 15:54:57 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2020-02-10 16:09:01 +0300 |
commit | 68cc982dcb7c1063a96f7ec9b7ccb95da4919d6b (patch) | |
tree | 9d2076363b54cb6b6da96064453ac3499a5f65c8 /tests/gtests/blenlib/BLI_stack_cxx_test.cc | |
parent | 76208a5670bc9d70f99f22a3c49463959461b5c1 (diff) |
BLI: improve various C++ data structures
The changes come from the `functions` branch, where I'm using
these structures a lot.
This also includes a new `BLI::Optional<T>` type, which is similar
to `std::Optional<T>` which can be used when Blender starts using
C++17.
Diffstat (limited to 'tests/gtests/blenlib/BLI_stack_cxx_test.cc')
-rw-r--r-- | tests/gtests/blenlib/BLI_stack_cxx_test.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/gtests/blenlib/BLI_stack_cxx_test.cc b/tests/gtests/blenlib/BLI_stack_cxx_test.cc index 436f1f307b9..272bba05cb8 100644 --- a/tests/gtests/blenlib/BLI_stack_cxx_test.cc +++ b/tests/gtests/blenlib/BLI_stack_cxx_test.cc @@ -8,7 +8,7 @@ TEST(stack, DefaultConstructor) { IntStack stack; EXPECT_EQ(stack.size(), 0); - EXPECT_TRUE(stack.empty()); + EXPECT_TRUE(stack.is_empty()); } TEST(stack, ArrayRefConstructor) @@ -19,7 +19,7 @@ TEST(stack, ArrayRefConstructor) EXPECT_EQ(stack.pop(), 2); EXPECT_EQ(stack.pop(), 7); EXPECT_EQ(stack.pop(), 4); - EXPECT_TRUE(stack.empty()); + EXPECT_TRUE(stack.is_empty()); } TEST(stack, Push) @@ -32,6 +32,17 @@ TEST(stack, Push) EXPECT_EQ(stack.size(), 2); } +TEST(stack, PushMultiple) +{ + IntStack stack; + EXPECT_EQ(stack.size(), 0); + stack.push_multiple({1, 2, 3}); + EXPECT_EQ(stack.size(), 3); + EXPECT_EQ(stack.pop(), 3); + EXPECT_EQ(stack.pop(), 2); + EXPECT_EQ(stack.pop(), 1); +} + TEST(stack, Pop) { IntStack stack; |