micro-test-plus
5.0.1
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
/*
2
* This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
*
5
* Permission to use, copy, modify, and/or distribute this software for any
6
* purpose is hereby granted, under the terms of the MIT license.
7
*
8
* If a copy of the license was not distributed with this file, it can be
9
* obtained from https://opensource.org/licenses/mit.
10
*
11
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
* released under the terms of the Boost Version 1.0 Software License,
13
* which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
*/
15
16
// ----------------------------------------------------------------------------
17
48
49
#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_MATH_H_
50
#define MICRO_OS_PLUS_MICRO_TEST_PLUS_MATH_H_
51
52
// ----------------------------------------------------------------------------
53
54
#if defined(__cplusplus)
55
56
// ----------------------------------------------------------------------------
57
58
#if __has_include("micro-os-plus/project-config.h")
59
#include "micro-os-plus/project-config.h"
60
#endif
// __has_include("micro-os-plus/project-config.h")
61
62
#if __has_include("micro-os-plus/micro-test-plus-defines.h")
63
#include "micro-os-plus/micro-test-plus-defines.h"
64
#endif
// __has_include("micro-os-plus/micro-test-plus-defines.h")
65
66
#include <array>
67
68
// ----------------------------------------------------------------------------
69
70
#if defined(__GNUC__)
71
#pragma GCC diagnostic push
72
73
#pragma GCC diagnostic ignored "-Wconversion"
74
#if defined(__clang__)
75
#pragma clang diagnostic ignored "-Wc++98-compat"
76
#pragma clang diagnostic ignored "-Wc++20-compat"
77
#endif
// defined(__clang__)
78
#endif
// defined(__GNUC__)
79
80
// ============================================================================
81
82
namespace
micro_os_plus::micro_test_plus
83
{
84
// --------------------------------------------------------------------------
85
105
namespace
math
106
{
116
template
<
class
T>
117
[[nodiscard]]
constexpr
auto
118
abs
(
const
T t)
noexcept
-> T;
119
130
template
<
class
T>
131
[[nodiscard]]
constexpr
auto
132
min_value
(
const
T& lhs,
const
T& rhs)
noexcept
->
const
T&;
133
147
template
<
class
T,
class
Exp_T>
148
[[nodiscard]]
constexpr
auto
149
pow
(
const
T base,
const
Exp_T exp)
noexcept
-> T;
150
162
template
<
class
T,
char
... Cs>
163
[[nodiscard]]
consteval
auto
164
num
(
void
) -> T;
165
177
template
<
class
T,
char
... Cs>
178
[[nodiscard]]
consteval
auto
179
den
(
void
) -> T;
180
192
template
<
class
T,
char
... Cs>
193
[[nodiscard]]
consteval
auto
194
den_size
(
void
) -> T;
195
207
template
<
class
T,
class
Value_T>
208
[[nodiscard]]
constexpr
auto
209
den_size
(Value_T value) -> T;
210
211
// ------------------------------------------------------------------------
212
}
// namespace math
213
214
// --------------------------------------------------------------------------
215
}
// namespace micro_os_plus::micro_test_plus
216
217
#if defined(__GNUC__)
218
#pragma GCC diagnostic pop
219
#endif
// defined(__GNUC__)
220
221
// ----------------------------------------------------------------------------
222
223
#endif
// defined(__cplusplus)
224
225
// ============================================================================
226
// Templates, inlines & constexpr implementations.
227
228
#include "
inlines/math-inlines.h
"
229
230
// ----------------------------------------------------------------------------
231
232
#endif
// MICRO_OS_PLUS_MICRO_TEST_PLUS_MATH_H_
233
234
// ----------------------------------------------------------------------------
math-inlines.h
C++ header file with inline implementations for the µTest++ mathematical utilities.
micro_os_plus::micro_test_plus::math
Mathematical utilities for the µTest++ testing framework.
Definition
math-inlines.h:79
micro_os_plus::micro_test_plus::math::min_value
constexpr auto min_value(const T &lhs, const T &rhs) noexcept -> const T &
Computes the minimum of two comparable values.
Definition
math-inlines.h:119
micro_os_plus::micro_test_plus::math::pow
constexpr auto pow(const T base, const Exp_T exp) noexcept -> T
Generic exponentiation function to compute the power of a base raised to an exponent.
Definition
math-inlines.h:140
micro_os_plus::micro_test_plus::math::den
consteval auto den(void) -> T
Computes the decimal part of a number represented as an array of characters.
Definition
math-inlines.h:204
micro_os_plus::micro_test_plus::math::abs
constexpr auto abs(const T t) noexcept -> T
Computes the absolute value of a given comparable value.
Definition
math-inlines.h:98
micro_os_plus::micro_test_plus::math::den_size
consteval auto den_size(void) -> T
Computes the number of decimal places in a number represented as an array of characters.
Definition
math-inlines.h:239
micro_os_plus::micro_test_plus::math::num
consteval auto num(void) -> T
Computes the integral value of a number represented as an array of characters.
Definition
math-inlines.h:164
micro_os_plus::micro_test_plus
Primary namespace for the µTest++ testing framework.
Definition
deferred-reporter.h:82
include
micro-os-plus
micro-test-plus
math.h
Generated by
1.17.0