Update tests

This commit is contained in:
stefiosif
2022-12-05 23:44:55 +02:00
parent 7c78bbd7ca
commit 55efd8b816
4 changed files with 113 additions and 113 deletions

View File

@@ -5,10 +5,10 @@
#include <random>
#include <functional>
constexpr int verticesNum = 10;
#include <iostream>
constexpr int verticesNum = 10;
using namespace graph;
TEST_SUITE("Algorithm") {
@@ -20,7 +20,7 @@ TEST_SUITE("Algorithm") {
// 7 --> 9
// 6 --> 9 --> 10 --> 11 --> 12 --> 13 --> 9
// 12 --> 10
Digraph<std::uint16_t> G;
Digraph<int> G;
G.insert(1, 2);
G.insert(2, 3);
G.insert(3, 1);
@@ -42,9 +42,9 @@ TEST_SUITE("Algorithm") {
REQUIRE_EQ(G.V(), 13);
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjList).execute();
auto SCCs = algo::Tarjan<int>(G.adjList).execute();
std::vector<std::vector<std::uint16_t>> expected = {
std::vector<std::vector<int>> expected = {
{9, 10, 11, 12, 13},
{6, 7, 8},
{1, 2, 3, 4, 5}
@@ -58,8 +58,8 @@ TEST_SUITE("Algorithm") {
}
TEST_CASE("Tarjan::execute ~ DAG") {
Digraph<std::uint16_t> G;
auto gen = std::bind(std::uniform_real_distribution<>(0, 1), std::default_random_engine());
Digraph<int> G;
auto gen = std::bind_front(std::uniform_real_distribution<>(0, 1), std::default_random_engine());
for (int i = 0; i <= verticesNum; ++i) {
for (int j = i + 1; j <= verticesNum; ++j) {
@@ -67,7 +67,7 @@ TEST_SUITE("Algorithm") {
}
}
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjList).execute();
auto SCCs = algo::Tarjan<int>(G.adjList).execute();
// Testing whether an scc is a 1-vertex scc which after the normalization
// has no edges, in this case we know tgat there exist no 2-vertex sccs
@@ -86,7 +86,7 @@ TEST_SUITE("Algorithm") {
// 7 --> 9
// 6 --> 9 --> 10 --> 11 --> 12 --> 13 --> 9
// 12 --> 10
Digraph<std::uint16_t> G;
Digraph<int> G;
G.insert(1, 2);
G.insert(2, 3);
G.insert(3, 1);
@@ -107,10 +107,10 @@ TEST_SUITE("Algorithm") {
G.insert(12, 10);
auto tree =
algo::BreadthFirstSearch<std::uint16_t>(G.adjList).execute(1);
algo::BreadthFirstSearch<int>(G.adjList).execute(1);
std::unordered_map<std::uint16_t,
std::unordered_set<std::uint16_t>> expected = {
std::unordered_map<int,
std::unordered_set<int>> expected = {
{1, {2}},
{2, {3, 6}},
{3, {4}},
@@ -136,7 +136,7 @@ TEST_SUITE("Algorithm") {
// 7 --> 9
// 6 --> 9 --> 10 --> 11 --> 12 --> 13 --> 9
// 12 --> 10
Digraph<std::uint16_t> G;
Digraph<int> G;
G.insert(1, 2);
G.insert(2, 3);
G.insert(3, 1);
@@ -156,11 +156,11 @@ TEST_SUITE("Algorithm") {
G.insert(13, 9);
G.insert(12, 10);
algo::BreadthFirstSearch<std::uint16_t> bfs(G.adjList);
auto bfs = std::make_unique<algo::BreadthFirstSearch<int>>(G.adjList);
CHECK_EQ(bfs.query(1, 5), true);
CHECK_EQ(bfs.query(1, 10), true);
CHECK_EQ(bfs.query(9, 5), false);
CHECK_EQ(bfs.query(8, 4), false);
CHECK_EQ(bfs->query(1, 5), true);
CHECK_EQ(bfs->query(1, 10), true);
CHECK_EQ(bfs->query(9, 5), false);
CHECK_EQ(bfs->query(8, 4), false);
}
}