MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_RGMatrix_simple_set

Function test_RGMatrix_simple_set

tests/unit/test_rg_matrix.c:227–308  ·  view source on GitHub ↗

setting an empty entry M[i,j] = 1

Source from the content-addressed store, hash-verified

225// setting an empty entry
226// M[i,j] = 1
227void test_RGMatrix_simple_set() {
228 GrB_Type t = GrB_UINT64;
229 RG_Matrix A = NULL;
230 GrB_Matrix M = NULL;
231 GrB_Matrix DP = NULL;
232 GrB_Matrix DM = NULL;
233 GrB_Info info = GrB_SUCCESS;
234 GrB_Index nvals = 0;
235 GrB_Index nrows = 100;
236 GrB_Index ncols = 100;
237 GrB_Index i = 0;
238 GrB_Index j = 1;
239 uint64_t x = 1;
240
241 info = RG_Matrix_new(&A, t, nrows, ncols);
242 TEST_ASSERT(info == GrB_SUCCESS);
243
244 //--------------------------------------------------------------------------
245 // set element at position i,j
246 //--------------------------------------------------------------------------
247
248 info = RG_Matrix_setElement_UINT64(A, x, i, j);
249 TEST_ASSERT(info == GrB_SUCCESS);
250
251 // make sure element at position i,j exists
252 info = RG_Matrix_extractElement_UINT64(&x, A, i, j);
253 TEST_ASSERT(info == GrB_SUCCESS);
254 TEST_ASSERT(x == 1);
255
256 // matrix should contain a single element
257 RG_Matrix_nvals(&nvals, A);
258 TEST_ASSERT(nvals == 1);
259
260 // matrix should be mark as dirty
261 TEST_ASSERT(RG_Matrix_isDirty(A));
262
263 // get internal matrices
264 M = RG_MATRIX_M(A);
265 DP = RG_MATRIX_DELTA_PLUS(A);
266 DM = RG_MATRIX_DELTA_MINUS(A);
267
268 //--------------------------------------------------------------------------
269 // validations
270 //--------------------------------------------------------------------------
271
272 // M should be empty
273 M_EMPTY();
274
275 // DM should be empty
276 DM_EMPTY();
277
278 // DP should contain a single element
279 DP_NOT_EMPTY();
280
281 //--------------------------------------------------------------------------
282 // set already existing entry
283 //--------------------------------------------------------------------------
284

Callers

nothing calls this directly

Calls 7

RG_Matrix_newFunction · 0.85
RG_Matrix_nvalsFunction · 0.85
RG_Matrix_isDirtyFunction · 0.85
RG_Matrix_waitFunction · 0.85
RG_Matrix_freeFunction · 0.85

Tested by

no test coverage detected