micro-test-plus
5.0.1
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
utility-inlines.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
40
41
#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_UTILITY_INLINES_H_
42
#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_UTILITY_INLINES_H_
43
44
// ----------------------------------------------------------------------------
45
46
#if defined(__cplusplus)
47
48
// ----------------------------------------------------------------------------
49
50
#if defined(__GNUC__)
51
#pragma GCC diagnostic push
52
53
#pragma GCC diagnostic ignored "-Waggregate-return"
54
#if defined(__clang__)
55
#pragma clang diagnostic ignored "-Wc++98-compat"
56
#endif
// defined(__clang__)
57
#endif
// defined(__GNUC__)
58
59
// ============================================================================
60
61
namespace
micro_os_plus::micro_test_plus
62
{
63
// --------------------------------------------------------------------------
64
namespace
utility
65
{
87
template
<
class
T = std::
string
_view,
class
Delim_T>
88
[[nodiscard]]
auto
89
split
(T input, Delim_T delim) -> std::vector<T>
90
{
91
std::vector<T> output{};
92
std::size_t first{};
93
while
(first < std::size (input))
94
{
95
const
auto
second = input.find_first_of (delim, first);
96
if
(first != second)
97
{
98
output.emplace_back (input.substr (first, second - first));
99
}
100
if
(second == T::npos)
101
{
102
break
;
103
}
104
first = second + 1;
105
}
106
return
output;
107
}
108
109
// ------------------------------------------------------------------------
110
}
// namespace utility
111
112
// --------------------------------------------------------------------------
113
}
// namespace micro_os_plus::micro_test_plus
114
115
#if defined(__GNUC__)
116
#pragma GCC diagnostic pop
117
#endif
// defined(__GNUC__)
118
119
// ----------------------------------------------------------------------------
120
121
#endif
// defined(__cplusplus)
122
123
// ----------------------------------------------------------------------------
124
125
#endif
// MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_UTILITY_INLINES_H_
126
127
// ----------------------------------------------------------------------------
micro_os_plus::micro_test_plus::utility::split
auto split(T input, Delim_T delim) -> std::vector< T >
Split a string into a vector of sub-strings.
Definition
utility-inlines.h:89
micro_os_plus::micro_test_plus::utility
Utility functions for the µTest++ testing framework.
Definition
utility-inlines.h:65
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
inlines
utility-inlines.h
Generated by
1.17.0