Added relationship and scope filter test case
This commit is contained in:
@@ -158,7 +158,7 @@ std::optional<bool> subclass_filter::match(
|
||||
relationship_filter::relationship_filter(
|
||||
filter_t type, std::vector<relationship_t> relationships)
|
||||
: filter_visitor{type}
|
||||
, relationships_{std::move(relationships)}
|
||||
, relationships_{relationships}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ std::optional<bool> relationship_filter::match(
|
||||
|
||||
scope_filter::scope_filter(filter_t type, std::vector<scope_t> scopes)
|
||||
: filter_visitor{type}
|
||||
, scopes_{std::move(scopes)}
|
||||
, scopes_{scopes}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -263,9 +263,9 @@ void diagram_filter::init_filters(const config::diagram &c)
|
||||
exclusive_.emplace_back(std::make_unique<element_filter>(
|
||||
filter_t::kExclusive, c.exclude().elements));
|
||||
exclusive_.emplace_back(std::make_unique<relationship_filter>(
|
||||
filter_t::kExclusive, c.include().relationships));
|
||||
filter_t::kExclusive, c.exclude().relationships));
|
||||
exclusive_.emplace_back(std::make_unique<scope_filter>(
|
||||
filter_t::kExclusive, c.include().scopes));
|
||||
filter_t::kExclusive, c.exclude().scopes));
|
||||
exclusive_.emplace_back(std::make_unique<subclass_filter>(
|
||||
filter_t::kExclusive, c.exclude().subclasses));
|
||||
exclusive_.emplace_back(std::make_unique<context_filter>(
|
||||
|
||||
@@ -137,8 +137,8 @@ public:
|
||||
bool exc = std::any_of(
|
||||
exclusive_.begin(), exclusive_.end(), [this, &e](const auto &ex) {
|
||||
auto m = ex->match(diagram_, e);
|
||||
// Return a match if a filter is undefined for specific element
|
||||
// or it's a match
|
||||
// Return true if a filter is defined for specific element
|
||||
// and it's a match
|
||||
return m.has_value() && m.value();
|
||||
});
|
||||
if (exc)
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
bool inc = std::all_of(
|
||||
inclusive_.begin(), inclusive_.end(), [this, &e](const auto &in) {
|
||||
auto m = in->match(diagram_, e);
|
||||
// Return a match if a filter is undefined for specific element
|
||||
// Return true if a filter is undefined for specific element
|
||||
// or it's a match
|
||||
return !m.has_value() || m.value();
|
||||
});
|
||||
|
||||
@@ -250,6 +250,53 @@ template <> struct convert<scope_t> {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config relationship_t decoder
|
||||
//
|
||||
template <> struct convert<relationship_t> {
|
||||
static bool decode(const Node &node, relationship_t &rhs)
|
||||
{
|
||||
assert(node.Type() == NodeType::Scalar);
|
||||
|
||||
auto relationship_name = node.as<std::string>();
|
||||
if (relationship_name == "extension" ||
|
||||
relationship_name == "inheritance") {
|
||||
rhs = relationship_t::kExtension;
|
||||
}
|
||||
else if (relationship_name == "composition") {
|
||||
rhs = relationship_t::kComposition;
|
||||
}
|
||||
else if (relationship_name == "aggregation") {
|
||||
rhs = relationship_t::kAggregation;
|
||||
}
|
||||
else if (relationship_name == "containment") {
|
||||
rhs = relationship_t::kContainment;
|
||||
}
|
||||
else if (relationship_name == "ownership") {
|
||||
rhs = relationship_t::kOwnership;
|
||||
}
|
||||
else if (relationship_name == "association") {
|
||||
rhs = relationship_t::kAssociation;
|
||||
}
|
||||
else if (relationship_name == "instantiation") {
|
||||
rhs = relationship_t::kInstantiation;
|
||||
}
|
||||
else if (relationship_name == "friendship") {
|
||||
rhs = relationship_t::kFriendship;
|
||||
}
|
||||
else if (relationship_name == "dependency") {
|
||||
rhs = relationship_t::kDependency;
|
||||
}
|
||||
else if (relationship_name == "none") {
|
||||
rhs = relationship_t::kNone;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct convert<std::vector<source_location>> {
|
||||
static bool decode(const Node &node, std::vector<source_location> &rhs)
|
||||
{
|
||||
@@ -465,53 +512,6 @@ template <> struct convert<layout_hint> {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config relationship_t decoder
|
||||
//
|
||||
template <> struct convert<relationship_t> {
|
||||
static bool decode(const Node &node, relationship_t &rhs)
|
||||
{
|
||||
assert(node.Type() == NodeType::Scalar);
|
||||
|
||||
auto relationship_name = node.as<std::string>();
|
||||
if (relationship_name == "extension" ||
|
||||
relationship_name == "inheritance") {
|
||||
rhs = relationship_t::kExtension;
|
||||
}
|
||||
else if (relationship_name == "composition") {
|
||||
rhs = relationship_t::kComposition;
|
||||
}
|
||||
else if (relationship_name == "aggregation") {
|
||||
rhs = relationship_t::kAggregation;
|
||||
}
|
||||
else if (relationship_name == "containment") {
|
||||
rhs = relationship_t::kContainment;
|
||||
}
|
||||
else if (relationship_name == "ownership") {
|
||||
rhs = relationship_t::kOwnership;
|
||||
}
|
||||
else if (relationship_name == "association") {
|
||||
rhs = relationship_t::kAssociation;
|
||||
}
|
||||
else if (relationship_name == "instantiation") {
|
||||
rhs = relationship_t::kInstantiation;
|
||||
}
|
||||
else if (relationship_name == "friendship") {
|
||||
rhs = relationship_t::kFriendship;
|
||||
}
|
||||
else if (relationship_name == "dependency") {
|
||||
rhs = relationship_t::kDependency;
|
||||
}
|
||||
else if (relationship_name == "none") {
|
||||
rhs = relationship_t::kNone;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config Yaml decoder
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user