-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed handling of multiple lambda expressions in a single function call
- Loading branch information
Showing
9 changed files
with
208 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
diagrams: | ||
t20060_sequence: | ||
type: sequence | ||
glob: | ||
- t20060.cc | ||
include: | ||
namespaces: | ||
- clanguml::t20060 | ||
exclude: | ||
paths: | ||
- include/t20060.h | ||
using_namespace: clanguml::t20060 | ||
from: | ||
- function: "clanguml::t20060::tmain()" | ||
t20060_sequence_inlined: | ||
type: sequence | ||
inline_lambda_messages: true | ||
glob: | ||
- t20060.cc | ||
include: | ||
namespaces: | ||
- clanguml::t20060 | ||
exclude: | ||
paths: | ||
- include/t20060.h | ||
using_namespace: clanguml::t20060 | ||
from: | ||
- function: "clanguml::t20060::tmain()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <algorithm> | ||
#include <iterator> | ||
|
||
namespace clanguml { | ||
namespace t20060 { | ||
|
||
namespace util { | ||
|
||
template <typename T, typename C, typename F> | ||
void for_each_if(const T &collection, C &&cond, F &&func) | ||
{ | ||
std::for_each(std::begin(collection), std::end(collection), | ||
[cond = std::forward<decltype(cond)>(cond), | ||
func = std::forward<decltype(func)>(func)](auto &e) mutable { | ||
if (cond(e)) | ||
func(e); | ||
}); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "include/t20060.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace clanguml { | ||
namespace t20060 { | ||
|
||
bool is_empty(const std::string &t) { return t.empty(); } | ||
|
||
void log() { } | ||
|
||
void tmain() | ||
{ | ||
std::vector<std::string> vs; | ||
|
||
std::string out; | ||
|
||
util::for_each_if( | ||
vs, [](const auto &s) { return !is_empty(s); }, | ||
[&](const auto &s) { | ||
log(); | ||
out += s; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* tests/t20060/test_case.h | ||
* | ||
* Copyright (c) 2021-2024 Bartek Kryza <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
TEST_CASE("t20060") | ||
{ | ||
using namespace clanguml::test; | ||
using namespace std::string_literals; | ||
|
||
{ | ||
auto [config, db, diagram, model] = | ||
CHECK_SEQUENCE_MODEL("t20060", "t20060_sequence"); | ||
|
||
CHECK_SEQUENCE_DIAGRAM(*config, diagram, *model, [](const auto &src) { | ||
REQUIRE(MessageOrder(src, | ||
{// | ||
{"tmain()", "tmain()::(lambda t20060.cc:20:13)", | ||
"operator()(const auto &) const"}, // | ||
{"tmain()::(lambda t20060.cc:20:13)", | ||
"is_empty(const std::string &)", ""}, // | ||
{"tmain()", "tmain()::(lambda t20060.cc:21:9)", | ||
"operator()(const auto &) const"}, | ||
{"tmain()::(lambda t20060.cc:21:9)", "log()", ""} | ||
|
||
})); | ||
}); | ||
} | ||
|
||
{ | ||
auto [config, db, diagram, model] = | ||
CHECK_SEQUENCE_MODEL("t20060", "t20060_sequence_inlined"); | ||
|
||
CHECK_SEQUENCE_DIAGRAM(*config, diagram, *model, [](const auto &src) { | ||
REQUIRE(MessageOrder(src, | ||
{ // | ||
{"tmain()", "is_empty(const std::string &)", ""}, // | ||
{"tmain()", "log()", ""} | ||
|
||
})); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters