| 1522 CX_TEST_ASSERT(buf.size == 12); |
1522 CX_TEST_ASSERT(buf.size == 12); |
| 1523 CX_TEST_ASSERT(target.pos == 12); |
1523 CX_TEST_ASSERT(target.pos == 12); |
| 1524 CX_TEST_ASSERT(target.size == 12); |
1524 CX_TEST_ASSERT(target.size == 12); |
| 1525 CX_TEST_ASSERT(0 == memcmp(buf.space, "eststrin1234", 12)); |
1525 CX_TEST_ASSERT(0 == memcmp(buf.space, "eststrin1234", 12)); |
| 1526 CX_TEST_ASSERT(0 == memcmp(target.space, "preparationt", 12)); |
1526 CX_TEST_ASSERT(0 == memcmp(target.space, "preparationt", 12)); |
| |
1527 } |
| |
1528 cxBufferDestroy(&buf); |
| |
1529 cxBufferDestroy(&target); |
| |
1530 } |
| |
1531 |
| |
1532 CX_TEST(test_buffer_write_large_data_flush_target_full) { |
| |
1533 CxBuffer buf, target; |
| |
1534 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
| |
1535 cxBufferInit(&buf, NULL, 8, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
| |
1536 // simulate that the target is full: |
| |
1537 target.pos = target.size = 16; |
| |
1538 CX_TEST_DO { |
| |
1539 CxBufferFlushConfig flush; |
| |
1540 flush.threshold = 0; |
| |
1541 flush.blksize = 32; |
| |
1542 flush.blkmax = 1; |
| |
1543 flush.target = ⌖ |
| |
1544 flush.wfunc = cxBufferWriteFunc; |
| |
1545 CX_TEST_ASSERT(0 == cxBufferEnableFlushing(&buf, flush)); |
| |
1546 // write more bytes than the buffer can take, but the target is full |
| |
1547 size_t written = cxBufferWrite("foobarfoobar", 1, 12, &buf); |
| |
1548 CX_TEST_ASSERT(written == 0); |
| |
1549 CX_TEST_ASSERT(buf.pos == 0); |
| |
1550 CX_TEST_ASSERT(buf.size == 0); |
| |
1551 CX_TEST_ASSERT(target.pos == 16); |
| |
1552 CX_TEST_ASSERT(target.size == 16); |
| 1527 } |
1553 } |
| 1528 cxBufferDestroy(&buf); |
1554 cxBufferDestroy(&buf); |
| 1529 cxBufferDestroy(&target); |
1555 cxBufferDestroy(&target); |
| 1530 } |
1556 } |
| 1531 |
1557 |
| 1832 cx_test_register(suite, test_buffer_write_flush_rate_limited_and_buffer_too_small); |
1858 cx_test_register(suite, test_buffer_write_flush_rate_limited_and_buffer_too_small); |
| 1833 cx_test_register(suite, test_buffer_write_flush_multibyte); |
1859 cx_test_register(suite, test_buffer_write_flush_multibyte); |
| 1834 cx_test_register(suite, test_buffer_write_flush_misaligned); |
1860 cx_test_register(suite, test_buffer_write_flush_misaligned); |
| 1835 cx_test_register(suite, test_buffer_write_flush_target_full); |
1861 cx_test_register(suite, test_buffer_write_flush_target_full); |
| 1836 cx_test_register(suite, test_buffer_write_flush_multibyte_target_full); |
1862 cx_test_register(suite, test_buffer_write_flush_multibyte_target_full); |
| |
1863 cx_test_register(suite, test_buffer_write_large_data_flush_target_full); |
| 1837 cx_test_register(suite, test_buffer_pop); |
1864 cx_test_register(suite, test_buffer_pop); |
| 1838 cx_test_register(suite, test_buffer_flush); |
1865 cx_test_register(suite, test_buffer_flush); |
| 1839 cx_test_register(suite, test_buffer_get); |
1866 cx_test_register(suite, test_buffer_get); |
| 1840 cx_test_register(suite, test_buffer_get_eof); |
1867 cx_test_register(suite, test_buffer_get_eof); |
| 1841 cx_test_register(suite, test_buffer_read); |
1868 cx_test_register(suite, test_buffer_read); |