1function test104 2%TEST104 export/import 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7rng ('default') 8fprintf ('\ntest104: export/import tests\n') ; 9 10for m = [0 1 5 100] 11 for n = [0 1 5 100] 12 if (n == 1) 13 fmts = [-9:-1 1:9] ; 14 else 15 fmts = [1:9] ; 16 end 17 for d = [0 0.1 0.5 inf] 18 A = GB_spec_random (m, n, d) ; 19 nz = nnz (A.pattern) ; 20 is_sparse = (nz < m*n) ; 21 fprintf ('.') ; 22 for fmt_matrix = fmts 23 for fmt_export = 0:11 24 try 25 C = GB_mex_export_import (A, fmt_matrix, fmt_export) ; 26 GB_spec_compare (C, A) ; 27 catch me 28 % should fail if A is sparse and it is attempted to 29 % be exported as full 30 ok = is_sparse && ... 31 (fmt_export == 6 || fmt_export == 7 || ... 32 fmt_export == -6 || fmt_export == -7) ; 33 if (~ok) 34 % this should not have failed 35 me 36 me.message 37 assert (false) ; 38 end 39 end 40 end 41 end 42 end 43 end 44end 45 46fprintf ('\ntest104: all tests passed\n') ; 47