Skip to content

Commit

Permalink
Graph class now compiles, added test file for it
Browse files Browse the repository at this point in the history
  • Loading branch information
lesbianlizard committed Apr 13, 2019
1 parent 79031f4 commit 20ee762
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/graph.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "graph.hpp"
#include "config.hpp"
#include "vertex.hpp"

Vertex* Graph::getStart(){
return this->vertex_start;
Expand Down
2 changes: 1 addition & 1 deletion include/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class Graph
void setEnd(Vertex* new_end);

Graph(Vertex* single_vertex) : vertex_start(single_vertex), vertex_end(single_vertex) {}
}
};
18 changes: 18 additions & 0 deletions src/tests/test_graph.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "graph.hpp"
#include "vertex.hpp"
#include <iostream>

int main(int argc, char** arcv)
{
Vertex* v1 = new Vertex(1, 2, 3);
Vertex* v2 = new Vertex(7, 8, 9);
Graph* graph1 = new Graph(v1);
Graph* graph2 = new Graph(v2);

printf("Graph %p starts and ends with vertices %p and %p\n", graph1, graph1->getStart(), graph1->getEnd());
printf("Graph %p starts and ends with vertices %p and %p\n", graph2, graph2->getStart(), graph2->getEnd());

graph2->setEnd(v1);
printf("Graph %p starts and ends with vertices %p and %p\n", graph2, graph2->getStart(), graph2->getEnd());

}

0 comments on commit 20ee762

Please sign in to comment.