Refactor to make a test
This commit is contained in:
parent
303deb5940
commit
9814dc0b9b
18 changed files with 28 additions and 20 deletions
|
@ -1,2 +1,11 @@
|
|||
include(${CMAKE_BINARY_DIR}/conan.cmake)
|
||||
conan_add_remote(NAME bincrafters INDEX 1 URL https://api.bintray.com/conan/bincrafters/public-conan)
|
||||
|
||||
conan_cmake_run(CONANFILE conanfile.py BASIC_SETUP CMAKE_TARGETS BUILD missing)
|
||||
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(test)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/assets/maze.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/assets/sprites32.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
7
pacman/lib/CMakeLists.txt
Normal file
7
pacman/lib/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
find_package(sdl2 REQUIRED)
|
||||
find_package(sdl2_image REQUIRED)
|
||||
include_directories(${sdl2_INCLUDE_DIRS} ${sdl2_image_INCLUDE_DIRS})
|
||||
|
||||
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "*.cpp")
|
||||
add_library(libpacman ${sources})
|
||||
target_link_libraries(libpacman sdl2::sdl2 sdl2_image::sdl2_image)
|
|
@ -1,15 +1,4 @@
|
|||
include(${CMAKE_BINARY_DIR}/conan.cmake)
|
||||
conan_add_remote(NAME bincrafters INDEX 1 URL https://api.bintray.com/conan/bincrafters/public-conan)
|
||||
|
||||
conan_cmake_run(CONANFILE ../conanfile.py BASIC_SETUP CMAKE_TARGETS BUILD missing)
|
||||
|
||||
find_package(sdl2 REQUIRED)
|
||||
find_package(sdl2_image REQUIRED)
|
||||
include_directories(${sdl2_INCLUDE_DIRS} ${sdl2_image_INCLUDE_DIRS})
|
||||
|
||||
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "*.cpp")
|
||||
add_executable(PacMan ${sources})
|
||||
target_link_libraries(PacMan sdl2::sdl2 sdl2_image::sdl2_image)
|
||||
add_executable(pacman ${sources})
|
||||
target_link_libraries(pacman libpacman)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../assets/maze.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../assets/sprites32.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
|
@ -1,4 +1,4 @@
|
|||
#include "Game.h"
|
||||
#include "../lib/Game.h"
|
||||
|
||||
extern "C" int main([[maybe_unused]] int argc, [[maybe_unused]] char * argv[]) {
|
||||
Game game;
|
||||
|
|
|
@ -4,8 +4,8 @@ find_package(GTest REQUIRED)
|
|||
include(GoogleTest)
|
||||
|
||||
add_executable(tests tests.cpp)
|
||||
target_link_libraries(tests GTest::GTest)
|
||||
target_link_libraries(tests GTest::GTest libpacman)
|
||||
|
||||
gtest_add_tests(TARGET tests TEST_PREFIX old_pacman:)
|
||||
gtest_discover_tests(tests TEST_PREFIX new_pacman:)
|
||||
#gtest_add_tests(TARGET tests TEST_PREFIX old_pacman:)
|
||||
gtest_discover_tests(tests TEST_PREFIX pacman:)
|
||||
add_test(NAME monolithic COMMAND tests)
|
|
@ -1,7 +1,10 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include "../lib/PacMan.h"
|
||||
|
||||
TEST(PacManTest, Allocate) {
|
||||
EXPECT_EQ(0, 1);
|
||||
TEST(PacManTest, InitialPosition) {
|
||||
PacMan pacMan;
|
||||
EXPECT_EQ(pacMan.currentPosition().x, 14);
|
||||
EXPECT_EQ(pacMan.currentPosition().y, 23);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
|
Loading…
Reference in a new issue