LCOV - code coverage report
Current view: top level - src - month.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 17 17 100.0 %
Date: 2026-08-20 23:47:58 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 6 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 "date_utils.h"
       5                 :            : #include "number_utils.h"
       6                 :            : #include "read_utils.h"
       7                 :            : #include "result.h"
       8                 :            : #include "timezone.h"
       9                 :            : #include "write_utils.h"
      10                 :            : 
      11                 :            : #include <exess/exess.h>
      12                 :            : 
      13                 :            : #include <string.h>
      14                 :            : 
      15                 :            : EXESS_NONBLOCKING ExessResult
      16                 :         40 : exess_read_month(const char* const str, ExessMonth* const out)
      17                 :            : {
      18                 :         40 :   memset(out, 0, sizeof(*out));
      19                 :            : 
      20                 :            :   // Skip leading absent-year delimiter
      21                 :         40 :   size_t i = skip_whitespace(str);
      22         [ +  + ]:         40 :   if (str[i] != '-') {
      23                 :          5 :     return RESULT(EXESS_EXPECTED_DASH, i);
      24                 :            :   }
      25                 :            : 
      26                 :            :   // Read (leading month delimiter and) month
      27                 :         35 :   ++i;
      28                 :         35 :   ExessResult r = read_date_m(&out->month, str + i);
      29                 :            : 
      30                 :            :   // Read timezone if present
      31                 :         35 :   r.count = i + r.count;
      32                 :         35 :   return read_optional_timezone(&out->zone, str, r);
      33                 :            : }
      34                 :            : 
      35                 :            : EXESS_NONBLOCKING ExessResult
      36                 :         24 : exess_write_month(const ExessMonth value,
      37                 :            :                   const size_t     buf_size,
      38                 :            :                   char* const      buf)
      39                 :            : {
      40   [ +  +  +  + ]:         24 :   if (value.month < 1 || value.month > 12) {
      41                 :          2 :     return end_write(EXESS_BAD_VALUE, buf_size, buf, 0);
      42                 :            :   }
      43                 :            : 
      44                 :            :   // Write -MM number
      45                 :         22 :   ExessResult r = {EXESS_SUCCESS, 0};
      46                 :         22 :   r.count += write_char('-', buf_size, buf, r.count);
      47                 :         22 :   r.count += write_char('-', buf_size, buf, r.count);
      48                 :         22 :   r.count += write_two_digit_number(value.month, buf_size, buf, r.count);
      49                 :            : 
      50                 :         22 :   return write_timezone(value.zone, buf_size, buf, r);
      51                 :            : }

Generated by: LCOV version 1.16