LCOV - code coverage report
Current view: top level - test - time_test_utils.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 7 7 100.0 %
Date: 2026-07-14 21:28:07 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 2 100.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright 2011-2021 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #ifndef EXESS_TEST_TIME_TEST_UTILS_H
       5                 :            : #define EXESS_TEST_TIME_TEST_UTILS_H
       6                 :            : 
       7                 :            : #include "int_test_utils.h"
       8                 :            : 
       9                 :            : #include <exess/exess.h>
      10                 :            : 
      11                 :            : #include <stdbool.h>
      12                 :            : #include <stdint.h>
      13                 :            : 
      14                 :            : #define INIT_ZONE(hour, minute) ((4 * (hour)) + ((minute) / 15))
      15                 :            : 
      16                 :            : static inline ExessTimezone
      17                 :       1440 : random_timezone(uint32_t* rng)
      18                 :            : {
      19                 :       1440 :   *rng = lcg32(*rng);
      20                 :            : 
      21                 :       1440 :   const int8_t hour = (int8_t)((*rng % 27) - 13);
      22                 :            : 
      23                 :       1440 :   *rng = lcg32(*rng);
      24                 :            : 
      25         [ +  + ]:       1440 :   const int8_t minute = (int8_t)((hour < 0 ? -1 : 1) * (int32_t)(*rng % 60));
      26                 :            : 
      27                 :       1440 :   const ExessTimezone zone = {(int8_t)((4 * hour) + (minute / 15))};
      28                 :       1440 :   return zone;
      29                 :            : }
      30                 :            : 
      31                 :            : static inline bool
      32                 :            : timezone_matches(const ExessTimezone zone,
      33                 :            :                  const int8_t        expected_hour,
      34                 :            :                  const int8_t        expected_minute,
      35                 :            :                  const bool          expected_is_present)
      36                 :            : 
      37                 :            : {
      38                 :            :   return (!expected_is_present && zone == EXESS_TIMEZONE_LOCAL) ||
      39                 :            :          zone == (4 * expected_hour) + (expected_minute / 15);
      40                 :            : }
      41                 :            : 
      42                 :            : #endif // EXESS_TEST_TIME_TEST_UTILS_H

Generated by: LCOV version 1.16