micro-test-plus 5.0.0
µ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
36#if __has_include(<micro-os-plus/project-config.h>)
37#include <micro-os-plus/project-config.h>
38#elif __has_include(<micro-os-plus/config.h>)
39#pragma message \
40 "micro-os-plus/config.h is deprecated, rename to micro-os-plus/project-config.h and include it instead of micro-os-plus/config.h"
41#include <micro-os-plus/config.h>
42#endif // __has_include(<micro-os-plus/project-config.h>)
43
44#if __has_include(<micro-os-plus/micro-test-plus-defines.h>)
45#include <micro-os-plus/micro-test-plus-defines.h>
46#endif // __has_include(<micro-os-plus/micro-test-plus-defines.h>)
47
49
50#include <cstring>
51
52// ----------------------------------------------------------------------------
53
54#if defined(__GNUC__)
55#if defined(__clang__)
56#pragma clang diagnostic ignored "-Wc++98-compat"
57#endif
58#endif
59
60// ============================================================================
61
63{
64 // --------------------------------------------------------------------------
65 // Public API.
66
67 // --------------------------------------------------------------------------
68 // Too small to deserve a separate source file.
69 namespace reflection
70 {
71
81 const char*
82 short_name (const char* name) noexcept
83 {
84#if defined(__GNUC__)
85#pragma GCC diagnostic push
86#if defined(__clang__)
87#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
88#endif
89#endif
90 const char* p = strrchr (name, '/');
91 if (p != nullptr)
92 return p + 1;
93 else
94 return name;
95#if defined(__GNUC__)
96#pragma GCC diagnostic pop
97#endif
98 }
99
100 } // namespace reflection
101
102 // ==========================================================================
103} // namespace micro_os_plus::micro_test_plus
104
105// ----------------------------------------------------------------------------
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.