[S] Change in openvpn[master]: test_buffer: Add test for buf_null_terminate
"cron2 (Code Review)" <[email protected]>
| Newsgroups | gmane.network.openvpn.devel |
|---|---|
| Message-ID | <0977e46887b56189e7a5ed47bae2a1e6e6d0411e-EmailReplacePatchSet-HTML@gerrit.openvpn.net> |
cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1580?usp=email ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: test_buffer: Add test for buf_null_terminate ...................................................................... test_buffer: Add test for buf_null_terminate Change-Id: I01683153a68e1809a4d7ab455eb346f53780e219 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1580 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg36532.html Signed-off-by: Gert Doering <[email protected]> --- M tests/unit_tests/openvpn/test_buffer.c 1 file changed, 27 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/80/1580/2 diff --git a/tests/unit_tests/openvpn/test_buffer.c b/tests/unit_tests/openvpn/test_buffer.c index 5f43e0d..326de40 100644 --- a/tests/unit_tests/openvpn/test_buffer.c +++ b/tests/unit_tests/openvpn/test_buffer.c @@ -460,6 +460,32 @@ gc_free(&gc); } +void +test_buffer_null_terminate(void **state) +{ + struct gc_arena gc = gc_new(); + + struct buffer buf = alloc_buf_gc(5, &gc); + const char test1[] = "1234"; + const char test2[] = "12345"; + assert_true(buf_write(&buf, test1, sizeof(test1))); + assert_string_equal(BSTR(&buf), "1234"); + buf_null_terminate(&buf); + assert_string_equal(BSTR(&buf), "1234"); + + assert_true(buf_inc_len(&buf, -1)); + assert_true(buf_write_u8(&buf, '5')); + assert_memory_equal(BPTR(&buf), test2, strlen(test2)); + buf_null_terminate(&buf); + assert_string_equal(BSTR(&buf), "1234"); + + struct buffer buf2; + CLEAR(buf2); + buf_null_terminate(&buf2); + + gc_free(&gc); +} + /* for building long texts */ #define A_TIMES_256 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAO" @@ -540,6 +566,7 @@ cmocka_unit_test(test_snprintf), cmocka_unit_test(test_checked_snprintf), cmocka_unit_test(test_buffer_chomp), + cmocka_unit_test(test_buffer_null_terminate), cmocka_unit_test(test_buffer_parse) }; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1580?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I01683153a68e1809a4d7ab455eb346f53780e219 Gerrit-Change-Number: 1580 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld <[email protected]> Gerrit-Reviewer: cron2 <[email protected]> Gerrit-Reviewer: plaisthos <[email protected]> Gerrit-CC: openvpn-devel <[email protected]> _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel