Compare commits
2 Commits
ce424df021
...
755fed86e5
Author | SHA1 | Date | |
---|---|---|---|
755fed86e5 | |||
eb4995ee41 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,3 +34,4 @@
|
|||||||
|
|
||||||
# Building
|
# Building
|
||||||
build
|
build
|
||||||
|
*.swp
|
||||||
|
@ -12,3 +12,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
|||||||
include_directories(${search-algorithms_SOURCE_DIR}/src)
|
include_directories(${search-algorithms_SOURCE_DIR}/src)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
@ -27,22 +27,6 @@ struct Graph {
|
|||||||
void PrintGraph(void);
|
void PrintGraph(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* OLD IMPLEMENTATION
|
|
||||||
struct Node {
|
|
||||||
int destination;
|
|
||||||
int weight;
|
|
||||||
Node(int destination, int weight);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Graph {
|
|
||||||
int nodeCount;
|
|
||||||
std::vector<std::vector<Node>> nodes;
|
|
||||||
Graph(void);
|
|
||||||
void AddEdge(int source, int destination, int weight);
|
|
||||||
void PrintGraph(void);
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
Graph ReadInGraph(std::string fileLocation);
|
Graph ReadInGraph(std::string fileLocation);
|
||||||
void PrintSolution(std::vector<Vertex*> solution);
|
void PrintSolution(std::vector<Vertex*> solution);
|
||||||
|
|
||||||
|
9
test/CMakeLists.txt
Normal file
9
test/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
find_package(Catch2 REQUIRED)
|
||||||
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
add_executable(testing
|
||||||
|
./test-main.cpp
|
||||||
|
./test-algorithm.cpp
|
||||||
|
../src/algorithm.cpp
|
||||||
|
)
|
||||||
|
set_target_properties(testing PROPERTIES LINKER_LANGUAGE CXX)
|
||||||
|
target_link_libraries(testing Catch2::Catch2)
|
23
test/test-algorithm.cpp
Normal file
23
test/test-algorithm.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <catch2/catch.hpp>
|
||||||
|
#include "algorithm.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("Adding Graph") {
|
||||||
|
Graph testGraph = ReadInGraph("test/input/graphPosLittle");
|
||||||
|
REQUIRE( testGraph.nodeCount > 0 );
|
||||||
|
SECTION( "Vertices" ) {
|
||||||
|
REQUIRE( testGraph.vertices.at(1).nodeNumber == 1 );
|
||||||
|
REQUIRE( testGraph.vertices.at(2).nodeNumber == 2 );
|
||||||
|
REQUIRE( testGraph.vertices.at(3).nodeNumber == 3 );
|
||||||
|
REQUIRE( testGraph.vertices.at(4).nodeNumber == 4 );
|
||||||
|
REQUIRE( testGraph.vertices.at(5).nodeNumber == 5 );
|
||||||
|
REQUIRE( testGraph.vertices.at(6).nodeNumber == 6 );
|
||||||
|
REQUIRE( testGraph.vertices.at(7).nodeNumber == 7 );
|
||||||
|
REQUIRE( testGraph.vertices.at(8).nodeNumber == 8 );
|
||||||
|
REQUIRE( testGraph.vertices.at(9).nodeNumber == 9 );
|
||||||
|
REQUIRE( testGraph.vertices.at(10).nodeNumber == 10 );
|
||||||
|
}
|
||||||
|
SECTION( "Edges" ) {
|
||||||
|
REQUIRE( testGraph.vertices.at(1).edges.at(1).destination->nodeNumber == 7 );
|
||||||
|
REQUIRE( testGraph.vertices.at(1).edges.at(2).destination->nodeNumber == 2 );
|
||||||
|
}
|
||||||
|
}
|
2
test/test-main.cpp
Normal file
2
test/test-main.cpp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include <catch2/catch.hpp>
|
Loading…
Reference in New Issue
Block a user