LCOV - code coverage report
Current view: top level - testing - testing_api_traits.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 14 14 100.0 %
Date: 2022-08-25 06:15:09 Functions: 25 120 20.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2018, 2021 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify
       6             :   it under the terms of the GNU General Public License as
       7             :   published by the Free Software Foundation; either version 3, or
       8             :   (at your option) any later version.
       9             : 
      10             :   TALER is distributed in the hope that it will be useful, but
      11             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :   GNU General Public License for more details.
      14             : 
      15             :   You should have received a copy of the GNU General Public
      16             :   License along with TALER; see the file COPYING.  If not, see
      17             :   <http://www.gnu.org/licenses/>
      18             : */
      19             : /**
      20             :  * @file testing/testing_api_traits.c
      21             :  * @brief loop for trait resolution
      22             :  * @author Christian Grothoff
      23             :  * @author Marcello Stanisci
      24             :  */
      25             : #include "platform.h"
      26             : #include "taler_json_lib.h"
      27             : #include <gnunet/gnunet_curl_lib.h>
      28             : #include "taler_signatures.h"
      29             : #include "taler_testing_lib.h"
      30             : 
      31             : 
      32         508 : TALER_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
      33             : 
      34         100 : TALER_TESTING_INDEXED_TRAITS (TALER_TESTING_MAKE_IMPL_INDEXED_TRAIT)
      35             : 
      36             : 
      37             : /**
      38             :  * End a trait array.  Usually, commands offer several traits,
      39             :  * and put them in arrays.
      40             :  */
      41             : struct TALER_TESTING_Trait
      42          57 : TALER_TESTING_trait_end ()
      43             : {
      44          57 :   struct TALER_TESTING_Trait end = {
      45             :     .index = 0,
      46             :     .trait_name = NULL,
      47             :     .ptr = NULL
      48             :   };
      49             : 
      50          57 :   return end;
      51             : }
      52             : 
      53             : 
      54             : enum GNUNET_GenericReturnValue
      55          57 : TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
      56             :                          const void **ret,
      57             :                          const char *trait,
      58             :                          unsigned int index)
      59             : {
      60         259 :   for (unsigned int i = 0; NULL != traits[i].trait_name; i++)
      61             :   {
      62         253 :     if ( (0 == strcmp (trait,
      63         253 :                        traits[i].trait_name)) &&
      64          51 :          (index == traits[i].index) )
      65             :     {
      66          51 :       *ret = (void *) traits[i].ptr;
      67          51 :       return GNUNET_OK;
      68             :     }
      69             :   }
      70           6 :   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
      71             :               "Trait %s/%u not found.\n",
      72             :               trait,
      73             :               index);
      74           6 :   return GNUNET_SYSERR;
      75             : }
      76             : 
      77             : 
      78             : /* end of testing_api_traits.c */

Generated by: LCOV version 1.14