From 7aa6d86cb90cca4a3fb6b4892aa516984cefdd66 Mon Sep 17 00:00:00 2001 From: dmatetelki Date: Fri, 10 Apr 2015 12:45:05 +0200 Subject: [PATCH] fixing catch.hpp include in test_graph.hpp, removing most tests for now. --- test/graph/test_graph.hpp | 275 +------------------------------------- 1 file changed, 1 insertion(+), 274 deletions(-) diff --git a/test/graph/test_graph.hpp b/test/graph/test_graph.hpp index 1a154af..ab8c833 100644 --- a/test/graph/test_graph.hpp +++ b/test/graph/test_graph.hpp @@ -1,287 +1,14 @@ #include -#include "/home/denes/projects/Catch/single_include/catch.hpp" +#include "../catch.hpp" #include #include #include - TEST_CASE( "Graph creation", "[graph][data_structure]" ) { SECTION("Initial state") { Graph g; - REQUIRE( empty(g) == true ); - REQUIRE( numberOfVertices(g) == 0 ); - REQUIRE( numberOfEdges(g) == 0 ); - REQUIRE( g.edges().size() == 0 ); - REQUIRE( g.vertices().size() == 0 ); - } - - SECTION("Initializer list of vertices") { - Graph g = { 1, 2, 3 }; - REQUIRE( empty(g) == false ); - REQUIRE( numberOfVertices(g) == 3 ); - REQUIRE( numberOfEdges(g) == 0 ); - REQUIRE( g.edges().size() == 0 ); - REQUIRE( g.vertices().size() == 3 ); - - REQUIRE( contains(g, 1) == true ); - REQUIRE( contains(g, 2) == true ); - REQUIRE( contains(g, 3) == true ); - } - - SECTION("Initializer list of vertices") { - Graph g = { {1, 2}, {1, 3}, {3, 4} }; - REQUIRE( empty(g) == false ); - REQUIRE( numberOfVertices(g) == 4 ); - REQUIRE( numberOfEdges(g) == 3*2 ); - REQUIRE( g.edges().size() == 3*2 ); - REQUIRE( g.vertices().size() == 4 ); - - REQUIRE( contains(g, 1) == true ); - REQUIRE( contains(g, 2) == true ); - REQUIRE( contains(g, 3) == true ); - REQUIRE( contains(g, 4) == true ); - } - - SECTION("copy ctor") { - Graph g = { {1, 2}, {1, 3}, {3, 4} }; - Graph g2(g); - REQUIRE( empty(g2) == false ); - REQUIRE( numberOfVertices(g2) == 4 ); - REQUIRE( numberOfEdges(g2) == 3*2 ); - REQUIRE( g2.edges().size() == 3*2 ); - REQUIRE( g2.vertices().size() == 4 ); - - REQUIRE( contains(g2, 1) == true ); - REQUIRE( contains(g2, 2) == true ); - REQUIRE( contains(g2, 3) == true ); - REQUIRE( contains(g2, 4) == true ); - } - - SECTION("Assignment operator") { - Graph g = { {1, 2}, {1, 3}, {3, 4} }; - Graph g2; - g2.clear(); - g2 = g; - REQUIRE( empty(g2) == false ); - REQUIRE( numberOfVertices(g2) == 4 ); - REQUIRE( numberOfEdges(g2) == 3*2 ); - REQUIRE( g2.edges().size() == 3*2 ); - REQUIRE( g2.vertices().size() == 4 ); - - REQUIRE( contains(g2, 1) == true ); - REQUIRE( contains(g2, 2) == true ); - REQUIRE( contains(g2, 3) == true ); - REQUIRE( contains(g2, 4) == true ); - } -} - -TEST_CASE( "Graph adding vertices", "[graph][data_structure]" ) { - - SECTION("One element") { - Graph g; - g.addVertex(1); - REQUIRE( empty(g) == false ); - REQUIRE( numberOfVertices(g) == 1 ); - REQUIRE( numberOfEdges(g) == 0 ); - REQUIRE( g.edges().size() == 0 ); - REQUIRE( g.vertices().size() == 1 ); - } - - SECTION("Removing the only element") { - Graph g; - g.addVertex(1); - g.removeVertex(1); - REQUIRE( empty(g) == true ); - REQUIRE( numberOfVertices(g) == 0 ); - REQUIRE( numberOfEdges(g) == 0 ); - REQUIRE( g.edges().size() == 0 ); - REQUIRE( g.vertices().size() == 0 ); - } - - SECTION("Adding some vertices, removing one by one") { - Graph g; - g.addVertex(1); - REQUIRE( numberOfVertices(g) == 1 ); - g.addVertex(2); - REQUIRE( numberOfVertices(g) == 2 ); - g.addVertex(3); - REQUIRE( numberOfVertices(g) == 3 ); - g.removeVertex(1); - REQUIRE( numberOfVertices(g) == 2 ); - g.removeVertex(2); - REQUIRE( numberOfVertices(g) == 1 ); - g.removeVertex(3); - REQUIRE( numberOfVertices(g) == 0 ); - } - - SECTION("Adding some vertices then clear") { - Graph g; - g.addVertex(1); - g.addVertex(2); - g.addVertex(3); - REQUIRE( numberOfVertices(g) == 3 ); - g.clear(); - REQUIRE( numberOfVertices(g) == 0 ); - } - - SECTION("Removing unexisting vertex") { - Graph g; - g.addVertex(1); - REQUIRE( numberOfVertices(g) == 1 ); - g.removeVertex(2); - REQUIRE( numberOfVertices(g) == 1 ); - } - - SECTION("Contains vertex") { - Graph g; - g.addVertex(1); - g.addVertex(3); - REQUIRE( contains(g, 1) == true ); - REQUIRE( contains(g, 2) == false ); - REQUIRE( contains(g, 3) == true ); - } - - SECTION("Modify vertex") { - Graph g; - g.addVertex(1); - REQUIRE( contains(g, 1) == true ); - REQUIRE( contains(g, 2) == false ); - - g.modifyVertex(1, 2); - REQUIRE( contains(g, 1) == false ); - REQUIRE( contains(g, 2) == true ); - } - - SECTION("get array of vertices") { - Graph g; - g.addVertex(1); - g.addVertex(2); - g.addVertex(3); - std::vector v = g.vertices(); - REQUIRE( v.size() == 3 ); - REQUIRE( std::find(v.begin(), v.end(), 1) != v.end() ); - REQUIRE( std::find(v.begin(), v.end(), 2) != v.end() ); - REQUIRE( std::find(v.begin(), v.end(), 3) != v.end() ); - } - - SECTION("iterate over vertices") { - Graph g; - g.addVertex(1); - g.addVertex(2); - g.addVertex(3); - - std::map found; - for (auto it : g) { - REQUIRE( contains(g, it) == true ); - ++found[it]; - } - REQUIRE( found.size() == 3 ); } } - -TEST_CASE( "Graph adding edges", "[graph][data_structure]" ) { - - SECTION("One element") { - Graph g; - g.addEdge(1, 2); - REQUIRE( empty(g) == false ); - REQUIRE( numberOfVertices(g) == 2 ); - REQUIRE( numberOfEdges(g) == 1*2 ); - REQUIRE( g.edges().size() == 1*2 ); - REQUIRE( g.vertices().size() == 2 ); - } - - SECTION("Removing the only edge") { - Graph g; - g.addEdge(1, 2); - g.removeEdge(1, 2); - REQUIRE( empty(g) == false ); - REQUIRE( numberOfVertices(g) == 2 ); - REQUIRE( numberOfEdges(g) == 0 ); - REQUIRE( g.edges().size() == 0 ); - REQUIRE( g.vertices().size() == 2 ); - } -/* - SECTION("Adding some edges, removing one by one") { - Graph g; - g.addVertex(1); - REQUIRE( numberOfVertices(g) == 1 ); - g.addVertex(2); - REQUIRE( numberOfVertices(g) == 2 ); - g.addVertex(3); - REQUIRE( numberOfVertices(g) == 3 ); - g.removeVertex(1); - REQUIRE( numberOfVertices(g) == 2 ); - g.removeVertex(2); - REQUIRE( numberOfVertices(g) == 1 ); - g.removeVertex(3); - REQUIRE( numberOfVertices(g) == 0 ); - } - - SECTION("Adding some vertices then clear") { - Graph g; - g.addVertex(1); - g.addVertex(2); - g.addVertex(3); - REQUIRE( numberOfVertices(g) == 3 ); - g.clear(); - REQUIRE( numberOfVertices(g) == 0 ); - } - - SECTION("Removing unexisting vertex") { - Graph g; - g.addVertex(1); - REQUIRE( numberOfVertices(g) == 1 ); - g.removeVertex(2); - REQUIRE( numberOfVertices(g) == 1 ); - } - - SECTION("Contains vertex") { - Graph g; - g.addVertex(1); - g.addVertex(3); - REQUIRE( contains(g, 1) == true ); - REQUIRE( contains(g, 2) == false ); - REQUIRE( contains(g, 3) == true ); - } - - SECTION("Modify vertex") { - Graph g; - g.addVertex(1); - REQUIRE( contains(g, 1) == true ); - REQUIRE( contains(g, 2) == false ); - - g.modifyVertex(1, 2); - REQUIRE( contains(g, 1) == false ); - REQUIRE( contains(g, 2) == true ); - } - - SECTION("get array of vertices") { - Graph g; - g.addVertex(1); - g.addVertex(2); - g.addVertex(3); - std::vector v = g.vertices(); - REQUIRE( v.size() == 3 ); - REQUIRE( std::find(v.begin(), v.end(), 1) != v.end() ); - REQUIRE( std::find(v.begin(), v.end(), 2) != v.end() ); - REQUIRE( std::find(v.begin(), v.end(), 3) != v.end() ); - } - - SECTION("iterate over vertices") { - Graph g; - g.addVertex(1); - g.addVertex(2); - g.addVertex(3); - - std::map found; - for (auto it : g) { - REQUIRE( contains(g, it) == true ); - ++found[it]; - } - REQUIRE( found.size() == 3 ); - }*/ -} \ No newline at end of file