Updated test case documentation
This commit is contained in:
97
docs/test_cases/t20012.md
Normal file
97
docs/test_cases/t20012.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# t20012 - Lambda expression call sequence diagram test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t20012_sequence:
|
||||
type: sequence
|
||||
glob:
|
||||
- ../../tests/t20012/t20012.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t20012
|
||||
using_namespace:
|
||||
- clanguml::t20012
|
||||
start_from:
|
||||
- function: "clanguml::t20012::tmain()"
|
||||
```
|
||||
## Source code
|
||||
File t20012.cc
|
||||
```cpp
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t20012 {
|
||||
struct A {
|
||||
void a() { aa(); }
|
||||
|
||||
void aa() { aaa(); }
|
||||
|
||||
void aaa() { }
|
||||
};
|
||||
|
||||
struct B {
|
||||
void b() { bb(); }
|
||||
|
||||
void bb() { bbb(); }
|
||||
|
||||
void bbb() { }
|
||||
};
|
||||
|
||||
struct C {
|
||||
void c() { cc(); }
|
||||
|
||||
void cc() { ccc(); }
|
||||
|
||||
void ccc() { }
|
||||
};
|
||||
|
||||
template <typename F> struct R {
|
||||
R(F &&f)
|
||||
: f_{std::move(f)}
|
||||
{
|
||||
}
|
||||
|
||||
void r() { f_(); }
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
void tmain()
|
||||
{
|
||||
A a;
|
||||
B b;
|
||||
C c;
|
||||
|
||||
// The activity shouldn't be marked at the lambda definition, but
|
||||
// wherever it is actually called...
|
||||
auto alambda = [&a, &b]() {
|
||||
a.a();
|
||||
b.b();
|
||||
};
|
||||
|
||||
// ...like here
|
||||
alambda();
|
||||
|
||||
// There should be no call to B in the sequence diagram as the blambda
|
||||
// is never called
|
||||
[[maybe_unused]] auto blambda = [&b]() { b.b(); };
|
||||
|
||||
// Nested lambdas should also work
|
||||
auto clambda = [alambda, &c]() {
|
||||
c.c();
|
||||
alambda();
|
||||
};
|
||||
clambda();
|
||||
|
||||
R r{[&c]() { c.c(); }};
|
||||
|
||||
r.r();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
Reference in New Issue
Block a user