Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix #569 - test.name lifetime with dynamic names #612

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading