summaryrefslogtreecommitdiff
path: root/unittests.c
diff options
context:
space:
mode:
Diffstat (limited to 'unittests.c')
-rw-r--r--unittests.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/unittests.c b/unittests.c
index fc6b663..61a59bb 100644
--- a/unittests.c
+++ b/unittests.c
@@ -515,6 +515,21 @@ static int test_copies_partial_substring_when_length_too_big(void)
}
+static int test_strdup_duplicates_string(void)
+{
+ Dynstr *dynstr;
+ char *cstring;
+ char data[] = "hello, world";
+
+ dynstr = dynstr_new_from_constant_cstring(data);
+ cstring = dynstr_strdup(dynstr);
+ FAIL_UNLESS_EQUAL(memcmp(data, cstring, sizeof(data)), 0);
+ free(cstring);
+ dynstr_free(dynstr);
+ return true;
+}
+
+
static int test_cats_ok(void)
{
Dynstr *a;
@@ -1233,6 +1248,7 @@ static const struct test tests[] = {
TEST(test_memcpy_truncates_if_copying_too_much),
TEST(test_memcpy_copies_whole_string_ok),
TEST(test_memcpy_copies_substring_ok),
+ TEST(test_strdup_duplicates_string),
TEST(test_copies_empty_substring_ok),
TEST(test_copies_single_byte_substring_ok),
TEST(test_copies_middle_substring_ok),