From 48389c129fe7293940ffe4d4587181209822dbbd Mon Sep 17 00:00:00 2001 From: Kris Jusiak Date: Wed, 21 Feb 2024 04:44:18 -0600 Subject: [PATCH] :bug: Fix #569 - test.name lifetime with dynamic names --- include/boost/ut.hpp | 10 +++++----- test/ut/ut.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/ut.hpp b/include/boost/ut.hpp index 05a1790e..3aa586de 100644 --- a/include/boost/ut.hpp +++ b/include/boost/ut.hpp @@ -597,7 +597,7 @@ struct suite_end { template struct test { std::string_view type{}; - std::string_view name{}; + std::string name{}; /// might be dynamic std::vector tag{}; reflection::source_location location{}; TArg arg{}; @@ -2265,7 +2265,7 @@ struct test { template constexpr auto operator=(test_location _test) { on(events::test{.type = type, - .name = name, + .name = std::string{name}, .tag = tag, .location = _test.location, .arg = none{}, @@ -2279,7 +2279,7 @@ struct test { constexpr auto operator=(Test _test) -> typename type_traits::identity::type { on(events::test{.type = type, - .name = name, + .name = std::string{name}, .tag = tag, .location = {}, .arg = none{}, @@ -2716,7 +2716,7 @@ template (events::test{ .type = "test", - .name = name, + .name = std::string{name}, .tag = {}, .location = {}, .arg = arg, @@ -2733,7 +2733,7 @@ template < apply( [f, name](const auto&... args) { (detail::on(events::test{.type = "test", - .name = name, + .name = std::string{name}, .tag = {}, .location = {}, .arg = args, diff --git a/test/ut/ut.cpp b/test/ut/ut.cpp index 563d3f74..f840d3d6 100644 --- a/test/ut/ut.cpp +++ b/test/ut/ut.cpp @@ -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{}; }; @@ -137,7 +137,7 @@ struct fake_cfg { template auto on(ut::events::skip 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