]> jfr.im git - irc/weechat/weechat.git/commitdiff
tests: add tests on dynamic string functions with NULL string
authorSébastien Helleu <redacted>
Sat, 13 Aug 2022 12:38:08 +0000 (14:38 +0200)
committerSébastien Helleu <redacted>
Sat, 13 Aug 2022 12:38:08 +0000 (14:38 +0200)
tests/unit/core/test-core-string.cpp

index 5639d2aae67fd8f58414066c2e89e3ab9569ea02..341f9145750d343bfb8701c8a612fdad96352f5c 100644 (file)
@@ -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);
 }