From 4efd4cf2ecf5486a8ae491cae9a73bf111e98740 Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 27 Apr 2024 21:31:42 +0200 Subject: [PATCH] Homework completed --- homework/schedule/CMakeLists.txt | 6 +++--- homework/schedule/schedule.hpp | 9 +++++++++ homework/schedule/tests/catch/catch_amalgamated.cpp | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 homework/schedule/schedule.hpp diff --git a/homework/schedule/CMakeLists.txt b/homework/schedule/CMakeLists.txt index a50c9e4..200ec72 100644 --- a/homework/schedule/CMakeLists.txt +++ b/homework/schedule/CMakeLists.txt @@ -7,9 +7,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include_directories(.) -add_executable(${PROJECT_NAME} main.cpp) -add_executable(${PROJECT_NAME}-ut tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests.cpp) -add_executable(${PROJECT_NAME}-ut-bonus tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests-bonus.cpp) +add_executable(${PROJECT_NAME} main.cpp schedule.hpp) +add_executable(${PROJECT_NAME}-ut schedule.hpp tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests.cpp) +add_executable(${PROJECT_NAME}-ut-bonus schedule.hpp tests/catch/catch_amalgamated.cpp tests/catch/catch_main.cpp tests/tests-bonus.cpp) target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -Wpedantic) target_compile_options(${PROJECT_NAME}-ut PRIVATE -Wall -Wextra -Werror -Wpedantic) diff --git a/homework/schedule/schedule.hpp b/homework/schedule/schedule.hpp new file mode 100644 index 0000000..2a5d979 --- /dev/null +++ b/homework/schedule/schedule.hpp @@ -0,0 +1,9 @@ +#pragma once +#include +#include + +template +void schedule(Func func, Sec sec, Data... d) { + std::this_thread::sleep_for(sec); + func(std::forward(d)...); +} diff --git a/homework/schedule/tests/catch/catch_amalgamated.cpp b/homework/schedule/tests/catch/catch_amalgamated.cpp index 3be8cc7..9fa9678 100644 --- a/homework/schedule/tests/catch/catch_amalgamated.cpp +++ b/homework/schedule/tests/catch/catch_amalgamated.cpp @@ -881,7 +881,7 @@ namespace Catch { multi->addListener(listener->create(config)); } - std::size_t reporterIdx = 0; + [[maybe_unused]] std::size_t reporterIdx = 0; for ( auto const& reporterSpec : config->getProcessedReporterSpecs() ) { multi->addReporter( createReporter( reporterSpec.name,