| 1580 CX_TEST_ASSERT(0 == memcmp(buf.space, "ar12345678ABCDEF", 16)); |
1580 CX_TEST_ASSERT(0 == memcmp(buf.space, "ar12345678ABCDEF", 16)); |
| 1581 CX_TEST_ASSERT(0 == memcmp(target.space, "prepfoob", 8)); |
1581 CX_TEST_ASSERT(0 == memcmp(target.space, "prepfoob", 8)); |
| 1582 } |
1582 } |
| 1583 cxBufferDestroy(&buf); |
1583 cxBufferDestroy(&buf); |
| 1584 cxBufferDestroy(&target); |
1584 cxBufferDestroy(&target); |
| |
1585 } |
| |
1586 |
| |
1587 CX_TEST(test_buffer_pop) { |
| |
1588 CxBuffer buf; |
| |
1589 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); |
| |
1590 cxBufferPutString(&buf, "teststring"); |
| |
1591 CX_TEST_DO { |
| |
1592 CX_TEST_ASSERT(buf.pos == 10); |
| |
1593 CX_TEST_ASSERT(buf.size == 10); |
| |
1594 CX_TEST_ASSERT(cxBufferPop(&buf, 1, 3) == 3); |
| |
1595 CX_TEST_ASSERT(buf.pos == 7); |
| |
1596 CX_TEST_ASSERT(buf.size == 7); |
| |
1597 CX_TEST_ASSERT(cxBufferPop(&buf, 2, 2) == 2); |
| |
1598 CX_TEST_ASSERT(buf.pos == 3); |
| |
1599 CX_TEST_ASSERT(buf.size == 3); |
| |
1600 cxBufferPutString(&buf, "1234"); |
| |
1601 CX_TEST_ASSERT(buf.pos == 7); |
| |
1602 CX_TEST_ASSERT(buf.size == 7); |
| |
1603 buf.pos = 3; |
| |
1604 CX_TEST_ASSERT(cxBufferPop(&buf, 2, 1) == 1); |
| |
1605 CX_TEST_ASSERT(buf.pos == 3); |
| |
1606 CX_TEST_ASSERT(buf.size == 5); |
| |
1607 CX_TEST_ASSERT(cxBufferPop(&buf, 1, 3) == 3); |
| |
1608 CX_TEST_ASSERT(buf.pos == 2); |
| |
1609 CX_TEST_ASSERT(buf.size == 2); |
| |
1610 cxBufferPut(&buf, 'c'); |
| |
1611 CX_TEST_ASSERT(buf.pos == 3); |
| |
1612 CX_TEST_ASSERT(buf.size == 3); |
| |
1613 CX_TEST_ASSERT(cxBufferPop(&buf, 2, 2) == 1); |
| |
1614 CX_TEST_ASSERT(buf.pos == 1); |
| |
1615 CX_TEST_ASSERT(buf.size == 1); |
| |
1616 CX_TEST_ASSERT(cxBufferPop(&buf, 1, 3) == 1); |
| |
1617 CX_TEST_ASSERT(buf.pos == 0); |
| |
1618 CX_TEST_ASSERT(buf.size == 0); |
| |
1619 } |
| |
1620 cxBufferDestroy(&buf); |
| 1585 } |
1621 } |
| 1586 |
1622 |
| 1587 CX_TEST(test_buffer_flush) { |
1623 CX_TEST(test_buffer_flush) { |
| 1588 CxBuffer buf, target; |
1624 CxBuffer buf, target; |
| 1589 cxBufferInit(&target, NULL, 8, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); |
1625 cxBufferInit(&target, NULL, 8, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); |
| 1796 cx_test_register(suite, test_buffer_write_flush_rate_limited_and_buffer_too_small); |
1832 cx_test_register(suite, test_buffer_write_flush_rate_limited_and_buffer_too_small); |
| 1797 cx_test_register(suite, test_buffer_write_flush_multibyte); |
1833 cx_test_register(suite, test_buffer_write_flush_multibyte); |
| 1798 cx_test_register(suite, test_buffer_write_flush_misaligned); |
1834 cx_test_register(suite, test_buffer_write_flush_misaligned); |
| 1799 cx_test_register(suite, test_buffer_write_flush_target_full); |
1835 cx_test_register(suite, test_buffer_write_flush_target_full); |
| 1800 cx_test_register(suite, test_buffer_write_flush_multibyte_target_full); |
1836 cx_test_register(suite, test_buffer_write_flush_multibyte_target_full); |
| |
1837 cx_test_register(suite, test_buffer_pop); |
| 1801 cx_test_register(suite, test_buffer_flush); |
1838 cx_test_register(suite, test_buffer_flush); |
| 1802 cx_test_register(suite, test_buffer_get); |
1839 cx_test_register(suite, test_buffer_get); |
| 1803 cx_test_register(suite, test_buffer_get_eof); |
1840 cx_test_register(suite, test_buffer_get_eof); |
| 1804 cx_test_register(suite, test_buffer_read); |
1841 cx_test_register(suite, test_buffer_read); |
| 1805 cx_test_register(suite, test_buffer_read_oob); |
1842 cx_test_register(suite, test_buffer_read_oob); |