# t20028 - Conditional (ternary) '?:' operator test case ## Config ```yaml diagrams: t20028_sequence: type: sequence glob: - t20028.cc include: namespaces: - clanguml::t20028 exclude: namespaces: - clanguml::t20028::detail using_namespace: clanguml::t20028 from: - function: "clanguml::t20028::tmain()" ``` ## Source code File `tests/t20028/t20028.cc` ```cpp namespace clanguml { namespace t20028 { struct A { int a() { return 0; } int b() { return 1; } int c() { return 2; } int d() { return 3; } }; namespace detail { struct B { int e() { return 4; } }; } // namespace detail int tmain() { A a; detail::B b; int result{}; result = b.e() ? b.e() : 12; result += a.a() ? a.b() + a.c() : a.d(); return result; } } } ``` ## Generated PlantUML diagrams ![t20028_sequence](./t20028_sequence.svg "Conditional (ternary) '?:' operator test case") ## Generated Mermaid diagrams ![t20028_sequence](./t20028_sequence_mermaid.svg "Conditional (ternary) '?:' operator test case") ## Generated JSON models ```json { "diagram_type": "sequence", "name": "t20028_sequence", "participants": [ { "display_name": "tmain()", "id": "1347206662193933194", "name": "tmain", "namespace": "clanguml::t20028", "source_location": { "column": 5, "file": "t20028.cc", "line": 17, "translation_unit": "t20028.cc" }, "type": "function" }, { "activities": [ { "display_name": "a()", "id": "666210834901940781", "name": "a", "namespace": "", "source_location": { "column": 9, "file": "t20028.cc", "line": 5, "translation_unit": "t20028.cc" }, "type": "method" }, { "display_name": "b()", "id": "793793464184037795", "name": "b", "namespace": "", "source_location": { "column": 9, "file": "t20028.cc", "line": 6, "translation_unit": "t20028.cc" }, "type": "method" }, { "display_name": "c()", "id": "1582152567698110078", "name": "c", "namespace": "", "source_location": { "column": 9, "file": "t20028.cc", "line": 7, "translation_unit": "t20028.cc" }, "type": "method" }, { "display_name": "d()", "id": "1178268687951492696", "name": "d", "namespace": "", "source_location": { "column": 9, "file": "t20028.cc", "line": 8, "translation_unit": "t20028.cc" }, "type": "method" } ], "display_name": "A", "id": "2073479923903128898", "name": "A", "namespace": "clanguml::t20028", "source_location": { "column": 8, "file": "t20028.cc", "line": 4, "translation_unit": "t20028.cc" }, "type": "class" } ], "sequences": [ { "messages": [ { "activity_id": "1347206662193933194", "branches": [ { "messages": [ { "from": { "activity_id": "1347206662193933194", "participant_id": "1347206662193933194" }, "name": "a()", "return_type": "int", "scope": "condition", "source_location": { "column": 15, "file": "t20028.cc", "line": 26, "translation_unit": "t20028.cc" }, "to": { "activity_id": "666210834901940781", "participant_id": "2073479923903128898" }, "type": "message" }, { "from": { "activity_id": "1347206662193933194", "participant_id": "1347206662193933194" }, "name": "b()", "return_type": "int", "scope": "normal", "source_location": { "column": 23, "file": "t20028.cc", "line": 26, "translation_unit": "t20028.cc" }, "to": { "activity_id": "793793464184037795", "participant_id": "2073479923903128898" }, "type": "message" }, { "from": { "activity_id": "1347206662193933194", "participant_id": "1347206662193933194" }, "name": "c()", "return_type": "int", "scope": "normal", "source_location": { "column": 31, "file": "t20028.cc", "line": 26, "translation_unit": "t20028.cc" }, "to": { "activity_id": "1582152567698110078", "participant_id": "2073479923903128898" }, "type": "message" } ], "type": "consequent" }, { "messages": [ { "from": { "activity_id": "1347206662193933194", "participant_id": "1347206662193933194" }, "name": "d()", "return_type": "int", "scope": "normal", "source_location": { "column": 39, "file": "t20028.cc", "line": 26, "translation_unit": "t20028.cc" }, "to": { "activity_id": "1178268687951492696", "participant_id": "2073479923903128898" }, "type": "message" } ], "type": "alternative" } ], "name": "conditional", "type": "alt" } ], "start_from": { "id": 1347206662193933194, "location": "clanguml::t20028::tmain()" } } ], "using_namespace": "clanguml::t20028" } ```