From d3655ee501778d15bcc6dc96cdc712b57544937a Mon Sep 17 00:00:00 2001 From: Brett Nash Date: Mon, 2 Aug 2010 09:44:06 +0000 Subject: [PATCH] Beef up the strncpy test SVN revision: 50740 --- legacy/eina/src/tests/eina_test_ustr.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/legacy/eina/src/tests/eina_test_ustr.c b/legacy/eina/src/tests/eina_test_ustr.c index d069a96d7f..458f8d2a77 100644 --- a/legacy/eina/src/tests/eina_test_ustr.c +++ b/legacy/eina/src/tests/eina_test_ustr.c @@ -114,14 +114,27 @@ START_TEST(eina_unicode_strncpy_test) rv = eina_unicode_strncpy(buf,STR1,1); fail_if(rv != buf); fail_if(buf[1] != '7'); - fail_if(buf[0] != STR1[1]); + fail_if(buf[0] != STR1[0]); buf[9] = '7'; - rv = eina_unicode_strncpy(buf, STR1, 10); + rv = eina_unicode_strncpy(buf, STR4, 10); fail_if(rv != buf); - fail_if(eina_unicode_strcmp(buf,STR1) != 0); + fail_if(eina_unicode_strcmp(buf,STR4) != 0); fail_if(buf[9] != 0); + buf[0] = '7'; + rv = eina_unicode_strncpy(buf, STR1, 0); + fail_if(buf[0] != '7'); + + /* may segfault */ + buf[0] = '7'; + rv = eina_unicode_strncpy(buf, NULL, 0); + fail_if(buf[0] != '7'); + + /* Hopefully won't segfault */ + rv = eina_unicode_strncpy(NULL, STR1, 0); + fail_if(rv != NULL); + eina_shutdown(); } END_TEST