LCOV - code coverage report
Current view: top level - test - delta-macros-test.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 51 51 100.0 %
Date: 2017-04-30 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Present - Date/Time Library
       3             :  *
       4             :  * Tests for the "present_delta" shortcut macro
       5             :  *
       6             :  * Licensed under the MIT License.
       7             :  * For details, see LICENSE.
       8             :  */
       9             : 
      10             : #include "catch.hpp"
      11             : #include "test-utils.hpp"
      12             : 
      13             : #include "present.h"
      14             : 
      15           2 : TEST_CASE("present_delta macro creating MonthDeltas",
      16             :           "[delta-macros] [month-delta]") {
      17           1 :     CHECK(present_delta(3, year) == MonthDelta::from_years(3));
      18           1 :     CHECK(present_delta(-4, yr) == MonthDelta::from_years(-4));
      19           1 :     CHECK(present_delta(5, years) == MonthDelta::from_years(5));
      20           1 :     CHECK(present_delta(-6, yrs) == MonthDelta::from_years(-6));
      21             : 
      22           1 :     CHECK(present_delta(7, month) == MonthDelta::from_months(7));
      23           1 :     CHECK(present_delta(-8, month) == MonthDelta::from_months(-8));
      24           1 :     CHECK(present_delta(9, months) == MonthDelta::from_months(9));
      25           1 :     CHECK(present_delta(-10, months) == MonthDelta::from_months(-10));
      26           1 : }
      27             : 
      28           2 : TEST_CASE("present_delta macro creating DayDeltas",
      29             :           "[delta-macros] [day-delta]") {
      30           1 :     CHECK(present_delta(11, week) == DayDelta::from_weeks(11));
      31           1 :     CHECK(present_delta(-12, week) == DayDelta::from_weeks(-12));
      32           1 :     CHECK(present_delta(13, weeks) == DayDelta::from_weeks(13));
      33           1 :     CHECK(present_delta(-14, weeks) == DayDelta::from_weeks(-14));
      34             : 
      35           1 :     CHECK(present_delta(15, day) == DayDelta::from_days(15));
      36           1 :     CHECK(present_delta(-16, day) == DayDelta::from_days(-16));
      37           1 :     CHECK(present_delta(17, days) == DayDelta::from_days(17));
      38           1 :     CHECK(present_delta(-18, days) == DayDelta::from_days(-18));
      39           1 : }
      40             : 
      41           2 : TEST_CASE("present_delta macro creating TimeDeltas",
      42             :           "[delta-macros] [time-delta]") {
      43           1 :     CHECK(present_delta(19, week_time) == TimeDelta::from_weeks(19));
      44           1 :     CHECK(present_delta(-20, week_time) == TimeDelta::from_weeks(-20));
      45           1 :     CHECK(present_delta(21, weeks_time) == TimeDelta::from_weeks(21));
      46           1 :     CHECK(present_delta(-22, weeks_time) == TimeDelta::from_weeks(-22));
      47             : 
      48           1 :     CHECK(present_delta(23, day_time) == TimeDelta::from_days(23));
      49           1 :     CHECK(present_delta(-24, day_time) == TimeDelta::from_days(-24));
      50           1 :     CHECK(present_delta(25, days_time) == TimeDelta::from_days(25));
      51           1 :     CHECK(present_delta(-26, days_time) == TimeDelta::from_days(-26));
      52             : 
      53           1 :     CHECK(present_delta(27, hour) == TimeDelta::from_hours(27));
      54           1 :     CHECK(present_delta(28, hours) == TimeDelta::from_hours(28));
      55           1 :     CHECK(present_delta(29, hr) == TimeDelta::from_hours(29));
      56           1 :     CHECK(present_delta(30, hrs) == TimeDelta::from_hours(30));
      57             : 
      58           1 :     CHECK(present_delta(31, minute) == TimeDelta::from_minutes(31));
      59           1 :     CHECK(present_delta(32, minutes) == TimeDelta::from_minutes(32));
      60           1 :     CHECK(present_delta(33, min) == TimeDelta::from_minutes(33));
      61           1 :     CHECK(present_delta(34, mins) == TimeDelta::from_minutes(34));
      62             : 
      63           1 :     CHECK(present_delta(35, second) == TimeDelta::from_seconds(35));
      64           1 :     CHECK(present_delta(36, seconds) == TimeDelta::from_seconds(36));
      65           1 :     CHECK(present_delta(37, sec) == TimeDelta::from_seconds(37));
      66           1 :     CHECK(present_delta(38, secs) == TimeDelta::from_seconds(38));
      67             : 
      68           1 :     CHECK(present_delta(39, millisecond) == TimeDelta::from_milliseconds(39));
      69           1 :     CHECK(present_delta(40, milliseconds) == TimeDelta::from_milliseconds(40));
      70           1 :     CHECK(present_delta(41, ms) == TimeDelta::from_milliseconds(41));
      71             : 
      72           1 :     CHECK(present_delta(42, microsecond) == TimeDelta::from_microseconds(42));
      73           1 :     CHECK(present_delta(43, microseconds) == TimeDelta::from_microseconds(43));
      74           1 :     CHECK(present_delta(44, us) == TimeDelta::from_microseconds(44));
      75             : 
      76           1 :     CHECK(present_delta(45, nanosecond) == TimeDelta::from_nanoseconds(45));
      77           1 :     CHECK(present_delta(46, nanoseconds) == TimeDelta::from_nanoseconds(46));
      78           1 :     CHECK(present_delta(47, ns) == TimeDelta::from_nanoseconds(47));
      79           4 : }
      80             : 

Generated by: LCOV version 1.10