# t20021 - Loop statements sequence diagram test case ## Config ```yaml diagrams: t20021_sequence: type: sequence glob: - t20021.cc include: namespaces: - clanguml::t20021 using_namespace: clanguml::t20021 from: - function: "clanguml::t20021::tmain()" ``` ## Source code File `tests/t20021/t20021.cc` ```cpp #include namespace clanguml { namespace t20021 { struct A { int a1() { return 0; } int a2() { return 1; } int a3() { return 2; } }; struct B { void log() { } int b1() const { return 3; } int b2() const { return 4; } }; struct C { int c1() { return 1; } int c2() { return 2; } int c3() { return 3; } int c4() { return c5(); } int c5() { return 5; } std::vector &contents() { return contents_; } std::vector contents_; }; int tmain() { A a; std::vector b; C c; int i = 10; while (i -= c.c4()) { int j = a.a3(); do { for (int l = a.a2(); l > c.c1(); l -= c.c2()) a.a1(); } while (j -= c.c3()); } int result = 0; for (const auto &bi : b) { result += bi.b2(); } for (const auto &ci : c.contents()) { result += ci; } return b.front().b2() + result; } } } ``` ## Generated PlantUML diagrams ![t20021_sequence](./t20021_sequence.svg "Loop statements sequence diagram test case") ## Generated Mermaid diagrams ![t20021_sequence](./t20021_sequence_mermaid.svg "Loop statements sequence diagram test case") ## Generated JSON models ```json { "diagram_type": "sequence", "name": "t20021_sequence", "participants": [ { "display_name": "tmain()", "id": "1682631020380557915", "name": "tmain", "namespace": "clanguml::t20021", "source_location": { "column": 5, "file": "t20021.cc", "line": 30, "translation_unit": "t20021.cc" }, "type": "function" }, { "activities": [ { "display_name": "c4()", "id": "124927877622321176", "name": "c4", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 22, "translation_unit": "t20021.cc" }, "type": "method" }, { "display_name": "c5()", "id": "1325720714179808628", "name": "c5", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 23, "translation_unit": "t20021.cc" }, "type": "method" }, { "display_name": "c1()", "id": "2143764740072323303", "name": "c1", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 19, "translation_unit": "t20021.cc" }, "type": "method" }, { "display_name": "c2()", "id": "1707693479408501017", "name": "c2", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 20, "translation_unit": "t20021.cc" }, "type": "method" }, { "display_name": "c3()", "id": "1302892753246800390", "name": "c3", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 21, "translation_unit": "t20021.cc" }, "type": "method" }, { "display_name": "contents()", "id": "814405216385697964", "name": "contents", "namespace": "", "source_location": { "column": 23, "file": "t20021.cc", "line": 25, "translation_unit": "t20021.cc" }, "type": "method" } ], "display_name": "C", "id": "451128000259357438", "name": "C", "namespace": "clanguml::t20021", "source_location": { "column": 8, "file": "t20021.cc", "line": 18, "translation_unit": "t20021.cc" }, "type": "class" }, { "activities": [ { "display_name": "a3()", "id": "1867955233624891190", "name": "a3", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 8, "translation_unit": "t20021.cc" }, "type": "method" }, { "display_name": "a2()", "id": "1139294797758415018", "name": "a2", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 7, "translation_unit": "t20021.cc" }, "type": "method" }, { "display_name": "a1()", "id": "1659488549696810992", "name": "a1", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 6, "translation_unit": "t20021.cc" }, "type": "method" } ], "display_name": "A", "id": "1280483607329510730", "name": "A", "namespace": "clanguml::t20021", "source_location": { "column": 8, "file": "t20021.cc", "line": 5, "translation_unit": "t20021.cc" }, "type": "class" }, { "activities": [ { "display_name": "b2() const", "id": "1561040999276563077", "name": "b2", "namespace": "", "source_location": { "column": 9, "file": "t20021.cc", "line": 15, "translation_unit": "t20021.cc" }, "type": "method" } ], "display_name": "B", "id": "1849696080443395393", "name": "B", "namespace": "clanguml::t20021", "source_location": { "column": 8, "file": "t20021.cc", "line": 11, "translation_unit": "t20021.cc" }, "type": "class" } ], "sequences": [ { "messages": [ { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "c4()", "return_type": "int", "scope": "condition", "source_location": { "column": 17, "file": "t20021.cc", "line": 37, "translation_unit": "t20021.cc" }, "to": { "activity_id": "124927877622321176", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "124927877622321176", "participant_id": "451128000259357438" }, "name": "c5()", "return_type": "int", "scope": "normal", "source_location": { "column": 23, "file": "t20021.cc", "line": 22, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1325720714179808628", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "a3()", "return_type": "int", "scope": "normal", "source_location": { "column": 17, "file": "t20021.cc", "line": 38, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1867955233624891190", "participant_id": "1280483607329510730" }, "type": "message" }, { "activity_id": "1682631020380557915", "messages": [ { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "a2()", "return_type": "int", "scope": "condition", "source_location": { "column": 26, "file": "t20021.cc", "line": 40, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1139294797758415018", "participant_id": "1280483607329510730" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "c1()", "return_type": "int", "scope": "condition", "source_location": { "column": 38, "file": "t20021.cc", "line": 40, "translation_unit": "t20021.cc" }, "to": { "activity_id": "2143764740072323303", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "c2()", "return_type": "int", "scope": "condition", "source_location": { "column": 51, "file": "t20021.cc", "line": 40, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1707693479408501017", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "a1()", "return_type": "int", "scope": "normal", "source_location": { "column": 17, "file": "t20021.cc", "line": 41, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1659488549696810992", "participant_id": "1280483607329510730" }, "type": "message" } ], "name": "for", "type": "loop" }, { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "c3()", "return_type": "int", "scope": "condition", "source_location": { "column": 23, "file": "t20021.cc", "line": 42, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1302892753246800390", "participant_id": "451128000259357438" }, "type": "message" } ], "name": "do", "type": "loop" } ], "name": "while", "type": "loop" }, { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "b2() const", "return_type": "int", "scope": "normal", "source_location": { "column": 19, "file": "t20021.cc", "line": 47, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1561040999276563077", "participant_id": "1849696080443395393" }, "type": "message" } ], "name": "for", "type": "loop" }, { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "contents()", "return_type": "std::vector &", "scope": "condition", "source_location": { "column": 27, "file": "t20021.cc", "line": 50, "translation_unit": "t20021.cc" }, "to": { "activity_id": "814405216385697964", "participant_id": "451128000259357438" }, "type": "message" } ], "name": "for", "type": "loop" }, { "from": { "activity_id": "1682631020380557915", "participant_id": "1682631020380557915" }, "name": "b2() const", "return_type": "int", "scope": "normal", "source_location": { "column": 12, "file": "t20021.cc", "line": 54, "translation_unit": "t20021.cc" }, "to": { "activity_id": "1561040999276563077", "participant_id": "1849696080443395393" }, "type": "message" } ], "start_from": { "id": 1682631020380557915, "location": "clanguml::t20021::tmain()" } } ], "using_namespace": "clanguml::t20021" } ```