From 035b2b28478fbf3a37903df00e7ad2f0e29ff7fd Mon Sep 17 00:00:00 2001 From: dmatetelki Date: Mon, 6 Feb 2017 14:30:32 +0100 Subject: [PATCH] trying to use coverage tool with travis --- .travis.yml | 7 ++++--- README.md | 2 +- lib/graph/graph.hpp | 7 ++++--- test/graph/test_graph.cpp | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4c9ab1..7ba1ba9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,13 @@ compiler: - gcc env: - - BUILD_TYPE=Debug - - BUILD_TYPE=Release global: # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created # via the "travis encrypt" command using the project repo's public key - secure: "dG3gXqI65d45f7S6KrlqCgFun0id9Tw5tYOSud9lEYVvri6Qh6nJXEiqqVAsaZhZ7I/0cLMCQNmof3voFmOXpU+3NgQ3+t/vpe6PW65phR5O7hQl05YMApyP5ipq+KozLUL6ZAgX7eaU95rI/iPGYMfcZ2W3Jl7szGpxaZZOKrM=" + - BUILD_TYPE=Debug + - BUILD_TYPE=Release + before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y @@ -45,4 +46,4 @@ addons: #build_command_prepend: "./configure; make clean" build_command_prepend: "cmake ." build_command: "make -j 4" - branch_pattern: master \ No newline at end of file + branch_pattern: master diff --git a/README.md b/README.md index 83fada1..e1db89d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ Playing with a graph as a data structure and the algorithms. Build status (on Travis CI) [![Build Status](https://travis-ci.org/cs0rbagomba/graph.png)](https://travis-ci.org/cs0rbagomba/graph) -Coverage status (scan.coverity.com) [![Coverity Status](https://scan.coverity.com/projects/cs0rbagomba/graph)](https://scan.coverity.com/projects/cs0rbagomba-graph) +Coverage status (scan.coverity.com) [![Coverity Status](https://scan.coverity.com/projects/cs0rbagomba/graph.png)](https://scan.coverity.com/projects/cs0rbagomba-graph) diff --git a/lib/graph/graph.hpp b/lib/graph/graph.hpp index 8bc523e..a2ae41c 100644 --- a/lib/graph/graph.hpp +++ b/lib/graph/graph.hpp @@ -10,11 +10,12 @@ /** the graph is: - not weighed - - not directed. There are 2 edges for each connection, both direction + - not directed. There are 2 edges added for each connection, both direction - no multi/self edges - - Stored as an unordered map where the keys are vertices and values are arrays of edges. - The multimap is picked since neighboursOf is the most critical operation. + - Stored as an \ref std::unordered_map map where the keys are vertices and values are \ref std::vector of edges. + The multimap is picked since \ref neighboursOf is the most critical operation. + @note maybe \ref std::set is a better option for the edges? - V expected to be cheap to copy - V should have operator== and be hashable (for the internal std::unordered_map): diff --git a/test/graph/test_graph.cpp b/test/graph/test_graph.cpp index f4aa0eb..4d139be 100644 --- a/test/graph/test_graph.cpp +++ b/test/graph/test_graph.cpp @@ -96,6 +96,21 @@ TEST_CASE( "Graph creation", "[graph][data_structure]" ) { } } +TEST_CASE( "Graph equality", "[graph][data_structure]" ) { + + SECTION("Simple comparisions") { + Graph g; + Graph g1 = { {1, 2}, {1, 3}, {3, 4} }; + Graph g2 = { {1, 3}, {3, 4}, {1, 2} }; // shuffled g1 + Graph g3 = { {3, 1}, {4, 3}, {1, 2} }; // shuffled g1 with switched src,dst + REQUIRE( g == g ); + REQUIRE( g != g1 ); + REQUIRE( g1 == g2 ); + REQUIRE( g1 == g3 ); + } + +} + TEST_CASE( "Graph adding vertices", "[graph][data_structure]" ) { SECTION("One element") {