261 CxBuffer buf; |
261 CxBuffer buf; |
262 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
262 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
263 buf.size = 6; |
263 buf.size = 6; |
264 buf.pos = 3; |
264 buf.pos = 3; |
265 CX_TEST_DO { |
265 CX_TEST_DO { |
266 int result = cxBufferSeek(&buf, 6, SEEK_SET); |
266 int result = cxBufferSeek(&buf, 7, SEEK_SET); |
267 CX_TEST_ASSERT(result != 0); |
267 CX_TEST_ASSERT(result != 0); |
268 CX_TEST_ASSERT(buf.pos == 3); |
268 CX_TEST_ASSERT(buf.pos == 3); |
269 } |
269 } |
270 cxBufferDestroy(&buf); |
270 cxBufferDestroy(&buf); |
271 } |
271 } |
313 CxBuffer buf; |
313 CxBuffer buf; |
314 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
314 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
315 buf.size = 6; |
315 buf.size = 6; |
316 buf.pos = 3; |
316 buf.pos = 3; |
317 CX_TEST_DO { |
317 CX_TEST_DO { |
318 int result = cxBufferSeek(&buf, 3, SEEK_CUR); |
318 int result = cxBufferSeek(&buf, 4, SEEK_CUR); |
319 CX_TEST_ASSERT(result != 0); |
319 CX_TEST_ASSERT(result != 0); |
320 CX_TEST_ASSERT(buf.pos == 3); |
320 CX_TEST_ASSERT(buf.pos == 3); |
321 } |
321 } |
322 cxBufferDestroy(&buf); |
322 cxBufferDestroy(&buf); |
323 } |
323 } |
340 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
340 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
341 buf.size = 6; |
341 buf.size = 6; |
342 buf.pos = 3; |
342 buf.pos = 3; |
343 CX_TEST_DO { |
343 CX_TEST_DO { |
344 int result = cxBufferSeek(&buf, 0, SEEK_END); |
344 int result = cxBufferSeek(&buf, 0, SEEK_END); |
345 // the (past-the-)end position is always invalid |
345 CX_TEST_ASSERT(result == 0); |
346 CX_TEST_ASSERT(result != 0); |
346 CX_TEST_ASSERT(buf.pos == 6); |
347 CX_TEST_ASSERT(buf.pos == 3); |
|
348 } |
347 } |
349 cxBufferDestroy(&buf); |
348 cxBufferDestroy(&buf); |
350 } |
349 } |
351 |
350 |
352 CX_TEST(test_buffer_seek_end_valid) { |
351 CX_TEST(test_buffer_seek_end_valid) { |