Blender
V4.3
source
blender
blenlib
tests
BLI_pool_test.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#include "testing/testing.h"
6
7
#include "
BLI_exception_safety_test_utils.hh
"
8
#include "
BLI_pool.hh
"
9
10
#include "
BLI_strict_flags.h
"
/* Keep last. */
11
12
namespace
blender::tests
{
13
14
TEST
(pool, DefaultConstructor)
15
{
16
Pool<int>
pool;
17
EXPECT_EQ
(pool.size(), 0);
18
}
19
20
TEST
(pool, Allocation)
21
{
22
Vector<int *>
ptrs;
23
Pool<int>
pool;
24
for
(
int
i = 0; i < 100; i++) {
25
ptrs.
append
(&pool.construct(i));
26
}
27
EXPECT_EQ
(pool.size(), 100);
28
29
for
(
int
*
ptr
: ptrs) {
30
pool.destruct(*
ptr
);
31
}
32
EXPECT_EQ
(pool.size(), 0);
33
}
34
35
TEST
(pool, Reuse)
36
{
37
Vector<int *>
ptrs;
38
Pool<int>
pool;
39
for
(
int
i = 0; i < 32; i++) {
40
ptrs.
append
(&pool.construct(i));
41
}
42
43
int
*freed_ptr = ptrs[6];
44
pool.destruct(*freed_ptr);
45
46
ptrs[6] = &pool.construct(0);
47
48
EXPECT_EQ
(ptrs[6], freed_ptr);
49
50
for
(
int
*
ptr
: ptrs) {
51
pool.destruct(*
ptr
);
52
}
53
}
54
55
}
// namespace blender::tests
BLI_exception_safety_test_utils.hh
EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
BLI_pool.hh
BLI_strict_flags.h
blender::Pool
Definition
BLI_pool.hh:24
blender::Vector
Definition
BLI_vector.hh:65
blender::Vector::append
void append(const T &value)
Definition
BLI_vector.hh:430
blender::tests
Definition
BLI_any_test.cc:10
blender::tests::TEST
TEST(any, DefaultConstructor)
Definition
BLI_any_test.cc:12
ptr
PointerRNA * ptr
Definition
wm_files.cc:4126
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0