-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Input data is presented as dot-files. Undirected graphs are used.
- Loading branch information
1 parent
7eb9d9f
commit 63b3453
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include "algorithms/algo_factory.h" | ||
#include "algorithms/gfd/gfd_validation.h" | ||
#include "config/names.h" | ||
#include "table_config.h" | ||
|
||
using namespace algos; | ||
using algos::StdParamsMap; | ||
|
||
namespace tests { | ||
|
||
namespace { | ||
|
||
auto current_path = test_data_dir / "graph_data"; | ||
|
||
template <typename T> | ||
class GfdValidationTest : public ::testing::Test { | ||
protected: | ||
std::unique_ptr<algos::GfdHandler> CreateGfdValidationInstance( | ||
std::filesystem::path const& graph_path, | ||
std::vector<std::filesystem::path> const& gfd_paths) { | ||
StdParamsMap optionMap = {{config::names::kGraphData, graph_path}, | ||
{config::names::kGfdData, gfd_paths}}; | ||
return algos::CreateAndLoadAlgorithm<T>(optionMap); | ||
} | ||
}; | ||
|
||
TYPED_TEST_SUITE_P(GfdValidationTest); | ||
|
||
TYPED_TEST_P(GfdValidationTest, TestTrivially) { | ||
auto graph_path = current_path / "quadrangle.dot"; | ||
auto gfd_path = current_path / "quadrangle_gfd.dot"; | ||
std::vector<std::filesystem::path> gfd_paths = {gfd_path}; | ||
auto algorithm = TestFixture::CreateGfdValidationInstance(graph_path, gfd_paths); | ||
int expected_size = 1; | ||
algorithm->Execute(); | ||
std::vector<Gfd> GfdList = algorithm->GfdList(); | ||
ASSERT_EQ(expected_size, GfdList.size()); | ||
} | ||
|
||
TYPED_TEST_P(GfdValidationTest, TestExistingMatches) { | ||
auto graph_path = current_path / "directors.dot"; | ||
auto gfd_path = current_path / "directors_gfd.dot"; | ||
std::vector<std::filesystem::path> gfd_paths = {gfd_path}; | ||
auto algorithm = TestFixture::CreateGfdValidationInstance(graph_path, gfd_paths); | ||
int expected_size = 0; | ||
algorithm->Execute(); | ||
std::vector<Gfd> GfdList = algorithm->GfdList(); | ||
ASSERT_EQ(expected_size, GfdList.size()); | ||
} | ||
|
||
REGISTER_TYPED_TEST_SUITE_P(GfdValidationTest, TestTrivially, TestExistingMatches); | ||
|
||
using GfdAlgorithms = | ||
::testing::Types<algos::NaiveGfdValidation, algos::GfdValidation, algos::EGfdValidation>; | ||
|
||
INSTANTIATE_TYPED_TEST_SUITE_P(GfdValidationTest, GfdValidationTest, GfdAlgorithms); | ||
|
||
} // namespace | ||
|
||
} // namespace tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
graph G { | ||
0[label="person" name="James Cameron" celebrity="high"]; | ||
1[label="film" name="Avatar" success="high" year="2009"]; | ||
2[label="film" name="Titanic" success="high" year="1997"]; | ||
3[label="film" name="Piranha II" success="low" year="1981"]; | ||
4[label="film" name="Terminator" success="high" year="1984"]; | ||
5[label="person" name="Robert Zemeckis" celebrity="high"]; | ||
6[label="film" name="The Walk" success="high" year="2015"]; | ||
7[label="film" name="Back to the future" success="high" year="1985"]; | ||
8[label="film" name="Forrest Gump" success="high" year="1994"]; | ||
9[label="person" name="James Toback" celebrity="low"]; | ||
10[label="film" name="Tyson" success="high" year="2008"]; | ||
11[label="film" name="Fingers" success="high" year="1978"]; | ||
0--1 [label="directed"]; | ||
0--2 [label="directed"]; | ||
0--3 [label="directed"]; | ||
0--4 [label="directed"]; | ||
5--6 [label="directed"]; | ||
5--7 [label="directed"]; | ||
5--8 [label="directed"]; | ||
9--10 [label="directed"]; | ||
9--11 [label="directed"]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
0.celebrity=high | ||
1.success=high | ||
graph G { | ||
0[label=person]; | ||
1[label=film]; | ||
0--1 [label=directed]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
graph G { | ||
0[label=quadrilateral angles=arbitrary sides=arbitrary]; | ||
1[label=parallelogram angles=pairwise_equal sides=pairwise_equal]; | ||
2[label=trapezoid angles=arbitrary sides=parallel_and_arbitrary]; | ||
3[label=rectangle angles=equal sides=pairwise_equal]; | ||
4[label=rhombus angles=pairwise_equal sides=equal]; | ||
5[label=square angles=equal sides=equal]; | ||
0--1 [label=two_pairs_of_parallel_sides]; | ||
0--2 [label=one_pair_of_parallel_sides]; | ||
1--3 [label=equality_of_angles]; | ||
1--4 [label=equality_of_sides]; | ||
3--5 [label=equality_of_sides]; | ||
4--5 [label=equality_of_angles]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
0.sides=1.sides | ||
graph G { | ||
0[label=polygon]; | ||
1[label=triangle]; | ||
0--1 [label=three_sides]; | ||
} |