Skip to content

Latest commit

 

History

History
556 lines (546 loc) · 15.2 KB

t20024.md

File metadata and controls

556 lines (546 loc) · 15.2 KB

t20024 - Switch statement sequence diagram test case

Config

diagrams:
  t20024_sequence:
    type: sequence
    glob:
      - t20024.cc
    include:
      namespaces:
        - clanguml::t20024
    using_namespace: clanguml::t20024
    from:
      - function: "clanguml::t20024::tmain()"

Source code

File tests/t20024/t20024.cc

namespace clanguml {
namespace t20024 {

enum enum_a { zero = 0, one = 1, two = 2, three = 3 };

enum class colors { red, orange, green };

struct A {
    int select(enum_a v)
    {
        switch (v) {
        case zero:
            return a0();
        case one:
            return a1();
        case two:
            return a2();
        default:
            return a3();
        }
    }

    int a0() { return 0; }
    int a1() { return 1; }
    int a2() { return 2; }
    int a3() { return 3; }
};

struct B {
    void select(colors c)
    {
        switch (c) {
        case colors::red:
            red();
            break;
        case colors::orange:
            orange();
            break;
        case colors::green:
            green();
            break;
        default:
            grey();
        }
    }

    void red() { }
    void orange() { }
    void green() { }
    void grey() { }
};

int tmain()
{
    A a;
    B b;

    a.select(enum_a::two);

    b.select(colors::green);

    return 0;
}
}
}

Generated PlantUML diagrams

t20024_sequence

Generated Mermaid diagrams

t20024_sequence

Generated JSON models

