From 10d27a0d42b51776900dba9c2f386b4b0d0d4e39 Mon Sep 17 00:00:00 2001 From: Sahana Prasad Date: Fri, 10 Jan 2020 17:43:08 +0100 Subject: [PATCH] unittests: Extends testcases for ssh_strreplace(). Signed-off-by: Sahana Prasad Reviewed-by: Andreas Schneider Reviewed-by: Jakub Jelen --- tests/unittests/torture_misc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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) {