micro-test-plus 5.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
reflection.cpp
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
33
34// ----------------------------------------------------------------------------
35
37
38#include <cstring>
39
40// ----------------------------------------------------------------------------
41
42#if defined(__GNUC__)
43#if defined(__clang__)
44#pragma clang diagnostic ignored "-Wc++98-compat"
45#endif // defined(__clang__)
46#endif // defined(__GNUC__)
47
48// ============================================================================
49
50#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
51
52// ----------------------------------------------------------------------------
53
55{
56 // --------------------------------------------------------------------------
57 // Public API.
58
59 // --------------------------------------------------------------------------
60 // Too small to deserve a separate source file.
61 namespace reflection
62 {
63
73 const char*
74 short_name (const char* name) noexcept
75 {
76#if defined(__GNUC__)
77#pragma GCC diagnostic push
78
79#if defined(__clang__)
80#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
81#endif // defined(__clang__)
82#endif // defined(__GNUC__)
83
84 const char* p = strrchr (name, '/');
85 if (p != nullptr)
86 return p + 1;
87 else
88 return name;
89
90#if defined(__GNUC__)
91#pragma GCC diagnostic pop
92#endif // defined(__GNUC__)
93 }
94
95 } // namespace reflection
96
97 // --------------------------------------------------------------------------
98} // namespace micro_os_plus::micro_test_plus
99
100// ----------------------------------------------------------------------------
101
102#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
103
104// ----------------------------------------------------------------------------
Reflection utilities for the µTest++ testing framework.
const char * short_name(const char *name) noexcept
Extract a short type or function name from a fully qualified name.
Primary namespace for the µTest++ testing framework.
C++ header file with declarations for the µTest++ reflection utilities.