Skip to content

Commit

Permalink
🐛 Fix #569 - test.name lifetime with dynamic names
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-jusiak committed Feb 21, 2024
1 parent 788f6b4 commit 48389c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions include/boost/ut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ struct suite_end {
template <class Test, class TArg = none>
struct test {
std::string_view type{};
std::string_view name{};
std::string name{}; /// might be dynamic
std::vector<std::string_view> tag{};
reflection::source_location location{};
TArg arg{};
Expand Down Expand Up @@ -2265,7 +2265,7 @@ struct test {
template <class... Ts>
constexpr auto operator=(test_location<void (*)()> _test) {
on<Ts...>(events::test<void (*)()>{.type = type,
.name = name,
.name = std::string{name},
.tag = tag,
.location = _test.location,
.arg = none{},
Expand All @@ -2279,7 +2279,7 @@ struct test {
constexpr auto operator=(Test _test) ->
typename type_traits::identity<Test, decltype(_test())>::type {
on<Test>(events::test<Test>{.type = type,
.name = name,
.name = std::string{name},
.tag = tag,
.location = {},
.arg = none{},
Expand Down Expand Up @@ -2716,7 +2716,7 @@ template <class F, class T,
for (const auto& arg : t) {
detail::on<F>(events::test<F, decltype(arg)>{
.type = "test",
.name = name,
.name = std::string{name},
.tag = {},
.location = {},
.arg = arg,
Expand All @@ -2733,7 +2733,7 @@ template <
apply(
[f, name](const auto&... args) {
(detail::on<F>(events::test<F, Ts>{.type = "test",
.name = name,
.name = std::string{name},
.tag = {},
.location = {},
.arg = args,
Expand Down
4 changes: 2 additions & 2 deletions test/ut/ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct fake_cfg {

struct test_call {
std::string_view type{};
std::string_view name{};
std::string name{};
ut::reflection::source_location location{};
std::any arg{};
};
Expand Down Expand Up @@ -137,7 +137,7 @@ struct fake_cfg {
template <class... Ts>
auto on(ut::events::skip<Ts...> test) -> void {
skip_calls.push_back(
{.type = test.type, .name = test.name, .arg = test.arg});
{.type = test.type, .name = std::string{test.name}, .arg = test.arg});
}

template <class TExpr>
Expand Down

0 comments on commit 48389c1

Please sign in to comment.