Skip to content
Snippets Groups Projects
Commit 0f156e72 authored by Le-Bao-Tin.Ha's avatar Le-Bao-Tin.Ha
Browse files

add module test

parent f83ddd9c
No related branches found
No related tags found
4 merge requests!8Modele,!7Modele,!6Modele,!5Modele Version 1
cmake_minimum_required(VERSION 3.17)
project(INSAGAME C)
set(CMAKE_C_STANDARD 90)
set(CMAKE_CXX_STANDARD 11)
if (WIN32)
message ([STATUS]" os Windows")
include_directories(include)
set(SDL2_INCLUDE_DIR C:/TDM-GCC-64/x86_64-w64-mingw32/include)
set(SDL2_LIB_DIR C:/TDM-GCC-64/x86_64-w64-mingw32/lib)
file(GLOB_RECURSE SOURCES "src/*c" main.c)
add_executable(INSAGAME ${SOURCES})
target_link_libraries(${PROJECT_NAME} mingw32 SDL2main SDL2 SDL2_image)
option(BUILD_TESTS OFF)
set(BUILD_TESTS ON)
if(BUILD_TESTS)
project(INSAGAMETEST C CXX)
set(GTEST_INCLUDE_DIR /googletest/googletest/include)
include_directories(include)
include_directories(${GTEST_INCLUDE_DIR})
enable_testing()
add_subdirectory(googletest)
file(GLOB_RECURSE SOURCES "src/*c" test_main.cpp)
add_executable(INSAGAMETEST ${SOURCES})
target_link_libraries(${PROJECT_NAME} mingw32 SDL2main SDL2 SDL2_image gtest gtest_main)
add_test(
NAME INSAGAMETEST
COMMAND INSAGAMETEST
)
else()
include_directories(include)
project(INSAGAME C)
file(GLOB_RECURSE SOURCES "src/*c" main.c)
add_executable(INSAGAME ${SOURCES})
target_link_libraries(${PROJECT_NAME} mingw32 SDL2main SDL2 SDL2_image)
endif(BUILD_TESTS)
else(APPLE)
......@@ -27,7 +54,7 @@ else(APPLE)
include_directories( ${SDL2_INCLUDE_DIRS} "/usr/local/Cellar/sdl2_image/2.0.5/include/SDL2" "include" )
file(GLOB_RECURSE SOURCES "src/*c" main.c)
add_executable(INSAGAME ${SOURCES} include/GAME.c include/GAME.h)
add_executable(INSAGAME ${SOURCES} include/GAME.c include/GAME.h test_main.c test/testpersonnage.cpp)
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} "-L/usr/local/Cellar/sdl2_image/2.0.5/lib -lSDL2")
......
/*
// Created by Tiny on 3/14/2021.
*/
#ifndef INSAGAME_TEST_PERSONNAGE_H
#define INSAGAME_TEST_PERSONNAGE_H
#include <gtest/gtest.h>
extern "C"{
#include "personnage.h"
}
TEST(test_init_personnage,values_3_3_3_3_3_testimage){
Personnage person;
init_pers(&person,3,3,3,3,3,"testimage");
EXPECT_EQ(3,person.x_pers);
EXPECT_EQ(3,person.y_pers);
EXPECT_EQ(3,person.long_pers);
EXPECT_EQ(3,person.larg_pers);
EXPECT_STREQ("testimage",person.image_pers);
}
TEST(test_calcul_point,values_3_3){
Personnage person;
init_pers(&person,3,3,3,3,3,"testimage");
calculpointspers(&person);
EXPECT_EQ(6,person.x_hr);
EXPECT_EQ(3,person.y_hr);
EXPECT_EQ(3,person.x_ll);
EXPECT_EQ(6,person.y_ll);
EXPECT_EQ(6,person.x_lr);
EXPECT_EQ(6,person.y_lr);
}
#endif /*INSAGAME_TEST_PERSONNAGE_H*/
#include <gtest/gtest.h>
#include "test_personnage.h"
int main(int argc, char* args[]){
::testing::InitGoogleTest(&argc, args);
return RUN_ALL_TESTS();
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment