From 33ceeca31544839f773161e64319b7c9d97f84ad Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 30 Jan 2011 13:28:19 +0100 Subject: [PATCH] test/t_str-list.c: test export. --- test/t_str-list.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/t_str-list.c b/test/t_str-list.c index 4cff082..9262d34 100644 --- a/test/t_str-list.c +++ b/test/t_str-list.c @@ -140,6 +140,31 @@ void test_lookup() { str_list_destroy(l); } +void test_export() { + + int i = 0; + char **export; + struct str_list *l = str_list_create(); + + export = str_list_export(l); + assert(export && *export == NULL); + free(export); + + str_list_insert(l, "a"); + str_list_insert(l, "b"); + str_list_insert(l, "c"); + + export = str_list_export(l); + + for(i=0; export[i]; i++); + + assert(i == 3); + free(export); + + str_list_clear_fn(l, NULL); + str_list_destroy(l); +} + int main() { test_insert(); @@ -150,6 +175,7 @@ int main() { test_foreach(); test_has(); test_lookup(); + test_export(); return 0; }