1 /*
2 IGraph library.
3 Copyright (C) 2021 The igraph development team <igraph@igraph.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19 #include <igraph.h>
20 #include "test_utilities.inc"
21
main()22 int main() {
23 igraph_spmatrix_t spmat;
24 int i;
25 igraph_set_error_handler(igraph_error_handler_ignore);
26
27 printf("0x0 matrix, trying to add nonexistent column\n");
28 igraph_spmatrix_init(&spmat, 0, 0);
29 IGRAPH_ASSERT(igraph_spmatrix_add_col_values(&spmat, /*to*/ 0, /*from*/ 0) == IGRAPH_EINVAL);
30 igraph_spmatrix_destroy(&spmat);
31
32 printf("\n1x1 matrix, adding a column to itself\n");
33 igraph_spmatrix_init(&spmat, 1, 1);
34 igraph_spmatrix_set(&spmat, 0, 0, 5);
35 IGRAPH_ASSERT(igraph_spmatrix_add_col_values(&spmat, /*to*/ 0, /*from*/ 0) == IGRAPH_SUCCESS);
36 print_spmatrix(&spmat);
37 igraph_spmatrix_destroy(&spmat);
38
39 printf("\n5x6 matrix\n");
40 igraph_spmatrix_init(&spmat, 5, 6);
41 for (i = 0; i < 30; i++) {
42 igraph_spmatrix_set(&spmat, i/6, i%6, i);
43 }
44 IGRAPH_ASSERT(igraph_spmatrix_add_col_values(&spmat, /*to*/ 1, /*from*/ 2) == IGRAPH_SUCCESS);
45 print_spmatrix(&spmat);
46 igraph_spmatrix_destroy(&spmat);
47
48 VERIFY_FINALLY_STACK();
49 return 0;
50 }
51