LCOV - code coverage report
Current view: top level - src/libvalent/core - valent-version.c (source / functions) Coverage Total Hit
Test: Code Coverage Lines: 100.0 % 10 10
Test Date: 2024-05-05 22:34:11 Functions: 100.0 % 4 4
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 75.0 % 4 3

             Branch data     Line data    Source code
       1                 :             : // SPDX-License-Identifier: GPL-3.0-or-later
       2                 :             : // SPDX-FileCopyrightText: Andy Holmes <andrew.g.r.holmes@gmail.com>
       3                 :             : 
       4                 :             : #include "config.h"
       5                 :             : 
       6                 :             : #include <glib.h>
       7                 :             : 
       8                 :             : #include "valent-version.h"
       9                 :             : 
      10                 :             : 
      11                 :             : /**
      12                 :             :  * valent_check_version:
      13                 :             :  * @major: required major version
      14                 :             :  * @minor: required minor version
      15                 :             :  *
      16                 :             :  * Run-time version check.
      17                 :             :  *
      18                 :             :  * Evaluates to %TRUE if the API version of libvalent is greater than or equal
      19                 :             :  * to the required one.
      20                 :             :  *
      21                 :             :  * Returns: %TRUE if the requirement is met, or %FALSE if not
      22                 :             :  *
      23                 :             :  * Since: 1.0
      24                 :             :  */
      25                 :             : gboolean
      26                 :           3 : valent_check_version (unsigned int major,
      27                 :             :                       unsigned int minor)
      28                 :             : {
      29         [ +  - ]:           3 :   if (VALENT_MAJOR_VERSION > major)
      30                 :             :     return TRUE;
      31                 :             : 
      32         [ +  + ]:           3 :   if (VALENT_MAJOR_VERSION == major && VALENT_MINOR_VERSION >= minor)
      33                 :           1 :     return TRUE;
      34                 :             : 
      35                 :             :   return FALSE;
      36                 :             : }
      37                 :             : 
      38                 :             : /**
      39                 :             :  * valent_get_major_version:
      40                 :             :  *
      41                 :             :  * Get the major version component of the Valent library.
      42                 :             :  *
      43                 :             :  * For example, if the version `1.2` this is `1`.
      44                 :             :  *
      45                 :             :  * Returns: the major version component of libvalent
      46                 :             :  *
      47                 :             :  * Since: 1.0
      48                 :             :  */
      49                 :             : unsigned int
      50                 :           1 : valent_get_major_version (void)
      51                 :             : {
      52                 :           1 :   return VALENT_MAJOR_VERSION;
      53                 :             : }
      54                 :             : 
      55                 :             : /**
      56                 :             :  * valent_get_minor_version:
      57                 :             :  *
      58                 :             :  * Get the minor version component of the Valent library.
      59                 :             :  *
      60                 :             :  * For example, if the version `1.2` this is `2`.
      61                 :             :  *
      62                 :             :  * Returns: the minor version component of libvalent
      63                 :             :  *
      64                 :             :  * Since: 1.0
      65                 :             :  */
      66                 :             : unsigned int
      67                 :           1 : valent_get_minor_version (void)
      68                 :             : {
      69                 :           1 :   return VALENT_MINOR_VERSION;
      70                 :             : }
      71                 :             : 
      72                 :             : /**
      73                 :             :  * valent_get_micro_version:
      74                 :             :  *
      75                 :             :  * Get the micro version component of the Valent library.
      76                 :             :  *
      77                 :             :  * For example, if the version `1.2.3` this is `3`.
      78                 :             :  *
      79                 :             :  * Returns: the micro version component of libvalent
      80                 :             :  *
      81                 :             :  * Since: 1.0
      82                 :             :  */
      83                 :             : unsigned int
      84                 :           1 : valent_get_micro_version (void)
      85                 :             : {
      86                 :           1 :   return VALENT_MICRO_VERSION;
      87                 :             : }
      88                 :             : 
        

Generated by: LCOV version 2.0-1