Add variables
This commit is contained in:
parent
2d5d59de4d
commit
14866848dc
|
|
@ -1,21 +1,70 @@
|
||||||
# CMakeList.txt : projet CMake pour TestJenkins, incluez la source et définissez
|
cmake_minimum_required(VERSION 3.10)
|
||||||
# la logique spécifique au projet ici.
|
|
||||||
|
project(TestJenkins VERSION 1.0)
|
||||||
|
|
||||||
|
# C++ Standard
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Enable testing
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Person library
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
add_library(Person
|
||||||
|
src/Person.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(Person
|
||||||
|
PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
|
)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Main executable
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
add_executable(TestJenkins
|
||||||
|
src/TestJenkins.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(TestJenkins
|
||||||
|
PRIVATE
|
||||||
|
Person
|
||||||
|
)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# GoogleTest
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#include(FetchContent)
|
||||||
|
#
|
||||||
|
#FetchContent_Declare(
|
||||||
|
# googletest
|
||||||
|
# URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
|
||||||
|
#)
|
||||||
|
#
|
||||||
|
#FetchContent_MakeAvailable(googletest)
|
||||||
|
#
|
||||||
|
#add_executable(UT_Person
|
||||||
|
# tests/UT_Person.cpp
|
||||||
|
#)
|
||||||
|
#
|
||||||
|
#target_link_libraries(UT_Person
|
||||||
|
# PRIVATE
|
||||||
|
# Person
|
||||||
|
# GTest::gtest
|
||||||
|
# GTest::gtest_main
|
||||||
|
#)
|
||||||
|
#
|
||||||
|
#include(GoogleTest)
|
||||||
|
#gtest_discover_tests(UT_Person)
|
||||||
|
#
|
||||||
|
## Optional: place executables in a common output folder
|
||||||
|
#set_target_properties(TestJenkins UT_Person PROPERTIES
|
||||||
|
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||||
|
#)
|
||||||
#
|
#
|
||||||
cmake_minimum_required (VERSION 3.8)
|
|
||||||
|
|
||||||
# Activez Rechargement à chaud pour les compilateurs MSVC si cela est pris en charge.
|
|
||||||
if (POLICY CMP0141)
|
|
||||||
cmake_policy(SET CMP0141 NEW)
|
|
||||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
project ("TestJenkins")
|
|
||||||
|
|
||||||
# Ajoutez une source à l'exécutable de ce projet.
|
|
||||||
add_executable (TestJenkins "TestJenkins.cpp" "TestJenkins.h")
|
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
|
||||||
set_property(TARGET TestJenkins PROPERTY CXX_STANDARD 20)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# TODO: Ajoutez des tests et installez des cibles si nécessaire.
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
// TestJenkins.cpp : définit le point d'entrée de l'application.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "TestJenkins.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
cout << "Hello World Willy test 3!" << endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "Person.h"
|
||||||
|
|
||||||
|
std::string Person::getName() const
|
||||||
|
{
|
||||||
|
return "Willy";
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Person::getAge() const
|
||||||
|
{
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Person
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string getName() const;
|
||||||
|
unsigned int getAge() const;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include "TestJenkins.h"
|
||||||
|
#include "Person.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
Person p;
|
||||||
|
cout << "Hello " << p.getName() << " : " << p.getAge() << " yo !" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "Person.h"
|
||||||
|
|
||||||
|
TEST(PersonTest, VerifyName)
|
||||||
|
{
|
||||||
|
Person person;
|
||||||
|
EXPECT_EQ(person.getName(), "Willy");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PersonTest, VerifyAge)
|
||||||
|
{
|
||||||
|
Person person;
|
||||||
|
EXPECT_EQ(person.getAge(), 32u);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue