Line data Source code
1 : //----------------------------------------------------------------------------- 2 : // LAGraph/src/test/test_Multiply_size_t.c: test LG_Multiply_size_t 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 : // test_multiply 23 : //----------------------------------------------------------------------------- 24 : 25 1 : void test_multiply (void) 26 : { 27 : char msg [LAGRAPH_MSG_LEN] ; 28 1 : OK (LAGraph_Init (msg)) ; 29 : 30 1 : size_t c = 99 ; 31 1 : TEST_CHECK (LG_Multiply_size_t (&c, (size_t) 0, (size_t) 42)) ; 32 1 : TEST_CHECK (c == 0) ; 33 : 34 1 : TEST_CHECK (LG_Multiply_size_t (&c, (size_t) 77, (size_t) 42)) ; 35 1 : TEST_CHECK (c == 77 * 42) ; 36 : 37 1 : TEST_CHECK (!LG_Multiply_size_t (&c, (size_t) SIZE_MAX, (size_t) 42)) ; 38 : 39 1 : size_t a = SIZE_MAX / 2 ; 40 1 : TEST_CHECK (!LG_Multiply_size_t (&c, a, a)) ; 41 : 42 1 : OK (LAGraph_Finalize (msg)) ; 43 1 : } 44 : 45 : //----------------------------------------------------------------------------- 46 : // TEST_LIST: the list of tasks for this entire test 47 : //----------------------------------------------------------------------------- 48 : 49 : TEST_LIST = { 50 : {"test_multiply", test_multiply}, 51 : // no brutal test needed 52 : {NULL, NULL} 53 : };