LCOV - code coverage report
Current view: top level - src - time.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 21 21 100.0 %
Date: 2026-07-14 21:28:07 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 10 100.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright 2019-2026 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #include "read_utils.h"
       5                 :            : #include "time_utils.h"
       6                 :            : #include "write_utils.h"
       7                 :            : 
       8                 :            : #include <exess/exess.h>
       9                 :            : 
      10                 :            : #include <string.h>
      11                 :            : 
      12                 :            : EXESS_NONBLOCKING ExessOrder
      13                 :         96 : exess_compare_time(const ExessTime lhs, const ExessTime rhs)
      14                 :            : {
      15                 :         96 :   const ExessDateTime lhs_datetime = {
      16                 :         96 :     1972, 12U, 31U, lhs.zone, lhs.hour, lhs.minute, lhs.second, lhs.nanosecond};
      17                 :            : 
      18                 :         96 :   const ExessDateTime rhs_datetime = {
      19                 :         96 :     1972, 12U, 31U, rhs.zone, rhs.hour, rhs.minute, rhs.second, rhs.nanosecond};
      20                 :            : 
      21                 :         96 :   return exess_compare_date_time(lhs_datetime, rhs_datetime);
      22                 :            : }
      23                 :            : 
      24                 :            : EXESS_NONBLOCKING ExessResult
      25                 :       6052 : exess_read_time(const char* const str, ExessTime* const out)
      26                 :            : {
      27                 :       6052 :   memset(out, 0, sizeof(*out));
      28                 :            : 
      29                 :       6052 :   size_t      i = skip_whitespace(str);
      30                 :       6052 :   ExessResult r = read_time(out, str + i);
      31                 :            : 
      32         [ +  + ]:       6052 :   if (out->hour == 24) {
      33   [ +  +  +  +  :         11 :     if (out->minute || out->second || out->nanosecond) {
                   +  + ]
      34                 :          4 :       r.status = EXESS_OUT_OF_RANGE;
      35                 :            :     } else {
      36                 :          7 :       out->hour = 0;
      37                 :            :     }
      38                 :            :   }
      39                 :            : 
      40                 :       6052 :   r.count += i;
      41                 :       6052 :   return r;
      42                 :            : }
      43                 :            : 
      44                 :            : EXESS_NONBLOCKING ExessResult
      45                 :       5929 : exess_write_time(const ExessTime value, const size_t buf_size, char* const buf)
      46                 :            : {
      47         [ +  + ]:       5929 :   if (value.hour == 24) {
      48                 :          4 :     return end_write(EXESS_BAD_VALUE, buf_size, buf, 0);
      49                 :            :   }
      50                 :            : 
      51                 :       5925 :   const ExessResult r = write_time(value, buf_size, buf, 0);
      52                 :            : 
      53                 :       5925 :   return end_write(r.status, buf_size, buf, r.count);
      54                 :            : }

Generated by: LCOV version 1.16