test RGMatrixTupleIter iteration
| 55 | |
| 56 | // test RGMatrixTupleIter iteration |
| 57 | void test_RGMatrixTupleIter_next() { |
| 58 | RG_Matrix A = NULL; |
| 59 | GrB_Type t = GrB_UINT64; |
| 60 | GrB_Info info = GrB_SUCCESS; |
| 61 | GrB_Index i = 1; |
| 62 | GrB_Index j = 2; |
| 63 | GrB_Index row = 0; |
| 64 | GrB_Index col = 0; |
| 65 | GrB_Index nrows = 100; |
| 66 | GrB_Index ncols = 100; |
| 67 | uint64_t val = 0; |
| 68 | bool sync = false; |
| 69 | RG_MatrixTupleIter iter; |
| 70 | memset(&iter, 0, sizeof(RG_MatrixTupleIter)); |
| 71 | |
| 72 | info = RG_Matrix_new(&A, t, nrows, ncols); |
| 73 | TEST_ASSERT(info == GrB_SUCCESS); |
| 74 | |
| 75 | // set element at position i,j |
| 76 | info = RG_Matrix_setElement_UINT64(A, 0, i, j); |
| 77 | TEST_ASSERT(info == GrB_SUCCESS); |
| 78 | |
| 79 | //-------------------------------------------------------------------------- |
| 80 | // flush matrix, sync |
| 81 | //-------------------------------------------------------------------------- |
| 82 | |
| 83 | // wait, force sync |
| 84 | sync = true; |
| 85 | RG_Matrix_wait(A, sync); |
| 86 | |
| 87 | //-------------------------------------------------------------------------- |
| 88 | // set pending changes |
| 89 | //-------------------------------------------------------------------------- |
| 90 | |
| 91 | // remove element at position i,j |
| 92 | info = RG_Matrix_removeElement_UINT64(A, i, j); |
| 93 | TEST_ASSERT(info == GrB_SUCCESS); |
| 94 | |
| 95 | // set element at position i+1,j+1 |
| 96 | info = RG_Matrix_setElement_UINT64(A, 1, i+1, j+1); |
| 97 | TEST_ASSERT(info == GrB_SUCCESS); |
| 98 | |
| 99 | info = RG_MatrixTupleIter_attach(&iter, A); |
| 100 | TEST_ASSERT(RG_MatrixTupleIter_is_attached(&iter, A)); |
| 101 | |
| 102 | info = RG_MatrixTupleIter_next_UINT64(&iter, &row, &col, &val); |
| 103 | TEST_ASSERT(info == GrB_SUCCESS); |
| 104 | |
| 105 | TEST_ASSERT(row == i+1); |
| 106 | TEST_ASSERT(col == j+1); |
| 107 | TEST_ASSERT(val == 1); |
| 108 | |
| 109 | info = RG_MatrixTupleIter_next_UINT64(&iter, &row, &col, &val); |
| 110 | |
| 111 | TEST_ASSERT(info == GxB_EXHAUSTED); |
| 112 | |
| 113 | RG_Matrix_free(&A); |
| 114 | TEST_ASSERT(A == NULL); |
nothing calls this directly
no test coverage detected