test/buffer_tests.c

changeset 219
2df780a4482b
parent 218
b20d6088795c
child 225
a1a068c2c4ef
equal deleted inserted replaced
218:b20d6088795c 219:2df780a4482b
379 UCX_TEST_ASSERT(r == 11, "returned incorrect number of written bytes"); 379 UCX_TEST_ASSERT(r == 11, "returned incorrect number of written bytes");
380 UCX_TEST_ASSERT(b->pos == 15, "incorrect position"); 380 UCX_TEST_ASSERT(b->pos == 15, "incorrect position");
381 UCX_TEST_ASSERT(memcmp(buffer, " test string7\0\0", 18) == 0, 381 UCX_TEST_ASSERT(memcmp(buffer, " test string7\0\0", 18) == 0,
382 "incorrect buffer content (test string)"); 382 "incorrect buffer content (test string)");
383 383
384 r = ucx_buffer_write(".", 1, 1, b);
385 UCX_TEST_ASSERT(r == 1, "returned incorrect number of written elements");
386 UCX_TEST_ASSERT(b->pos == 16, "incorrect position");
387
384 int32_t testarr[4] = {0x09abcdef, 0x05fedcba, 0x01abefcd, 0x3cd07ab}; 388 int32_t testarr[4] = {0x09abcdef, 0x05fedcba, 0x01abefcd, 0x3cd07ab};
385 r = ucx_buffer_write(testarr, 4, 4, b); 389 r = ucx_buffer_write(testarr, 4, 4, b);
386 UCX_TEST_ASSERT(r = 4, "returned incorrect number of written elements"); 390 UCX_TEST_ASSERT(r = 4, "returned incorrect number of written elements");
387 UCX_TEST_ASSERT(b->pos == 31, "incorrect position"); 391 UCX_TEST_ASSERT(b->pos == 32, "incorrect position");
388 392
389 char cmp[32]; 393 char cmp[32];
390 memset(cmp, 0, 32); 394 memset(cmp, 0, 32);
391 memcpy(cmp, " test string", 15); 395 memcpy(cmp, " test string.", 16);
392 int32_t *ptr = (int32_t*) (cmp+15); 396 int32_t *ptr = (int32_t*) (cmp+16);
393 ptr[0] = testarr[0]; 397 ptr[0] = testarr[0];
394 ptr[1] = testarr[1]; 398 ptr[1] = testarr[1];
395 ptr[2] = testarr[2]; 399 ptr[2] = testarr[2];
396 ptr[3] = testarr[3]; 400 ptr[3] = testarr[3];
397 UCX_TEST_ASSERT(memcmp(buffer, cmp, 32) == 0, 401 UCX_TEST_ASSERT(memcmp(buffer, cmp, 32) == 0,

mercurial