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: 11 11 100.0 %
Date: 2021-08-30 06:43:37 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2018 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             : /**
      33             :  * End a trait array.  Usually, commands offer several traits,
      34             :  * and put them in arrays.
      35             :  */
      36             : struct TALER_TESTING_Trait
      37        4537 : TALER_TESTING_trait_end ()
      38             : {
      39        4537 :   struct TALER_TESTING_Trait end = {
      40             :     .index = 0,
      41             :     .trait_name = NULL,
      42             :     .ptr = NULL
      43             :   };
      44             : 
      45        4537 :   return end;
      46             : }
      47             : 
      48             : 
      49             : /**
      50             :  * Pick the chosen trait from the traits array.
      51             :  *
      52             :  * @param traits the traits array.
      53             :  * @param ret where to store the result.
      54             :  * @param trait type of the trait to extract.
      55             :  * @param index index number of the object to extract.
      56             :  * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
      57             :  */
      58             : int
      59        4517 : TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
      60             :                          const void **ret,
      61             :                          const char *trait,
      62             :                          unsigned int index)
      63             : {
      64       17088 :   for (unsigned int i = 0; NULL != traits[i].trait_name; i++)
      65             :   {
      66       16584 :     if ( (0 == strcmp (trait, traits[i].trait_name)) &&
      67        6189 :          (index == traits[i].index) )
      68             :     {
      69        4013 :       *ret = (void *) traits[i].ptr;
      70        4013 :       return GNUNET_OK;
      71             :     }
      72             :   }
      73         504 :   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
      74             :               "Trait %s/%u not found.\n",
      75             :               trait, index);
      76             : 
      77         504 :   return GNUNET_SYSERR;
      78             : }
      79             : 
      80             : 
      81             : /* end of testing_api_traits.c */

Generated by: LCOV version 1.14