aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wmem/wmem_test.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2013-06-18 21:42:54 +0000
committerEvan Huus <eapache@gmail.com>2013-06-18 21:42:54 +0000
commit8ec8f94db7b556bacf70b05e71c007c8cc0b3d11 (patch)
tree46317bac7dbce71c521a639cc4f49b08a3c95ec4 /epan/wmem/wmem_test.c
parentd487bba75f4719eff8edc5a946596ecb14c28fa2 (diff)
downloadwireshark-8ec8f94db7b556bacf70b05e71c007c8cc0b3d11.tar.gz
wireshark-8ec8f94db7b556bacf70b05e71c007c8cc0b3d11.tar.bz2
wireshark-8ec8f94db7b556bacf70b05e71c007c8cc0b3d11.zip
Resurrect wmem_memdup in its own misc. utilities group. Emem provides it, so we
need to provide an analogue at least for now. svn path=/trunk/; revision=50018
Diffstat (limited to 'epan/wmem/wmem_test.c')
-rw-r--r--epan/wmem/wmem_test.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/epan/wmem/wmem_test.c b/epan/wmem/wmem_test.c
index d0c1177947..04d547e260 100644
--- a/epan/wmem/wmem_test.c
+++ b/epan/wmem/wmem_test.c
@@ -357,6 +357,30 @@ wmem_test_allocator_strict(void)
/* UTILITY TESTING FUNCTIONS (/wmem/utils/) */
static void
+wmem_test_miscutls(void)
+{
+ wmem_allocator_t *allocator;
+ const char *source = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ char *ret;
+
+ allocator = wmem_allocator_force_new(WMEM_ALLOCATOR_STRICT);
+
+ ret = (char*) wmem_memdup(allocator, source, 5);
+ ret[4] = '\0';
+ g_assert_cmpstr(ret, ==, "ABCD");
+
+ ret = (char*) wmem_memdup(allocator, source, 1);
+ g_assert(ret[0] == 'A');
+ wmem_strict_check_canaries(allocator);
+
+ ret = (char*) wmem_memdup(allocator, source, 10);
+ ret[9] = '\0';
+ g_assert_cmpstr(ret, ==, "ABCDEFGHI");
+
+ wmem_destroy_allocator(allocator);
+}
+
+static void
wmem_test_strutls(void)
{
wmem_allocator_t *allocator;
@@ -751,6 +775,7 @@ main(int argc, char **argv)
g_test_add_func("/wmem/allocator/times", wmem_time_allocators);
g_test_add_func("/wmem/allocator/callbacks", wmem_test_allocator_callbacks);
+ g_test_add_func("/wmem/utils/misc", wmem_test_miscutls);
g_test_add_func("/wmem/utils/strings", wmem_test_strutls);
g_test_add_func("/wmem/datastruct/slist", wmem_test_slist);