LCOV - code coverage report
Current view: top level - src/test - test_fopen.c (source / functions) Hit Total Coverage
Test: LAGraph code coverage report. Commit id: 3b461aa. Current time (UTC): 2024-01-25T16:04:32Z Lines: 13 13 100.0 %
Date: 2024-01-25 16:05:28 Functions: 2 2 100.0 %

          Line data    Source code
       1             : //-----------------------------------------------------------------------------
       2             : // LAGraph/src/test/test_fopen.c:  test fopen
       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 "LAGraph_test.h"
      19             : 
      20             : //-----------------------------------------------------------------------------
      21             : // test fopen, as an example of how to use LG_SOURCE_DIR
      22             : //-----------------------------------------------------------------------------
      23             : 
      24           1 : void test_fopen(void)
      25             : {
      26             :     char buffer [1000] ;
      27           1 :     printf ("\nLAGraph source directory: [%s]\n", LG_SOURCE_DIR) ;
      28           1 :     FILE *f = fopen (LG_SOURCE_DIR "/data/A.mtx", "r") ;
      29           1 :     TEST_CHECK (f != NULL) ;
      30           1 :     char *r = fgets (buffer, 512, f) ;
      31           1 :     TEST_CHECK (r != NULL) ;
      32           1 :     printf ("[%s]\n", buffer) ;
      33           1 :     fclose (f) ;
      34           1 : }
      35             : 
      36           1 : void test_fopen_failure (void)
      37             : {
      38           1 :     FILE *f = fopen ("garbage", "r") ;
      39           1 :     TEST_CHECK (f == NULL) ;
      40           1 : }
      41             : 
      42             : //-----------------------------------------------------------------------------
      43             : // run the test
      44             : //-----------------------------------------------------------------------------
      45             : 
      46             : TEST_LIST =
      47             : {
      48             :     { "fopen", test_fopen },
      49             :     { "fopen_failure", test_fopen_failure },
      50             :     // no brutal test needed
      51             :     { NULL, NULL }
      52             : } ;

Generated by: LCOV version 1.14