LCOV - code coverage report
Current view: top level - src/utility - LAGraph_NameOfType.c (source / functions) Hit Total Coverage
Test: LAGraph code coverage report. Commit id: cc56ed4. Current time (UTC): 2024-08-30T17:14:30Z Lines: 18 18 100.0 %
Date: 2024-08-30 17:16:41 Functions: 1 1 100.0 %

          Line data    Source code
       1             : //------------------------------------------------------------------------------
       2             : // LAGraph_NameOfType: return the C name of a GraphBLAS GrB_Type
       3             : //------------------------------------------------------------------------------
       4             : 
       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
       6             : // SPDX-License-Identifier: BSD-2-Clause
       7             : //
       8             : // For additional details (including references to third party source code and
       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
      10             : // Contributors.txt for a full list of contributors. Created, in part, with
      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
      12             : // DM22-0790
      13             : 
      14             : // Contributed by Timothy A. Davis, Texas A&M University
      15             : 
      16             : //------------------------------------------------------------------------------
      17             : 
      18             : #include "LG_internal.h"
      19             : 
      20          15 : int LAGraph_NameOfType
      21             : (
      22             :     // output:
      23             :     char *name,     // name of the type: user provided array of size at
      24             :                     // least LAGRAPH_MAX_NAME_LEN.
      25             :     // input:
      26             :     GrB_Type type,  // GraphBLAS type
      27             :     char *msg
      28             : )
      29             : {
      30             : 
      31             :     //--------------------------------------------------------------------------
      32             :     // check inputs
      33             :     //--------------------------------------------------------------------------
      34             : 
      35          15 :     LG_CLEAR_MSG ;
      36          15 :     LG_ASSERT (type != NULL, GrB_NULL_POINTER) ;
      37          13 :     LG_ASSERT (name != NULL, GrB_NULL_POINTER) ;
      38             : 
      39             :     //--------------------------------------------------------------------------
      40             :     // determine the name of the type
      41             :     //--------------------------------------------------------------------------
      42             : 
      43          12 :         if      (type == GrB_BOOL  ) strcpy (name, "bool")     ;
      44          11 :         else if (type == GrB_INT8  ) strcpy (name, "int8_t")   ;
      45          10 :         else if (type == GrB_INT16 ) strcpy (name, "int16_t")  ;
      46           9 :         else if (type == GrB_INT32 ) strcpy (name, "int32_t")  ;
      47           8 :         else if (type == GrB_INT64 ) strcpy (name, "int64_t")  ;
      48           7 :         else if (type == GrB_UINT8 ) strcpy (name, "uint8_t")  ;
      49           6 :         else if (type == GrB_UINT16) strcpy (name, "uint16_t") ;
      50           5 :         else if (type == GrB_UINT32) strcpy (name, "uint32_t") ;
      51           4 :         else if (type == GrB_UINT64) strcpy (name, "uint64_t") ;
      52           3 :         else if (type == GrB_FP32  ) strcpy (name, "float")    ;
      53           2 :         else if (type == GrB_FP64  ) strcpy (name, "double")   ;
      54             :         #if 0
      55             :         else if (type == GxB_FC32  ) strcpy (name, "float complex") ;
      56             :         else if (type == GxB_FC64  ) strcpy (name, "double complex") ;
      57             :         #endif
      58             :         else
      59             :         {
      60           1 :             name [0] = '\0' ;
      61           1 :             LG_ASSERT_MSG (false,
      62             :                 GrB_NOT_IMPLEMENTED, "user-defined types not supported") ;
      63             :         }
      64          11 :         return (GrB_SUCCESS) ;
      65             : 
      66             : }

Generated by: LCOV version 1.14