test/utils_tests.c

changeset 222
e0f850709a5c
parent 192
1e51558b9d09
child 223
e18884bbad48
equal deleted inserted replaced
221:ebfc6a2902f7 222:e0f850709a5c
100 ucx_buffer_write("01234567", 1, 8, b1); 100 ucx_buffer_write("01234567", 1, 8, b1);
101 ucx_buffer_write("abcdefgh", 1, 8, b1); 101 ucx_buffer_write("abcdefgh", 1, 8, b1);
102 UCX_TEST_ASSERT(b1->size == 16, "failed to fill buffer b1"); 102 UCX_TEST_ASSERT(b1->size == 16, "failed to fill buffer b1");
103 ucx_buffer_seek(b1, 0, SEEK_SET); 103 ucx_buffer_seek(b1, 0, SEEK_SET);
104 104
105 size_t ncp = ucx_stream_hcopy(b1, b2, ucx_buffer_read, ucx_buffer_write); 105 char copybuf[256];
106 size_t ncp = ucx_stream_bcopy(b1, b2, ucx_buffer_read, ucx_buffer_write,
107 copybuf, sizeof(copybuf));
106 UCX_TEST_ASSERT(ncp == 16, "wrong number of copied bytes"); 108 UCX_TEST_ASSERT(ncp == 16, "wrong number of copied bytes");
107 UCX_TEST_ASSERT(b2->size == 16, "b2 has wrong size"); 109 UCX_TEST_ASSERT(b2->size == 16, "b2 has wrong size");
108 UCX_TEST_ASSERT(memcmp(b1->space, b2->space, 16) == 0, 110 UCX_TEST_ASSERT(memcmp(b1->space, b2->space, 16) == 0,
109 "b1 and b2 have not the same content"); 111 "b1 and b2 have not the same content");
110 112
114 ucx_buffer_seek(b1, 0, SEEK_SET); 116 ucx_buffer_seek(b1, 0, SEEK_SET);
115 117
116 FILE *file = tmpfile(); 118 FILE *file = tmpfile();
117 UCX_TEST_ASSERT(file, "test file cannot be opened, test aborted"); 119 UCX_TEST_ASSERT(file, "test file cannot be opened, test aborted");
118 120
119 ncp = ucx_stream_hcopy(b1, file, ucx_buffer_read, fwrite); 121 ncp = ucx_stream_copy(b1, file, ucx_buffer_read, fwrite);
120 UCX_TEST_ASSERT(ncp == 16, "copied wrong number of bytes to file"); 122 UCX_TEST_ASSERT(ncp == 16, "copied wrong number of bytes to file");
121 123
122 fseek(file, 0, SEEK_SET); 124 fseek(file, 0, SEEK_SET);
123 125
124 ncp = ucx_stream_hcopy(file, b2, fread, ucx_buffer_write); 126 ncp = ucx_stream_copy(file, b2, fread, ucx_buffer_write);
125 UCX_TEST_ASSERT(ncp == 16, "copied wrong number of bytes from file"); 127 UCX_TEST_ASSERT(ncp == 16, "copied wrong number of bytes from file");
126 128
127 UCX_TEST_ASSERT(memcmp(b1->space, b2->space, 16) == 0, 129 UCX_TEST_ASSERT(memcmp(b1->space, b2->space, 16) == 0,
128 "b1 and b2 content mismatch"); 130 "b1 and b2 content mismatch");
129 131

mercurial