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

Function test_RGMatrix_export_pending_changes

tests/unit/test_rg_matrix.c:1227–1294  ·  view source on GitHub ↗

test exporting RG_Matrix to GrB_Matrix when there are pending changes by exporting the matrix after making changes then flush the matrix and compare the internal matrix to the exported matrix

Source from the content-addressed store, hash-verified

1225// by exporting the matrix after making changes
1226// then flush the matrix and compare the internal matrix to the exported matrix
1227void test_RGMatrix_export_pending_changes() {
1228 GrB_Type t = GrB_BOOL;
1229 RG_Matrix A = NULL;
1230 GrB_Matrix M = NULL;
1231 GrB_Matrix N = NULL; // exported matrix
1232 GrB_Info info = GrB_SUCCESS;
1233 GrB_Index nrows = 100;
1234 GrB_Index ncols = 100;
1235 bool sync = false;
1236
1237 info = RG_Matrix_new(&A, t, nrows, ncols);
1238 TEST_ASSERT(info == GrB_SUCCESS);
1239
1240 // get internal matrices
1241 M = RG_MATRIX_M(A);
1242
1243 // set elements
1244 info = RG_Matrix_setElement_BOOL(A, 0, 0);
1245 TEST_ASSERT(info == GrB_SUCCESS);
1246 info = RG_Matrix_setElement_BOOL(A, 1, 1);
1247 TEST_ASSERT(info == GrB_SUCCESS);
1248
1249 //--------------------------------------------------------------------------
1250 // flush matrix, sync
1251 //--------------------------------------------------------------------------
1252
1253 // wait, force sync
1254 sync = true;
1255 RG_Matrix_wait(A, sync);
1256
1257 //--------------------------------------------------------------------------
1258 // set pending changes
1259 //--------------------------------------------------------------------------
1260
1261 // remove element at position 0,0
1262 info = RG_Matrix_removeElement_BOOL(A, 0, 0);
1263 TEST_ASSERT(info == GrB_SUCCESS);
1264
1265 // set element at position 2,2
1266 info = RG_Matrix_setElement_BOOL(A, 2, 2);
1267 TEST_ASSERT(info == GrB_SUCCESS);
1268
1269 //--------------------------------------------------------------------------
1270 // export matrix
1271 //--------------------------------------------------------------------------
1272
1273 info = RG_Matrix_export(&N, A);
1274 TEST_ASSERT(info == GrB_SUCCESS);
1275
1276 //--------------------------------------------------------------------------
1277 // flush matrix, sync
1278 //--------------------------------------------------------------------------
1279
1280 // wait, force sync
1281 sync = true;
1282 RG_Matrix_wait(A, sync);
1283
1284 //--------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 8

RG_Matrix_newFunction · 0.85
RG_Matrix_waitFunction · 0.85
RG_Matrix_exportFunction · 0.85
ASSERT_GrB_Matrices_EQFunction · 0.85
GrB_Matrix_freeFunction · 0.85
RG_Matrix_freeFunction · 0.85

Tested by

no test coverage detected