Added UTC handling for Windows

This commit is contained in:
Per Malmberg
2018-03-22 22:38:55 +01:00
parent 5395c75061
commit c441da4287
7 changed files with 80 additions and 27 deletions

View File

@@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.6)
project(cron_test)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra")
if( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif()
include_directories(
${CMAKE_CURRENT_LIST_DIR}/externals/Catch2/single_include/

View File

@@ -5,6 +5,7 @@
using namespace libcron;
using namespace std::chrono;
using namespace date;
std::string create_schedule_expiring_in(std::chrono::system_clock::time_point now, hours h, minutes m, seconds s)
{
@@ -221,7 +222,7 @@ class TestClock
SCENARIO("Clock changes")
{
GIVEN("A Cron instance with a single task expiring in 4h")
GIVEN("A Cron instance with a single task expiring every hour")
{
Cron<TestClock> c{};
auto& clock = c.get_clock();
@@ -239,11 +240,11 @@ SCENARIO("Clock changes")
WHEN("Clock changes <3h forward")
{
THEN("Task expires accordingly")
{
REQUIRE(c.tick() == 1);
clock.add(minutes{30}); // 00:30
REQUIRE(c.tick() == 0);
THEN("Task expires accordingly")
{
REQUIRE(c.tick() == 1);
clock.add(minutes{ 30 }); // 00:30
REQUIRE(c.tick() == 0);
clock.add(minutes{30}); // 01:00
REQUIRE(c.tick() == 1);
REQUIRE(c.tick() == 0);
@@ -294,6 +295,5 @@ SCENARIO("Clock changes")
REQUIRE(c.tick() == 1);
}
}
}
}