summaryrefslogtreecommitdiff
path: root/tests/unittests.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests.c')
-rw-r--r--tests/unittests.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/unittests.c b/tests/unittests.c
index 0ba5b33..e754b1d 100644
--- a/tests/unittests.c
+++ b/tests/unittests.c
@@ -60,6 +60,7 @@
} while (0)
+
#define MAX_STRINGS 128
static Dynstr *strings[MAX_STRINGS];
static int num_strings;
@@ -304,6 +305,10 @@ static int test_creates_from_constant_cstring(void)
FAIL_UNLESS_EQUAL(size, strlen(bytes));
FAIL_UNLESS_EQUAL(memcmp(bytes, newbytes, strlen(bytes)), 0);
+ /* Creating a dynstr from a supposedly constant C string should
+ make the dynstr re-use the C string's memory area. Thus,
+ if we modify the C string (even though we should not), the
+ dynstr should also change. */
bytes[0] = 'x';
dynstr_memcpy(newbytes, dynstr, 0, strlen(bytes));
FAIL_UNLESS_EQUAL(memcmp(bytes, newbytes, strlen(bytes)), 0);