summaryrefslogtreecommitdiffstats
path: root/src/test/test-string-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test-string-util.c')
-rw-r--r--src/test/test-string-util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c
index 92f1083a4c..3b003e885f 100644
--- a/src/test/test-string-util.c
+++ b/src/test/test-string-util.c
@@ -88,6 +88,35 @@ TEST(free_and_strndup) {
}
}
+TEST(strdup_to_full) {
+ _cleanup_free_ char *dst;
+
+ assert_se(strdup_to_full(NULL, NULL) == 0);
+ assert_se(strdup_to_full(&dst, NULL) == 0);
+
+ assert_se(strdup_to_full(NULL, "") == 1);
+ assert_se(strdup_to_full(&dst, "") == 1);
+ assert_se(streq_ptr(dst, ""));
+ dst = mfree(dst);
+
+ assert_se(strdup_to_full(NULL, "x") == 1);
+ assert_se(strdup_to_full(&dst, "x") == 1);
+ assert_se(streq_ptr(dst, "x"));
+}
+
+TEST(strdup_to) {
+ _cleanup_free_ char *dst;
+
+ assert_se(strdup_to(&dst, NULL) == 0);
+
+ assert_se(strdup_to(&dst, "") == 0);
+ assert_se(streq_ptr(dst, ""));
+ dst = mfree(dst);
+
+ assert_se(strdup_to(&dst, "x") == 0);
+ assert_se(streq_ptr(dst, "x"));
+}
+
TEST(ascii_strcasecmp_n) {
assert_se(ascii_strcasecmp_n("", "", 0) == 0);
assert_se(ascii_strcasecmp_n("", "", 1) == 0);