Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/testing setup #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ cmake-build-debug/
.idea

.mypy_cache
*.txt
Build
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/Catch2"]
path = third_party/Catch2
url = https://github.com/catchorg/Catch2.git
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ addons:
packages:
- g++-7

script:

before_script:
- export CC=gcc-7
- export CXX=g++-7
- cmake --version
- cmake CMakeLists.txt
- cmake --build . --target neat
- cmake -H. -BBuild
- cd Build

script:
- make
- ctest -V
27 changes: 21 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
cmake_minimum_required(VERSION 3.8)

project(neat)

set(CMAKE_CXX_STANDARD 17)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)

set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)

set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads REQUIRED)

add_subdirectory (third_party EXCLUDE_FROM_ALL)
add_subdirectory (lib)
add_subdirectory (app)

enable_testing ()

# set(SOURCE_FILES main.cpp src/ANN.cpp src/ANN.hpp src/ConnectionGene.cpp src/ConnectionGene.hpp src/Gene.cpp src/Gene.h src/Node.cpp src/Node.hpp src/NEAT.cpp src/NEAT.hpp src/SnakeGame.cpp src/SnakeGame.hpp src/Snake.cpp src/Snake.hpp)



set(SOURCE_FILES main.cpp src/ANN.cpp src/ANN.hpp src/ConnectionGene.cpp src/ConnectionGene.hpp src/Gene.cpp src/Gene.h src/Node.cpp src/Node.hpp src/NEAT.cpp src/NEAT.hpp src/SnakeGame.cpp src/SnakeGame.hpp src/Snake.cpp src/Snake.hpp)


# Tests
enable_testing()
add_subdirectory(tests)
add_executable(neat ${SOURCE_FILES})
# # Tests
# enable_testing()
# add_subdirectory(tests)
# add_executable(neat ${SOURCE_FILES})
18 changes: 18 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set (APP_NAME "${PROJECT_NAME}App")

#configure directories
set (APP_MODULE_PATH "${PROJECT_SOURCE_DIR}/app")
set (APP_SRC_PATH "${APP_MODULE_PATH}/src" )

#set includes
include_directories (${LIBRARY_INCLUDE_PATH})

#set sources
file (GLOB APP_SOURCE_FILES "${APP_SRC_PATH}/*.cpp")

#set target executable
add_executable (${APP_NAME} ${APP_SOURCE_FILES})

#add the library
target_link_libraries (${APP_NAME} ${LIB_NAME})

2 changes: 1 addition & 1 deletion main.cpp → app/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include "src/NEAT.hpp"
#include "NEAT.hpp"


int main() {
Expand Down
24 changes: 24 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set (LIB_NAME "${PROJECT_NAME}Lib")

#configure directories
set (LIBRARY_MODULE_PATH "${PROJECT_SOURCE_DIR}/lib")
set (LIBRARY_SRC_PATH "${LIBRARY_MODULE_PATH}/src" )
set (LIBRARY_INCLUDE_PATH "${LIBRARY_MODULE_PATH}/include")

#set includes
include_directories (${LIBRARY_INCLUDE_PATH})

#set sources
file (GLOB LIB_HEADER_FILES "${LIBRARY_INCLUDE_PATH}/*.[h]pp")
file (GLOB LIB_SOURCE_FILES "${LIBRARY_SRC_PATH}/*.cpp")

#set library
add_library (${LIB_NAME} STATIC ${LIB_SOURCE_FILES} ${LIB_HEADER_FILES})

#export vars
set (LIBRARY_INCLUDE_PATH ${LIBRARY_INCLUDE_PATH} PARENT_SCOPE)
set (LIB_NAME ${LIB_NAME} PARENT_SCOPE)

#test
enable_testing ()
add_subdirectory (test)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions lib/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set (TEST_APP_NAME "${LIB_NAME}Test")

#configure directories
set (TEST_MODULE_PATH "${LIBRARY_MODULE_PATH}/test")

#configure test directories
set (TEST_SRC_PATH "${TEST_MODULE_PATH}/src" )

#set includes
include_directories (${LIBRARY_INCLUDE_PATH} ${TEST_THIRD_PARTY_INCLUDE_PATH})

#set test sources
file (GLOB TEST_SOURCE_FILES "${TEST_SRC_PATH}/*.cpp")

#set target executable
add_executable (${TEST_APP_NAME} ${TEST_SOURCE_FILES})

#add the library
target_link_libraries (${TEST_APP_NAME} ${LIB_NAME} Threads::Threads)

# Turn on CMake testing capabilities
enable_testing()

#parse catch tests
ParseAndAddCatchTests (${TEST_APP_NAME})
6 changes: 3 additions & 3 deletions tests/testSnake.cpp → lib/test/src/testSnake.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file

#include "Snake.hpp"
#include "catch.hpp"
// #include "Snake.hpp"
#include <catch.hpp>


unsigned int Factorial( unsigned int number ) {
return number <= 1 ? number : Factorial(number-1)*number;
}

TEST_CASE( "move that is already valid", "[snake]" ) {
}
}
8 changes: 0 additions & 8 deletions tests/CMakeLists.txt

This file was deleted.

Loading