From 033ce127e6b5368ce4c2739fa86a69707baff3fe Mon Sep 17 00:00:00 2001 From: Melefo Date: Mon, 20 Jan 2020 21:26:15 +0100 Subject: [PATCH] Preparing sources and tests for CI --- CMakeLists.txt | 22 +++++++++++++++++++--- main.cpp => sources/hello.cpp | 5 +++-- sources/main.cpp | 6 ++++++ tests/hello.cpp | 10 ++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) rename main.cpp => sources/hello.cpp (77%) create mode 100644 sources/main.cpp create mode 100644 tests/hello.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 385e282..413f196 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,22 @@ cmake_minimum_required(VERSION 3.15) -project(Hillnes) - set(CMAKE_CXX_STANDARD 20) -add_executable(Hillnes main.cpp) \ No newline at end of file +# set the project name +project(ComSquare) + +# show compilation warnings +add_compile_options(-W -Wall -Wextra -Wshadow) + +if (TEST) + # make unit tests + add_executable(unit_tests sources/hello.cpp tests/test_test.cpp) + + # include criterion & coverage + target_link_libraries(unit_tests criterion -lgcov) + target_compile_options(unit_tests PUBLIC -fprofile-arcs -ftest-coverage -g -O0) + +else (TEST) + # make app + add_executable(ComSquare sources/main.cpp sources/hello.cpp) + +endif (TEST) \ No newline at end of file diff --git a/main.cpp b/sources/hello.cpp similarity index 77% rename from main.cpp rename to sources/hello.cpp index bc8f460..b62ba07 100644 --- a/main.cpp +++ b/sources/hello.cpp @@ -1,6 +1,7 @@ #include -int main() { +int HelloWorld(void) +{ std::cout << "Hello, World!" << std::endl; return 0; -} +} \ No newline at end of file diff --git a/sources/main.cpp b/sources/main.cpp new file mode 100644 index 0000000..b92cc19 --- /dev/null +++ b/sources/main.cpp @@ -0,0 +1,6 @@ +int HelloWorld(void); + +int main(void) +{ + return HelloWorld(); +} \ No newline at end of file diff --git a/tests/hello.cpp b/tests/hello.cpp new file mode 100644 index 0000000..b8f8842 --- /dev/null +++ b/tests/hello.cpp @@ -0,0 +1,10 @@ +#include + +int HelloWorld(void); + +Test(HelloWorld, hello) +{ + int result = HelloWorld(); + + cr_assert_eq(result, 0); +} \ No newline at end of file