From 2ca0ebd89c7a0d4b7bed85c41cffb503193484c6 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 29 Dec 2021 09:52:38 +0100 Subject: [PATCH] :rotating_light: fix warnings --- test/src/unit-regression2.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 1077a21f5..db27a2c4e 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -231,10 +231,14 @@ inline void from_json(const nlohmann::json& j, FooBar& fb) // for #3215 ///////////////////////////////////////////////////////////////////// -std::string f_3215() +std::string f_3215(bool should_throw); +std::string f_3215(bool should_throw) { - throw std::runtime_error("12"); - return {}; + if (should_throw) + { + throw std::runtime_error("12"); + } + return "foo"; } TEST_CASE("regression tests 2") @@ -782,8 +786,8 @@ TEST_CASE("regression tests 2") // std::map j // no leak nlohmann::json j // leak { - {"smth", f_3215()}, // exception thrown here - {"smth", "smth"} + {"smth", f_3215(true)}, // exception thrown here + {"smth", f_3215(false)} }; s = "initialized"; }