data: cleaned up TokenLocation classes

* removed self assiged locationId
* show errors after parse again
This commit is contained in:
Eberhard Graether
2015-08-27 22:14:12 +02:00
parent 2044ff9723
commit 9bcf7d2f0f
14 changed files with 54 additions and 137 deletions
+16 -16
View File
@@ -254,8 +254,8 @@ public:
void test_graph_saves_nodes()
{
Graph graph;
Node* a = graph.addNode(1, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
Node* b = graph.addNode(2, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
Node* a = graph.createNode(1, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
Node* b = graph.createNode(2, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
TS_ASSERT_EQUALS(2, graph.getNodeCount());
TS_ASSERT_EQUALS(0, graph.getEdgeCount());
@@ -273,10 +273,10 @@ public:
{
Graph graph;
Node* a = graph.addNode(1, Node::NODE_FUNCTION, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
Node* b = graph.addNode(2, Node::NODE_FUNCTION, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
Node* a = graph.createNode(1, Node::NODE_FUNCTION, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
Node* b = graph.createNode(2, Node::NODE_FUNCTION, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
Edge* e = graph.addEdge(3, Edge::EDGE_CALL, a, b);
Edge* e = graph.createEdge(3, Edge::EDGE_CALL, a, b);
TS_ASSERT_EQUALS(2, graph.getNodeCount());
TS_ASSERT_EQUALS(1, graph.getEdgeCount());
@@ -289,8 +289,8 @@ public:
{
Graph graph;
Node* a = graph.addNode(1, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
graph.addNode(2, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
Node* a = graph.createNode(1, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
graph.createNode(2, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
TS_ASSERT_EQUALS(2, graph.getNodeCount());
TS_ASSERT_EQUALS(0, graph.getEdgeCount());
@@ -304,16 +304,16 @@ public:
{
Graph graph;
Node* a = graph.addNode(1, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
Node* b = graph.addNode(2, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
Node* c = graph.addNode(3, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("C", "::")));
Node* d = graph.addNode(4, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("D", "::")));
Node* e = graph.addNode(5, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("E", "::")));
Node* a = graph.createNode(1, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("A", "::")));
Node* b = graph.createNode(2, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("B", "::")));
Node* c = graph.createNode(3, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("C", "::")));
Node* d = graph.createNode(4, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("D", "::")));
Node* e = graph.createNode(5, Node::NODE_UNDEFINED, std::make_shared<TokenComponentNameCached>(utility::splitToVector("E", "::")));
graph.addEdge(6, Edge::EDGE_MEMBER, a, b);
graph.addEdge(7, Edge::EDGE_MEMBER, a, c);
graph.addEdge(8, Edge::EDGE_USAGE, c, d);
graph.addEdge(9, Edge::EDGE_MEMBER, b, e);
graph.createEdge(6, Edge::EDGE_MEMBER, a, b);
graph.createEdge(7, Edge::EDGE_MEMBER, a, c);
graph.createEdge(8, Edge::EDGE_USAGE, c, d);
graph.createEdge(9, Edge::EDGE_MEMBER, b, e);
TS_ASSERT_EQUALS(5, graph.getNodeCount());
TS_ASSERT_EQUALS(4, graph.getEdgeCount());
+17 -17
View File
@@ -11,7 +11,7 @@ public:
void test_token_locations_get_created_with_other_end()
{
TokenLocationCollection collection;
TokenLocation* a = collection.addTokenLocation(1, "file.c", 2, 3, 4, 5);
TokenLocation* a = collection.addTokenLocation(1, 1, "file.c", 2, 3, 4, 5);
TS_ASSERT(a);
TS_ASSERT(a->isStartTokenLocation());
@@ -33,8 +33,8 @@ public:
void test_token_locations_do_not_get_created_with_wrong_input()
{
TokenLocationCollection collection;
TokenLocation* a = collection.addTokenLocation(1, "file.c", 2, 3, 2, 1);
TokenLocation* b = collection.addTokenLocation(1, "file.c", 4, 1, 1, 10);
TokenLocation* a = collection.addTokenLocation(1, 1, "file.c", 2, 3, 2, 1);
TokenLocation* b = collection.addTokenLocation(2, 1, "file.c", 4, 1, 1, 10);
TS_ASSERT(!a);
TS_ASSERT(!b);
@@ -43,9 +43,9 @@ public:
void test_token_locations_get_unique_id_but_both_ends_have_the_same()
{
TokenLocationCollection collection;
TokenLocation* a = collection.addTokenLocation(1, "file.c", 1, 1, 1, 1);
TokenLocation* b = collection.addTokenLocation(2, "file.c", 1, 1, 1, 1);
TokenLocation* c = collection.addTokenLocation(3, "file.c", 1, 1, 1, 1);
TokenLocation* a = collection.addTokenLocation(1, 1, "file.c", 1, 1, 1, 1);
TokenLocation* b = collection.addTokenLocation(2, 2, "file.c", 1, 1, 1, 1);
TokenLocation* c = collection.addTokenLocation(3, 3, "file.c", 1, 1, 1, 1);
TS_ASSERT_EQUALS(1, collection.getTokenLocationFileCount());
TS_ASSERT_EQUALS(3, collection.getTokenLocationCount());
@@ -62,7 +62,7 @@ public:
void test_token_locations_have_right_file_path_line_column_and_token_id()
{
TokenLocationCollection collection;
TokenLocation* a = collection.addTokenLocation(1, "file.c", 2, 3, 4, 5);
TokenLocation* a = collection.addTokenLocation(1, 1, "file.c", 2, 3, 4, 5);
TS_ASSERT_EQUALS(1, a->getTokenId());
TS_ASSERT_EQUALS(2, a->getLineNumber());
@@ -75,8 +75,8 @@ public:
void test_finding_token_locations_by_id()
{
TokenLocationCollection collection;
TokenLocation* a = collection.addTokenLocation(1, "file.c", 2, 3, 4, 5);
TokenLocation* b = collection.addTokenLocation(6, "file.c", 7, 8, 9, 10);
TokenLocation* a = collection.addTokenLocation(1, 1, "file.c", 2, 3, 4, 5);
TokenLocation* b = collection.addTokenLocation(2, 6, "file.c", 7, 8, 9, 10);
TS_ASSERT_EQUALS(a, collection.findTokenLocationById(a->getId()));
TS_ASSERT_EQUALS(b, collection.findTokenLocationById(b->getId()));
@@ -85,10 +85,10 @@ public:
void test_removing_token_locations()
{
TokenLocationCollection collection;
TokenLocation* a = collection.addTokenLocation(1, "file.c", 2, 3, 4, 5);
TokenLocation* b = collection.addTokenLocation(1, "file.c", 3, 3, 4, 5);
TokenLocation* c = collection.addTokenLocation(1, "file.c", 1, 3, 5, 5);
TokenLocation* d = collection.addTokenLocation(1, "file2.c", 1, 3, 5, 5);
TokenLocation* a = collection.addTokenLocation(1, 1, "file.c", 2, 3, 4, 5);
TokenLocation* b = collection.addTokenLocation(2, 1, "file.c", 3, 3, 4, 5);
TokenLocation* c = collection.addTokenLocation(3, 1, "file.c", 1, 3, 5, 5);
TokenLocation* d = collection.addTokenLocation(4, 1, "file2.c", 1, 3, 5, 5);
TS_ASSERT_EQUALS(2, collection.getTokenLocationFileCount());
TS_ASSERT_EQUALS(4, collection.getTokenLocationCount());
@@ -114,10 +114,10 @@ public:
void test_creating_plain_copy_of_all_locations_in_line_range()
{
TokenLocationCollection collection;
TokenLocation* a = collection.addTokenLocation(1, "file.c", 2, 3, 4, 5);
TokenLocation* b = collection.addTokenLocation(1, "file.c", 3, 3, 4, 5);
TokenLocation* c = collection.addTokenLocation(1, "file.c", 1, 3, 5, 5);
TokenLocation* d = collection.addTokenLocation(1, "file.c", 1, 5, 4, 5);
TokenLocation* a = collection.addTokenLocation(1, 1, "file.c", 2, 3, 4, 5);
TokenLocation* b = collection.addTokenLocation(2, 1, "file.c", 3, 3, 4, 5);
TokenLocation* c = collection.addTokenLocation(3, 1, "file.c", 1, 3, 5, 5);
TokenLocation* d = collection.addTokenLocation(4, 1, "file.c", 1, 5, 4, 5);
Id ida = a->getId();
Id idb = b->getId();