zpp
Zephyr C++20 Framework
Main Page
Namespaces
Namespace List
Namespace Members
All
a
b
d
e
g
i
m
o
p
s
t
y
Functions
a
b
d
g
i
m
o
p
s
t
y
Enumerations
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
~
Variables
Typedefs
c
d
i
n
p
r
t
v
Enumerations
Files
File List
File Members
All
c
f
i
m
n
o
s
t
w
z
Functions
i
m
o
w
z
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
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
/*
8
* Simple test to check if all zpp headers are error free
9
*/
10
11
#include <zephyr/ztest.h>
12
13
#include <zephyr/kernel.h>
14
15
#include <
zpp.hpp
>
16
17
ZTEST_SUITE
(zpp_compile_tests, NULL, NULL, NULL, NULL, NULL);
18
19
//
20
// check compile time power_of_two function
21
//
22
static_assert(
zpp::power_of_two
(0) == 1);
23
static_assert(
zpp::power_of_two
(1) == 2);
24
static_assert(
zpp::power_of_two
(2) == 4);
25
static_assert(
zpp::power_of_two
(3) == 8);
26
static_assert(
zpp::power_of_two
(4) == 16);
27
static_assert(
zpp::power_of_two
(10) == 1024);
28
static_assert(
zpp::power_of_two
(20) == 1048576);
29
30
//
31
// check compile time is_power_of_two function
32
//
33
static_assert(
zpp::is_power_of_two
(1) ==
true
);
34
static_assert(
zpp::is_power_of_two
(2) ==
true
);
35
static_assert(
zpp::is_power_of_two
(4) ==
true
);
36
static_assert(
zpp::is_power_of_two
(8) ==
true
);
37
static_assert(
zpp::is_power_of_two
(16) ==
true
);
38
static_assert(
zpp::is_power_of_two
(3) ==
false
);
39
static_assert(
zpp::is_power_of_two
(100) ==
false
);
40
41
//
42
// check compile time is_multiple_of function
43
//
44
static_assert(
zpp::is_multiple_of
(0, 0) ==
false
);
45
static_assert(
zpp::is_multiple_of
(4, 4) ==
true
);
46
static_assert(
zpp::is_multiple_of
(6, 3) ==
true
);
47
static_assert(
zpp::is_multiple_of
(10, 3) ==
false
);
zpp::is_power_of_two
consteval bool is_power_of_two(uint32_t value) noexcept
check if a value is a power of two
Definition:
utils.hpp:97
zpp::is_multiple_of
consteval bool is_multiple_of(uint32_t value, uint32_t base)
Check if a value is a multiple of another value.
Definition:
utils.hpp:117
zpp::power_of_two
consteval uint32_t power_of_two(uint32_t power) noexcept
calculate a power of 2
Definition:
utils.hpp:79
ZTEST_SUITE
ZTEST_SUITE(zpp_atomic_tests, NULL, NULL, NULL, NULL, NULL)
zpp.hpp
tests
compile
src
main.cpp
Generated by
1.9.1