From 06b6f457d9017289ae48a05816fe34e7e1828e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 13 Aug 2022 14:38:08 +0200 Subject: [PATCH] tests: add tests on dynamic string functions with NULL string --- tests/unit/core/test-core-string.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp index 5639d2aae..341f91457 100644 --- a/tests/unit/core/test-core-string.cpp +++ b/tests/unit/core/test-core-string.cpp @@ -2465,4 +2465,23 @@ TEST(CoreString, Dyn) STRCMP_EQUAL("abcdxxyxyz", str_ptr); free (str_ptr); + + str_ptr = NULL; + str = &str_ptr; + + /* test copy to NULL */ + LONGS_EQUAL(0, string_dyn_copy (NULL, NULL)); + LONGS_EQUAL(0, string_dyn_copy (NULL, "a")); + LONGS_EQUAL(0, string_dyn_copy (str, NULL)); + LONGS_EQUAL(0, string_dyn_copy (str, "a")); + + /* test concat to NULL */ + LONGS_EQUAL(0, string_dyn_concat (NULL, NULL, 1)); + LONGS_EQUAL(0, string_dyn_concat (NULL, "a", 1)); + LONGS_EQUAL(0, string_dyn_concat (str, NULL, 1)); + LONGS_EQUAL(0, string_dyn_concat (str, "a", 1)); + + /* test free of NULL */ + string_dyn_free (NULL, 0); + string_dyn_free (str, 0); }