Added basic include diagram test case
This commit is contained in:
@@ -3,8 +3,17 @@ output_directory: puml
|
|||||||
diagrams:
|
diagrams:
|
||||||
t40001_include:
|
t40001_include:
|
||||||
type: include
|
type: include
|
||||||
|
# Provide the files to parse in order to look
|
||||||
|
# for #include directives
|
||||||
glob:
|
glob:
|
||||||
- ../../tests/t40001/t40001.cc
|
- ../../tests/t40001/**/*.cc
|
||||||
|
- ../../tests/t40001/**/*.h
|
||||||
|
# Render the paths relative to this directory
|
||||||
|
relative_to: ../../tests/t40001
|
||||||
|
include:
|
||||||
|
# Include only headers belonging to these paths
|
||||||
|
paths:
|
||||||
|
- ../../tests/t40001
|
||||||
plantuml:
|
plantuml:
|
||||||
before:
|
before:
|
||||||
- "' t40001 test include diagram"
|
- "' t40001 test include diagram"
|
||||||
7
tests/t40001/include/lib1/lib1.h
Normal file
7
tests/t40001/include/lib1/lib1.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace clanguml::t40001::lib1 {
|
||||||
|
|
||||||
|
int foo2() { return 0; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "include/t40001_include1.h"
|
#include "../include/t40001_include1.h"
|
||||||
|
|
||||||
namespace clanguml {
|
namespace clanguml {
|
||||||
namespace t40001 {
|
namespace t40001 {
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ TEST_CASE("t40001", "[test-case][package]")
|
|||||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsFolder("lib1"));
|
||||||
|
REQUIRE_THAT(puml, IsFile("lib1.h"));
|
||||||
|
REQUIRE_THAT(puml, IsFile("t40001.cc"));
|
||||||
|
REQUIRE_THAT(puml, IsFile("t40001_include1.h"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsAssociation(_A("t40001.cc"), _A("t40001_include1.h")));
|
||||||
|
REQUIRE_THAT(puml, IsAssociation(_A("t40001_include1.h"), _A("lib1.h")));
|
||||||
|
|
||||||
save_puml(
|
save_puml(
|
||||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,8 @@ std::string generate_package_puml(
|
|||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
|
assert(config.get() != nullptr);
|
||||||
|
|
||||||
ss << generator(
|
ss << generator(
|
||||||
dynamic_cast<clanguml::config::package_diagram &>(*config), model);
|
dynamic_cast<clanguml::config::package_diagram &>(*config), model);
|
||||||
|
|
||||||
@@ -169,6 +171,8 @@ std::string generate_include_puml(
|
|||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
|
assert(config.get() != nullptr);
|
||||||
|
|
||||||
ss << generator(
|
ss << generator(
|
||||||
dynamic_cast<clanguml::config::include_diagram &>(*config), model);
|
dynamic_cast<clanguml::config::include_diagram &>(*config), model);
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,10 @@ struct AliasMatcher {
|
|||||||
std::regex{"package\\s\"" + name + "\"\\sas\\s" + alias_regex});
|
std::regex{"package\\s\"" + name + "\"\\sas\\s" + alias_regex});
|
||||||
patterns.push_back(
|
patterns.push_back(
|
||||||
std::regex{"package\\s\\[" + name + "\\]\\sas\\s" + alias_regex});
|
std::regex{"package\\s\\[" + name + "\\]\\sas\\s" + alias_regex});
|
||||||
|
patterns.push_back(
|
||||||
|
std::regex{"file\\s\"?" + name + "\"?\\sas\\s" + alias_regex});
|
||||||
|
patterns.push_back(
|
||||||
|
std::regex{"folder\\s\"?" + name + "\"?\\sas\\s" + alias_regex});
|
||||||
|
|
||||||
std::smatch base_match;
|
std::smatch base_match;
|
||||||
|
|
||||||
@@ -260,10 +264,16 @@ ContainsMatcher IsAssociation(std::string const &from, std::string const &to,
|
|||||||
if (!multiplicity_dest.empty())
|
if (!multiplicity_dest.empty())
|
||||||
format_string += " \"" + multiplicity_dest + "\"";
|
format_string += " \"" + multiplicity_dest + "\"";
|
||||||
|
|
||||||
format_string += " {} : {}";
|
format_string += " {}";
|
||||||
|
|
||||||
return ContainsMatcher(CasedString(
|
if (!label.empty()) {
|
||||||
fmt::format(format_string, from, to, label), caseSensitivity));
|
format_string += " : {}";
|
||||||
|
return ContainsMatcher(CasedString(
|
||||||
|
fmt::format(format_string, from, to, label), caseSensitivity));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return ContainsMatcher(
|
||||||
|
CasedString(fmt::format(format_string, from, to), caseSensitivity));
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainsMatcher IsComposition(std::string const &from, std::string const &to,
|
ContainsMatcher IsComposition(std::string const &from, std::string const &to,
|
||||||
@@ -444,6 +454,18 @@ ContainsMatcher IsPackage(std::string const &str,
|
|||||||
CasedString("package [" + str + "]", caseSensitivity));
|
CasedString("package [" + str + "]", caseSensitivity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContainsMatcher IsFolder(std::string const &str,
|
||||||
|
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||||
|
{
|
||||||
|
return ContainsMatcher(CasedString("folder " + str, caseSensitivity));
|
||||||
|
}
|
||||||
|
|
||||||
|
ContainsMatcher IsFile(std::string const &str,
|
||||||
|
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||||
|
{
|
||||||
|
return ContainsMatcher(CasedString("file " + str, caseSensitivity));
|
||||||
|
}
|
||||||
|
|
||||||
ContainsMatcher IsDeprecated(std::string const &str,
|
ContainsMatcher IsDeprecated(std::string const &str,
|
||||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
#include <cx/util.h>
|
#include <cx/util.h>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include "catch.h"
|
#include "catch.h"
|
||||||
|
|
||||||
TEST_CASE("Test split", "[unit-test]")
|
TEST_CASE("Test split", "[unit-test]")
|
||||||
@@ -47,6 +49,23 @@ TEST_CASE("Test abbreviate", "[unit-test]")
|
|||||||
CHECK(abbreviate("abcdefg", 5) == "ab...");
|
CHECK(abbreviate("abcdefg", 5) == "ab...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Test starts_with", "[unit-test]")
|
||||||
|
{
|
||||||
|
using clanguml::util::starts_with;
|
||||||
|
using std::filesystem::path;
|
||||||
|
|
||||||
|
CHECK(starts_with(path{"/a/b/c/d"}, path{"/"}));
|
||||||
|
CHECK(!starts_with(path{"/a/b/c/d"}, path{"/a/b/c/d/e"}));
|
||||||
|
CHECK(starts_with(path{"/a/b/c/d/e"}, path{"/a/b/c/d"}));
|
||||||
|
CHECK(starts_with(path{"/a/b/c/d/e"}, path{"/a/b/c/d/"}));
|
||||||
|
CHECK(!starts_with(path{"/e/f/c/d/file.h"}, path{"/a/b"}));
|
||||||
|
CHECK(!starts_with(path{"/e/f/c/d/file.h"}, path{"/a/b/"}));
|
||||||
|
CHECK(starts_with(path{"/a/b/c/d/file.h"}, path{"/a/b/c"}));
|
||||||
|
CHECK(starts_with(path{"/a/b/c/file.h"}, path{"/a/b/c/file.h"}));
|
||||||
|
CHECK(starts_with(path{"c/file.h"}, path{"c"}));
|
||||||
|
CHECK(starts_with(path{"c/file.h"}, path{"c/"}));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Test replace_all", "[unit-test]")
|
TEST_CASE("Test replace_all", "[unit-test]")
|
||||||
{
|
{
|
||||||
using namespace clanguml::util;
|
using namespace clanguml::util;
|
||||||
|
|||||||
Reference in New Issue
Block a user