{
  "diagram_type": "sequence",
  "name": "t20024_sequence",
  "participants": [
    {
      "display_name": "tmain()",
      "full_name": "clanguml::t20024::tmain()",
      "id": "1919714441225983014",
      "name": "tmain",
      "namespace": "clanguml::t20024",
      "source_location": {
        "column": 5,
        "file": "t20024.cc",
        "line": 53,
        "translation_unit": "t20024.cc"
      },
      "type": "function"
    },
    {
      "activities": [
        {
          "display_name": "select(enum_a)",
          "full_name": "clanguml::t20024::A::select(enum_a)",
          "id": "1200587047701031901",
          "name": "select",
          "namespace": "",
          "source_location": {
            "column": 9,
            "file": "t20024.cc",
            "line": 9,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "a0()",
          "full_name": "clanguml::t20024::A::a0()",
          "id": "1859614580641799156",
          "name": "a0",
          "namespace": "",
          "source_location": {
            "column": 9,
            "file": "t20024.cc",
            "line": 23,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "a1()",
          "full_name": "clanguml::t20024::A::a1()",
          "id": "501598940454911460",
          "name": "a1",
          "namespace": "",
          "source_location": {
            "column": 9,
            "file": "t20024.cc",
            "line": 24,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "a2()",
          "full_name": "clanguml::t20024::A::a2()",
          "id": "1698866541173753340",
          "name": "a2",
          "namespace": "",
          "source_location": {
            "column": 9,
            "file": "t20024.cc",
            "line": 25,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "a3()",
          "full_name": "clanguml::t20024::A::a3()",
          "id": "490376438551958259",
          "name": "a3",
          "namespace": "",
          "source_location": {
            "column": 9,
            "file": "t20024.cc",
            "line": 26,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        }
      ],
      "display_name": "A",
      "full_name": "clanguml::t20024::A",
      "id": "40786919835708828",
      "name": "A",
      "namespace": "clanguml::t20024",
      "source_location": {
        "column": 8,
        "file": "t20024.cc",
        "line": 8,
        "translation_unit": "t20024.cc"
      },
      "type": "class"
    },
    {
      "activities": [
        {
          "display_name": "select(colors)",
          "full_name": "clanguml::t20024::B::select(colors)",
          "id": "286108218156977422",
          "name": "select",
          "namespace": "",
          "source_location": {
            "column": 10,
            "file": "t20024.cc",
            "line": 30,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "red()",
          "full_name": "clanguml::t20024::B::red()",
          "id": "112014563206084467",
          "name": "red",
          "namespace": "",
          "source_location": {
            "column": 10,
            "file": "t20024.cc",
            "line": 47,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "orange()",
          "full_name": "clanguml::t20024::B::orange()",
          "id": "2222823236498505185",
          "name": "orange",
          "namespace": "",
          "source_location": {
            "column": 10,
            "file": "t20024.cc",
            "line": 48,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "green()",
          "full_name": "clanguml::t20024::B::green()",
          "id": "519021723720658376",
          "name": "green",
          "namespace": "",
          "source_location": {
            "column": 10,
            "file": "t20024.cc",
            "line": 49,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        },
        {
          "display_name": "grey()",
          "full_name": "clanguml::t20024::B::grey()",
          "id": "1813557671878544737",
          "name": "grey",
          "namespace": "",
          "source_location": {
            "column": 10,
            "file": "t20024.cc",
            "line": 50,
            "translation_unit": "t20024.cc"
          },
          "type": "method"
        }
      ],
      "display_name": "B",
      "full_name": "clanguml::t20024::B",
      "id": "933287014626440872",
      "name": "B",
      "namespace": "clanguml::t20024",
      "source_location": {
        "column": 8,
        "file": "t20024.cc",
        "line": 29,
        "translation_unit": "t20024.cc"
      },
      "type": "class"
    }
  ],
  "sequences": [
    {
      "messages": [
        {
          "from": {
            "activity_id": "1919714441225983014",
            "participant_id": "1919714441225983014"
          },
          "name": "select(enum_a)",
          "return_type": "int",
          "scope": "normal",
          "source_location": {
            "column": 5,
            "file": "t20024.cc",
            "line": 58,
            "translation_unit": "t20024.cc"
          },
          "to": {
            "activity_id": "1200587047701031901",
            "participant_id": "40786919835708828"
          },
          "type": "message"
        },
        {
          "activity_id": "1200587047701031901",
          "branches": [
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "1200587047701031901",
                    "participant_id": "40786919835708828"
                  },
                  "name": "a0()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "column": 20,
                    "file": "t20024.cc",
                    "line": 13,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "1859614580641799156",
                    "participant_id": "40786919835708828"
                  },
                  "type": "message"
                }
              ],
              "name": "zero",
              "type": "case"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "1200587047701031901",
                    "participant_id": "40786919835708828"
                  },
                  "name": "a1()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "column": 20,
                    "file": "t20024.cc",
                    "line": 15,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "501598940454911460",
                    "participant_id": "40786919835708828"
                  },
                  "type": "message"
                }
              ],
              "name": "one",
              "type": "case"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "1200587047701031901",
                    "participant_id": "40786919835708828"
                  },
                  "name": "a2()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "column": 20,
                    "file": "t20024.cc",
                    "line": 17,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "1698866541173753340",
                    "participant_id": "40786919835708828"
                  },
                  "type": "message"
                }
              ],
              "name": "two",
              "type": "case"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "1200587047701031901",
                    "participant_id": "40786919835708828"
                  },
                  "name": "a3()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "column": 20,
                    "file": "t20024.cc",
                    "line": 19,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "490376438551958259",
                    "participant_id": "40786919835708828"
                  },
                  "type": "message"
                }
              ],
              "name": "default",
              "type": "case"
            }
          ],
          "name": "switch",
          "type": "alt"
        },
        {
          "from": {
            "activity_id": "1919714441225983014",
            "participant_id": "1919714441225983014"
          },
          "name": "select(colors)",
          "return_type": "void",
          "scope": "normal",
          "source_location": {
            "column": 5,
            "file": "t20024.cc",
            "line": 60,
            "translation_unit": "t20024.cc"
          },
          "to": {
            "activity_id": "286108218156977422",
            "participant_id": "933287014626440872"
          },
          "type": "message"
        },
        {
          "activity_id": "286108218156977422",
          "branches": [
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "286108218156977422",
                    "participant_id": "933287014626440872"
                  },
                  "name": "red()",
                  "return_type": "void",
                  "scope": "normal",
                  "source_location": {
                    "column": 13,
                    "file": "t20024.cc",
                    "line": 34,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "112014563206084467",
                    "participant_id": "933287014626440872"
                  },
                  "type": "message"
                }
              ],
              "name": "enum colors::red",
              "type": "case"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "286108218156977422",
                    "participant_id": "933287014626440872"
                  },
                  "name": "orange()",
                  "return_type": "void",
                  "scope": "normal",
                  "source_location": {
                    "column": 13,
                    "file": "t20024.cc",
                    "line": 37,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "2222823236498505185",
                    "participant_id": "933287014626440872"
                  },
                  "type": "message"
                }
              ],
              "name": "enum colors::orange",
              "type": "case"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "286108218156977422",
                    "participant_id": "933287014626440872"
                  },
                  "name": "green()",
                  "return_type": "void",
                  "scope": "normal",
                  "source_location": {
                    "column": 13,
                    "file": "t20024.cc",
                    "line": 40,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "519021723720658376",
                    "participant_id": "933287014626440872"
                  },
                  "type": "message"
                }
              ],
              "name": "enum colors::green",
              "type": "case"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "286108218156977422",
                    "participant_id": "933287014626440872"
                  },
                  "name": "grey()",
                  "return_type": "void",
                  "scope": "normal",
                  "source_location": {
                    "column": 13,
                    "file": "t20024.cc",
                    "line": 43,
                    "translation_unit": "t20024.cc"
                  },
                  "to": {
                    "activity_id": "1813557671878544737",
                    "participant_id": "933287014626440872"
                  },
                  "type": "message"
                }
              ],
              "name": "default",
              "type": "case"
            }
          ],
          "name": "switch",
          "type": "alt"
        }
      ],
      "start_from": {
        "id": 1919714441225983014,
        "location": "clanguml::t20024::tmain()"
      }
    }
  ],
  "using_namespace": "clanguml::t20024"
}