Skip to content
Snippets Groups Projects
Commit de4dbde9 authored by Jakub Janák's avatar Jakub Janák
Browse files

test for getting neighbors added

parent 1d1eef3a
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,36 @@
//
#include "catch.hpp"
#include "../graph/Edge.h"
#include "../graph/Node.h"
TEST_CASE("Get neighbour nodes should get nodes connected to our node with an edge") {
Node n1 = Node("a");
Node n2 = Node("b");
Node n3 = Node("not connected");
Edge e1 = Edge(&n1, &n2, 1);
Edge e2 = Edge(&n2, &n1, 1);
n1.add_edge(&e1);
n1.add_edge(&e2);
n2.add_edge(&e1);
n2.add_edge(&e2);
SECTION("n2 should be a neighbour to n1") {
const auto& n1_neighbours = n1.get_neighbour_nodes();
REQUIRE(std::find(n1_neighbours.begin(), n1_neighbours.end(), &n2) != n1_neighbours.end());
REQUIRE_FALSE(std::find(n1_neighbours.begin(), n1_neighbours.end(), &n3) != n1_neighbours.end());
}
SECTION("n1 should be a neighbour to n2") {
const auto& n2_neighbours = n2.get_neighbour_nodes();
REQUIRE(std::find(n2_neighbours.begin(), n2_neighbours.end(), &n1) != n2_neighbours.end());
REQUIRE_FALSE(std::find(n2_neighbours.begin(), n2_neighbours.end(), &n3) != n2_neighbours.end());
}
SECTION("n1 and n2 should not be a neighbour of n3") {
const auto& n3_neighbours = n3.get_neighbour_nodes();
REQUIRE_FALSE(std::find(n3_neighbours.begin(), n3_neighbours.end(), &n1) != n3_neighbours.end());
REQUIRE_FALSE(std::find(n3_neighbours.begin(), n3_neighbours.end(), &n2) != n3_neighbours.end());
}
}
TEST_CASE("Test the operators '<' and '>'", "[all]") {
Node n1 = Node("a");
Node n2 = Node("aa");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment