test: added GraphFilter and GraphFilterConductor tests

This commit is contained in:
Eberhard Graether
2014-09-01 12:15:17 +02:00
parent aee0b7c337
commit 5c89e49ff0
29 changed files with 554 additions and 48 deletions
+4 -4
View File
@@ -118,13 +118,13 @@ std::string Edge::getTypeString(EdgeType type) const
case EDGE_MEMBER:
return "child";
case EDGE_TYPE_OF:
return "type use";
return "type_use";
case EDGE_RETURN_TYPE_OF:
return "return type";
return "return_type";
case EDGE_PARAMETER_TYPE_OF:
return "parameter type";
return "parameter_type";
case EDGE_TYPE_USAGE:
return "type usage";
return "type_usage";
case EDGE_INHERITANCE:
return "inheritance";
case EDGE_CALL:
+21
View File
@@ -30,3 +30,24 @@ void FilterableGraph::print(std::ostream& ostream) const
}
);
}
void FilterableGraph::printBasic(std::ostream& ostream) const
{
ostream << getNodeCount() << " nodes:";
forEachNode(
[&ostream](Node* n)
{
ostream << ' ' << n->getTypeString() << ':' << n->getFullName();
}
);
ostream << '\n';
ostream << getEdgeCount() << " edges:";
forEachEdge(
[&ostream](Edge* e)
{
ostream << ' ' << e->getName();
}
);
ostream << '\n';
}
+1
View File
@@ -30,6 +30,7 @@ public:
virtual size_t getEdgeCount() const = 0;
void print(std::ostream& ostream) const;
void printBasic(std::ostream& ostream) const;
};
#endif // FILTERABLE_GRAPH_H
+22
View File
@@ -14,6 +14,28 @@ Graph::~Graph()
m_nodes.clear();
}
Graph& Graph::operator=(const Graph& other)
{
if (&other != this)
{
other.forEachNode(
[this](Node* node)
{
addNodeAsPlainCopy(node);
}
);
other.forEachEdge(
[this](Edge* edge)
{
addEdgeAsPlainCopy(edge);
}
);
}
return *this;
}
void Graph::copy(const FilterableGraph* other)
{
clear();
+1 -2
View File
@@ -15,6 +15,7 @@ class Graph
public:
Graph();
virtual ~Graph();
Graph& operator=(const Graph& other);
// FilterableGraph implementation
virtual void copy(const FilterableGraph* other);
@@ -71,8 +72,6 @@ private:
Edge* insertEdge(Edge::EdgeType type, Node* from, Node* to);
void removeEdgeInternal(Edge* edge);
const std::string m_delimiter;
std::map<Id, std::shared_ptr<Node>> m_nodes;
std::map<Id, std::shared_ptr<Edge>> m_edges;
};
+1 -1
View File
@@ -268,7 +268,7 @@ std::string Node::getTypeString(NodeType type) const
case NODE_UNDEFINED:
return "undefined";
case NODE_UNDEFINED_FUNCTION:
return "undefined function";
return "undefined_function";
case NODE_CLASS:
return "class";
case NODE_STRUCT:
@@ -56,22 +56,22 @@ class GraphFilterCommandNodeType
: public GraphFilter
{
public:
GraphFilterCommandNodeType(Node::NodeType type)
: m_type(type)
GraphFilterCommandNodeType(Node::NodeTypeMask mask)
: m_mask(mask)
{
}
protected:
virtual void visitNode(Node* node)
{
if (node->getType() == m_type)
if (node->isType(m_mask))
{
addNode(node);
}
}
private:
const Node::NodeType m_type;
const Node::NodeTypeMask m_mask;
};
class GraphFilterCommandConst
@@ -254,7 +254,6 @@ private:
const bool m_super;
};
class GraphFilterToken
: public GraphFilter
{