Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakub Janák
tss
Commits
de4dbde9
Commit
de4dbde9
authored
4 months ago
by
Jakub Janák
Browse files
Options
Downloads
Patches
Plain Diff
test for getting neighbors added
parent
1d1eef3a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_Node.cpp
+28
-0
28 additions, 0 deletions
test/test_Node.cpp
with
28 additions
and
0 deletions
test/test_Node.cpp
+
28
−
0
View file @
de4dbde9
...
...
@@ -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"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment