784 CX_TEST_ASSERT(written == 3); |
784 CX_TEST_ASSERT(written == 3); |
785 CX_TEST_ASSERT(buf.size == 9); |
785 CX_TEST_ASSERT(buf.size == 9); |
786 CX_TEST_ASSERT(buf.pos == 9); |
786 CX_TEST_ASSERT(buf.pos == 9); |
787 CX_TEST_ASSERT(buf.capacity >= 9); |
787 CX_TEST_ASSERT(buf.capacity >= 9); |
788 CX_TEST_ASSERT(0 == memcmp(buf.space, "pretester", 9)); |
788 CX_TEST_ASSERT(0 == memcmp(buf.space, "pretester", 9)); |
|
789 } |
|
790 cxBufferDestroy(&buf); |
|
791 } |
|
792 |
|
793 CX_TEST(test_buffer_append) { |
|
794 CxBuffer buf; |
|
795 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); |
|
796 memcpy(buf.space, "prepXXXX\0\0\0\0\0\0\0\0", 16); |
|
797 buf.capacity = 8; |
|
798 buf.size = 6; |
|
799 buf.pos = 4; |
|
800 CX_TEST_DO { |
|
801 size_t written = cxBufferAppend("testing", 1, 7, &buf); |
|
802 CX_TEST_ASSERT(written == 7); |
|
803 CX_TEST_ASSERT(buf.size == 13); |
|
804 CX_TEST_ASSERT(buf.pos == 4); |
|
805 CX_TEST_ASSERT(buf.capacity >= 13); |
|
806 CX_TEST_ASSERT(0 == memcmp(buf.space, "prepXXtesting", 13)); |
789 } |
807 } |
790 cxBufferDestroy(&buf); |
808 cxBufferDestroy(&buf); |
791 } |
809 } |
792 |
810 |
793 CX_TEST(test_buffer_put_fit) { |
811 CX_TEST(test_buffer_put_fit) { |
1312 cx_test_register(suite, test_buffer_write_size_one_extend); |
1330 cx_test_register(suite, test_buffer_write_size_one_extend); |
1313 cx_test_register(suite, test_buffer_write_multibyte_fit); |
1331 cx_test_register(suite, test_buffer_write_multibyte_fit); |
1314 cx_test_register(suite, test_buffer_write_multibyte_discard); |
1332 cx_test_register(suite, test_buffer_write_multibyte_discard); |
1315 cx_test_register(suite, test_buffer_write_multibyte_extend); |
1333 cx_test_register(suite, test_buffer_write_multibyte_extend); |
1316 cx_test_register(suite, test_buffer_write_copy_on_write); |
1334 cx_test_register(suite, test_buffer_write_copy_on_write); |
|
1335 cx_test_register(suite, test_buffer_append); |
1317 cx_test_register(suite, test_buffer_put_fit); |
1336 cx_test_register(suite, test_buffer_put_fit); |
1318 cx_test_register(suite, test_buffer_put_discard); |
1337 cx_test_register(suite, test_buffer_put_discard); |
1319 cx_test_register(suite, test_buffer_put_extend); |
1338 cx_test_register(suite, test_buffer_put_extend); |
1320 cx_test_register(suite, test_buffer_put_copy_on_write); |
1339 cx_test_register(suite, test_buffer_put_copy_on_write); |
1321 cx_test_register(suite, test_buffer_put_string_fit); |
1340 cx_test_register(suite, test_buffer_put_string_fit); |