zpp
Zephyr C++20 Framework
main.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019 Erwin Rol <erwin@erwinrol.com>
3 //
4 // SPDX-License-Identifier: Apache-2.0
5 //
6 
7 #include <zephyr/ztest.h>
8 
9 #include <zephyr/kernel.h>
10 
11 #include <zpp/mem_slab.hpp>
12 
13 
14 ZTEST_SUITE(zpp_mem_slab_tests, NULL, NULL, NULL, NULL, NULL);
15 
16 namespace {
17 
18 zpp::mem_slab<8, 64, 8> g_mem_slab;
19 
20 } // namespace
21 
22 ZTEST(zpp_mem_slab_tests, test_mem_slab)
23 {
24  const auto total = g_mem_slab.total_block_count();
25 
26  zassert_equal(g_mem_slab.free_block_count(), total, "");
27  zassert_equal(g_mem_slab.used_block_count(), 0, "");
28 
29  auto p = g_mem_slab.allocate();
30 
31  zassert_not_null(p, "");
32 
33  zassert_equal(g_mem_slab.free_block_count(), total - 1, "");
34  zassert_equal(g_mem_slab.used_block_count(), 1, "");
35 
36  g_mem_slab.deallocate(p);
37 
38  zassert_equal(g_mem_slab.free_block_count(), total, "");
39  zassert_equal(g_mem_slab.used_block_count(), 0, "");
40 }
A memory slab class.
Definition: mem_slab.hpp:182
ZTEST(zpp_atomic_tests, test_atomic_bitset)
Definition: main.cpp:23
ZTEST_SUITE(zpp_atomic_tests, NULL, NULL, NULL, NULL, NULL)