1function test09b
2%TEST09B test GrB_assign
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7fprintf ('\n-----------duplicate I,J test of GB_mex_assign\n') ;
8
9I = [2 3 2 3 3] ; J = [2 2 4 4 ] ;
10I0 = uint64 (I) ;
11J0 = uint64 (J);
12
13C = sparse (magic (5)) ;
14A = sparse (77 * ones (5,4)) ;
15
16C2 = GB_mex_assign(C, [ ], [ ], A, I0, J0) ;
17
18% check erroneous I and J
19
20fprintf ('testing error handling, errors expected:\n') ;
21A = sparse (1) ;
22try
23    K = uint64 (99) ;
24    GB_mex_assign (C, [], 'plus', A, K, K) ;
25    ok = false ;
26catch me
27    ok = true ;
28end
29assert (ok) ;
30
31
32A = sparse (rand (2)) ;
33try
34    I = uint64 ([0 0]) ;
35    K = uint64 ([99 100]) ;
36    GB_mex_assign (C, [], 'plus', A, I, K) ;
37    ok = false ;
38catch me
39    ok = true ;
40end
41assert (ok) ;
42
43fprintf ('\nAll tests passed (errors expected)\n') ;
44fprintf ('\ntest09b: all tests passed\n') ;
45
46
47