Line data Source code
1 : //------------------------------------------------------------------------------ 2 : // LAGraph/src/test/test_KindName.c: test LG_KindName 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 : #include "LG_internal.h" 20 : 21 : //------------------------------------------------------------------------------ 22 : // global variables 23 : //------------------------------------------------------------------------------ 24 : 25 : char msg [LAGRAPH_MSG_LEN] ; 26 : char name [LAGRAPH_MAX_NAME_LEN] ; 27 : 28 : //------------------------------------------------------------------------------ 29 : // setup: start a test 30 : //------------------------------------------------------------------------------ 31 : 32 1 : void setup (void) 33 : { 34 1 : OK (LAGraph_Init (msg)) ; 35 1 : } 36 : 37 : //------------------------------------------------------------------------------ 38 : // teardown: finalize a test 39 : //------------------------------------------------------------------------------ 40 : 41 1 : void teardown (void) 42 : { 43 1 : OK (LAGraph_Finalize (msg)) ; 44 1 : } 45 : 46 : //------------------------------------------------------------------------------ 47 : // test_KindName: test LG_KindName 48 : //------------------------------------------------------------------------------ 49 : 50 1 : void test_KindName (void) 51 : { 52 1 : setup ( ) ; 53 : 54 1 : OK (LG_KindName (name, LAGraph_ADJACENCY_UNDIRECTED, msg)) ; 55 1 : OK (strcmp (name, "undirected")) ; 56 : 57 1 : OK (LG_KindName (name, LAGraph_ADJACENCY_DIRECTED, msg)) ; 58 1 : OK (strcmp (name, "directed")) ; 59 : 60 1 : OK (LG_KindName (name, LAGRAPH_UNKNOWN, msg)) ; 61 1 : OK (strcmp (name, "unknown")) ; 62 : 63 1 : TEST_CHECK (LG_KindName (name, 42, msg) == GrB_INVALID_VALUE) ; 64 1 : printf ("\nmsg: %s\n", msg) ; 65 : 66 1 : teardown ( ) ; 67 1 : } 68 : 69 : //------------------------------------------------------------------------------ 70 : // test_KindName_brutal 71 : //------------------------------------------------------------------------------ 72 : 73 : // LG_KindName currently doesn't do any mallocs so this test is not 74 : // strictly necessary, but it's simple to include here. It serves as a very 75 : // simple use-case of the brutal testing mechanism. 76 : 77 : #if LAGRAPH_SUITESPARSE 78 1 : void test_KindName_brutal (void) 79 : { 80 1 : OK (LG_brutal_setup (msg)) ; 81 1 : LG_BRUTAL (LG_KindName (name, LAGraph_ADJACENCY_UNDIRECTED, msg)) ; 82 1 : OK (strcmp (name, "undirected")) ; 83 1 : OK (LG_brutal_teardown (msg)) ; 84 1 : } 85 : #endif 86 : 87 : //----------------------------------------------------------------------------- 88 : // TEST_LIST: the list of tasks for this entire test 89 : //----------------------------------------------------------------------------- 90 : 91 : TEST_LIST = 92 : { 93 : { "KindName", test_KindName }, 94 : #if LAGRAPH_SUITESPARSE 95 : { "KindName_brutal", test_KindName_brutal }, 96 : #endif 97 : { NULL, NULL } 98 : } ;