From 20794e729ad9ad650bc2989e8a469a530585c635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Tue, 10 May 2022 18:21:19 +0200 Subject: [PATCH] Change string concatenation with boolean values The value of the boolean is now concatenated using the "true" or "false" instead of the conversion to integer (1 or 0). --- src/language/node_processor/ConcatExpressionProcessor.hpp | 4 ++-- tests/test_ConcatExpressionProcessor.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/language/node_processor/ConcatExpressionProcessor.hpp b/src/language/node_processor/ConcatExpressionProcessor.hpp index bb6357c87..718325641 100644 --- a/src/language/node_processor/ConcatExpressionProcessor.hpp +++ b/src/language/node_processor/ConcatExpressionProcessor.hpp @@ -16,11 +16,11 @@ class ConcatExpressionProcessor final : public INodeProcessor { if constexpr (std::is_same_v<B_DataT, std::string>) { return a + std::get<B_DataT>(b); - } else if constexpr (std::is_arithmetic_v<B_DataT>) { + } else if constexpr ((std::is_arithmetic_v<B_DataT>)and(not std::is_same_v<B_DataT, bool>)) { return a + std::to_string(std::get<B_DataT>(b)); } else { std::ostringstream os; - os << a << b; + os << a << std::boolalpha << b; return os.str(); } } diff --git a/tests/test_ConcatExpressionProcessor.cpp b/tests/test_ConcatExpressionProcessor.cpp index 4c5e202b7..7e8d097f9 100644 --- a/tests/test_ConcatExpressionProcessor.cpp +++ b/tests/test_ConcatExpressionProcessor.cpp @@ -74,7 +74,8 @@ TEST_CASE("ConcatExpressionProcessor", "[language]") SECTION("string + B") { - CHECK_CONCAT_EXPRESSION_RESULT(R"(let s:string, s = "foo_"; s = s+true;)", "s", std::string{"foo_1"}); + CHECK_CONCAT_EXPRESSION_RESULT(R"(let s:string, s = "foo_"; s = s+(2>1);)", "s", std::string{"foo_true"}); + CHECK_CONCAT_EXPRESSION_RESULT(R"(let s:string, s = "foo_"; s = s+(1>2);)", "s", std::string{"foo_false"}); } SECTION("string + R^1") -- GitLab