|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Local implementation of source location information for diagnostics. More...
#include "micro-os-plus/micro-test-plus.h"
Public Member Functions | |
| constexpr auto | file_name (void) const noexcept |
| Returns the file name associated with this source location. | |
| constexpr auto | line (void) const noexcept |
| Returns the line number associated with this source location. | |
Static Public Member Functions | |
| static constexpr source_location | current (const char *file="unknown", unsigned int line={}) noexcept |
| Returns the current source location. | |
Private Attributes | |
| const char * | file_ { "unknown" } |
| The file name where the source location was captured. | |
| unsigned int | line_ {} |
| The line number where the source location was captured. | |
This class provides a lightweight, constexpr-compatible alternative to std::source_location, used when the standard library does not provide it (__cpp_lib_source_location is not defined).
It enables retrieval of the file name and line number at the point of invocation, for the reports of the checks.
The static member function current() captures the current source location, using compiler built-ins where available, or defaulting to "unknown" and zero otherwise.
Definition at line 142 of file reflection.h.
|
staticnodiscardconstexprnoexcept |
| file | The file name (automatically provided by the compiler). |
| line | The line number (automatically provided by the compiler). |
Returns a source_location instance representing the file name and line number at the point of invocation.
If supported by the compiler, uses built-in macros to capture this information; otherwise, defaults to "unknown" and zero.
Definition at line 87 of file reflection-inlines.h.
References file_, line(), and line_.
Referenced by micro_os_plus::micro_test_plus::test_case::expect(), micro_os_plus::micro_test_plus::test_case::operator=(), micro_os_plus::micro_test_plus::test_case::require(), and micro_os_plus::micro_test_plus::detail::runnable_base::run().
|
nodiscardconstexprnoexcept |
Returns the file name captured at the time this source_location instance was created.
Definition at line 101 of file reflection-inlines.h.
References file_.
Referenced by micro_os_plus::micro_test_plus::runner::abort(), micro_os_plus::micro_test_plus::detail::reporter_human::abort_session(), micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session(), micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_prefix(), and micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix().
|
nodiscardconstexprnoexcept |
Returns the line number captured at the time this source_location instance was created.
Definition at line 112 of file reflection-inlines.h.
References line_.
Referenced by micro_os_plus::micro_test_plus::runner::abort(), micro_os_plus::micro_test_plus::detail::reporter_human::abort_session(), micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session(), current(), micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_prefix(), and micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix().
|
private |
Defaults to "unknown" when no location was provided.
Definition at line 189 of file reflection.h.
Referenced by current(), and file_name().
|
private |
Defaults to zero when no location was provided.
Definition at line 197 of file reflection.h.