diff options
author | Sahana Prasad <sahana@redhat.com> | 2020-01-10 17:43:08 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2020-01-23 09:19:07 +0100 |
commit | 10d27a0d42b51776900dba9c2f386b4b0d0d4e39 (patch) | |
tree | 46a958a048b436d84db052892cffefdafe18c186 /tests/unittests | |
parent | 240bf3236a15f2bfb2d3013635588cae1836057b (diff) | |
download | libssh-10d27a0d42b51776900dba9c2f386b4b0d0d4e39.tar.gz libssh-10d27a0d42b51776900dba9c2f386b4b0d0d4e39.tar.xz libssh-10d27a0d42b51776900dba9c2f386b4b0d0d4e39.zip |
unittests: Extends testcases for ssh_strreplace().
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/torture_misc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unittests/torture_misc.c b/tests/unittests/torture_misc.c index 0f9b0def..2d2d6860 100644 --- a/tests/unittests/torture_misc.c +++ b/tests/unittests/torture_misc.c @@ -702,6 +702,25 @@ static void torture_ssh_strreplace(void **state) replaced_string = ssh_strreplace(test_string3, "test", "an"); assert_string_equal(replaced_string, "this;an;is;a"); free(replaced_string); + + /* pattern not found in teststring */ + replaced_string = ssh_strreplace(test_string1, "banana", "an"); + assert_string_equal(replaced_string, test_string1); + free(replaced_string); + + /* pattern is NULL */ + replaced_string = ssh_strreplace(test_string1, NULL , "an"); + assert_string_equal(replaced_string, test_string1); + free(replaced_string); + + /* replacement is NULL */ + replaced_string = ssh_strreplace(test_string1, "test", NULL); + assert_string_equal(replaced_string, test_string1); + free(replaced_string); + + /* src is NULL */ + replaced_string = ssh_strreplace(NULL, "test", "kiwi"); + assert_null(replaced_string); } int torture_run_tests(void) { |