Adding Test dir
This commit is contained in:
parent
2c68726ab2
commit
e8885b01e3
@ -1,33 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
project(Chess C CXX)
|
project(Chess C CXX)
|
||||||
|
|
||||||
find_package(SDL2 REQUIRED)
|
add_subdirectory(src)
|
||||||
|
add_subdirectory(test)
|
||||||
file(GLOB_RECURSE cpp_sources
|
|
||||||
CONFIGURE_DEPENDS
|
|
||||||
"src/*.cpp")
|
|
||||||
|
|
||||||
file(GLOB_RECURSE c_sources
|
|
||||||
CONFIGURE_DEPENDS
|
|
||||||
"src/*.c")
|
|
||||||
|
|
||||||
file (GLOB_RECURSE headers CONFIGURE_DEPENDS "src/*.h")
|
|
||||||
|
|
||||||
set (include_dirs "")
|
|
||||||
foreach (_headerFile ${headers})
|
|
||||||
get_filename_component(_dir ${_headerFile} PATH)
|
|
||||||
list (APPEND include_dirs ${_dir})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
add_executable(Chess ${cpp_sources} ${c_sources})
|
|
||||||
set_target_properties(Chess PROPERTIES CXX_STANDARD 17) # set standard level
|
|
||||||
target_include_directories(Chess PRIVATE ${include_dirs})
|
|
||||||
target_compile_options(Chess PRIVATE
|
|
||||||
-Wall -Wextra -Wredundant-decls -Wcast-align
|
|
||||||
-Wshadow -Wnon-virtual-dtor
|
|
||||||
-Wunused -Woverloaded-virtual -Wpedantic -Wconversion
|
|
||||||
-Wsign-conversion -Wmisleading-indentation
|
|
||||||
-Wnull-dereference -Wformat=2
|
|
||||||
)
|
|
||||||
target_link_libraries(Chess SDL2::SDL2)
|
|
||||||
|
32
src/CMakeLists.txt
Normal file
32
src/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
|
||||||
|
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE cpp_sources
|
||||||
|
CONFIGURE_DEPENDS
|
||||||
|
"./*.cpp")
|
||||||
|
|
||||||
|
file(GLOB_RECURSE c_sources
|
||||||
|
CONFIGURE_DEPENDS
|
||||||
|
"./*.c")
|
||||||
|
|
||||||
|
file (GLOB_RECURSE headers CONFIGURE_DEPENDS "./*.h")
|
||||||
|
|
||||||
|
set (include_dirs "")
|
||||||
|
foreach (_headerFile ${headers})
|
||||||
|
get_filename_component(_dir ${_headerFile} PATH)
|
||||||
|
list (APPEND include_dirs ${_dir})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_executable(Chess ${cpp_sources} ${c_sources})
|
||||||
|
set_target_properties(Chess PROPERTIES CXX_STANDARD 17) # set standard level
|
||||||
|
target_include_directories(Chess PRIVATE ${include_dirs})
|
||||||
|
target_compile_options(Chess PRIVATE
|
||||||
|
-Wall -Wextra -Wredundant-decls -Wcast-align
|
||||||
|
-Wshadow -Wnon-virtual-dtor
|
||||||
|
-Wunused -Woverloaded-virtual -Wpedantic -Wconversion
|
||||||
|
-Wsign-conversion -Wmisleading-indentation
|
||||||
|
-Wnull-dereference -Wformat=2
|
||||||
|
)
|
||||||
|
target_link_libraries(Chess SDL2::SDL2)
|
@ -3,7 +3,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
char * fen_string_get_state(void);
|
char * fen_string_get_state(void);
|
||||||
void fen_string_set_state(void);
|
void fen_string_set_state(char *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
50
test/CMakeLists.txt
Normal file
50
test/CMakeLists.txt
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
googletest
|
||||||
|
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
file(GLOB_RECURSE cpp_sources
|
||||||
|
CONFIGURE_DEPENDS
|
||||||
|
"../src/*.cpp")
|
||||||
|
|
||||||
|
list(REMOVE_ITEM cpp_sources
|
||||||
|
"../src/pc_app/main.cpp")
|
||||||
|
|
||||||
|
file(GLOB_RECURSE test_sources
|
||||||
|
CONFIGURE_DEPENDS
|
||||||
|
"*.cc")
|
||||||
|
|
||||||
|
file(GLOB_RECURSE c_sources
|
||||||
|
CONFIGURE_DEPENDS
|
||||||
|
"../src/*.c")
|
||||||
|
|
||||||
|
file (GLOB_RECURSE headers CONFIGURE_DEPENDS "../src/*.h")
|
||||||
|
set (include_dirs "")
|
||||||
|
foreach (_headerFile ${headers})
|
||||||
|
get_filename_component(_dir ${_headerFile} PATH)
|
||||||
|
list (APPEND include_dirs ${_dir})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
hello_test
|
||||||
|
# ${cpp_sources}
|
||||||
|
${test_sources}
|
||||||
|
${c_sources}
|
||||||
|
)
|
||||||
|
target_include_directories(hello_test PRIVATE ${include_dirs})
|
||||||
|
target_link_libraries(
|
||||||
|
hello_test
|
||||||
|
GTest::gtest_main
|
||||||
|
SDL2::SDL2
|
||||||
|
)
|
||||||
|
|
||||||
|
include(GoogleTest)
|
||||||
|
gtest_discover_tests(hello_test)
|
||||||
|
|
12
test/game_logic/test_game_state.cc
Normal file
12
test/game_logic/test_game_state.cc
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "game_state.h"
|
||||||
|
#include "fen_strings.h"
|
||||||
|
|
||||||
|
// Demonstrate some basic assertions.
|
||||||
|
TEST(GameLogic, initialized_state) {
|
||||||
|
// Expect two strings not to be equal.
|
||||||
|
game_state_init();
|
||||||
|
char * test_data = fen_string_get_state();
|
||||||
|
EXPECT_STREQ(test_data, "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -");
|
||||||
|
}
|
||||||
|
|
10
test/hello_test.cc
Normal file
10
test/hello_test.cc
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
// Demonstrate some basic assertions.
|
||||||
|
TEST(HelloTest, BasicAssertions) {
|
||||||
|
// Expect two strings not to be equal.
|
||||||
|
EXPECT_STRNE("hello", "world");
|
||||||
|
// Expect equality.
|
||||||
|
EXPECT_EQ(7 * 6, 42);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user