def test_given_two_functions_included__export_returns_diagram_with_call(): manager = CallTreeManager() with generate_file('file.cpp', 'void f();\nvoid g() { f(); }') as file_name: manager.open(file_name) manager.select_tu(file_name) manager.select_root('g()') manager.include('g()') manager.include('f()') expected = '@startuml\n\n -> "file.cpp": g()\nactivate "file.cpp"\n"file.cpp" -> "file.cpp": f()\nactivate "file.cpp"\ndeactivate "file.cpp"\ndeactivate "file.cpp"\n\n@enduml' actual = manager.export() assert actual == expected
def test_given_methods_of_same_class__use_class_as_participant(): manager = CallTreeManager() with generate_file('file.cpp', 'class Foo {\nvoid bar();\nvoid baz() { bar(); }\n};' ) as file_name: manager.open(file_name) manager.select_tu(file_name) manager.select_root('Foo::baz()') manager.include('Foo::baz()') manager.include('Foo::bar()') expected = '@startuml\n\n -> "Foo": baz()\nactivate "Foo"\n"Foo" -> "Foo": bar()\nactivate "Foo"\ndeactivate "Foo"\ndeactivate "Foo"\n\n@enduml' actual = manager.export() assert actual == expected
def test_given_call_graph_of_depth_two__functions_exported_depth_first(): manager = CallTreeManager() with generate_file( 'file.cpp', 'void i();\nvoid h();\nvoid g() { h(); }\nvoid f() { g();\ni(); }' ) as file_name: manager.open(file_name) manager.select_tu(file_name) manager.select_root('f()') manager.include('f()') manager.include('g()') manager.include('h()') manager.include('i()') expected = '@startuml\n\n -> "file.cpp": f()\nactivate "file.cpp"\n"file.cpp" -> "file.cpp": g()\nactivate "file.cpp"\n"file.cpp" -> "file.cpp": h()\nactivate "file.cpp"\ndeactivate "file.cpp"\ndeactivate "file.cpp"\n"file.cpp" -> "file.cpp": i()\nactivate "file.cpp"\ndeactivate "file.cpp"\ndeactivate "file.cpp"\n\n@enduml' actual = manager.export() assert actual == expected