diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-05-13 16:49:34 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-05-14 05:56:58 +1000 |
commit | a89bee4c98819567c6e15c0cae32372e32e118f5 (patch) | |
tree | ac92b6ff91a4601526047f574b3bc743a4fb4f11 /lib/util/tests | |
parent | a13ba4347f92afc63497991210bc59e6bd2434d0 (diff) | |
download | samba-a89bee4c98819567c6e15c0cae32372e32e118f5.tar.gz samba-a89bee4c98819567c6e15c0cae32372e32e118f5.tar.bz2 samba-a89bee4c98819567c6e15c0cae32372e32e118f5.zip |
Add new functions and tests: str_list_make_empty(), str_list_make_single()
Diffstat (limited to 'lib/util/tests')
-rw-r--r-- | lib/util/tests/strlist.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/util/tests/strlist.c b/lib/util/tests/strlist.c index 8605102954..3f6cf2714b 100644 --- a/lib/util/tests/strlist.c +++ b/lib/util/tests/strlist.c @@ -87,6 +87,38 @@ static bool test_list_copy(struct torture_context *tctx) return true; } +static bool test_list_make_empty(struct torture_context *tctx) +{ + char **result; + + result = str_list_make_empty(tctx); + torture_assert(tctx, result, "str_list_make_empty() must not return NULL"); + torture_assert(tctx, result[0] == NULL, "first element in str_list_make_empty() result must be NULL"); + + result = str_list_make(tctx, NULL, NULL); + torture_assert(tctx, result, "str_list_make() must not return NULL"); + torture_assert(tctx, result[0] == NULL, "first element in str_list_make(ctx, NULL, NULL) result must be NULL"); + + result = str_list_make(tctx, "", NULL); + torture_assert(tctx, result, "str_list_make() must not return NULL"); + torture_assert(tctx, result[0] == NULL, "first element in str_list_make(ctx, "", NULL) result must be NULL"); + + return true; +} + +static bool test_list_make_single(struct torture_context *tctx) +{ + char **result; + + result = str_list_make_single(tctx, "foo"); + + torture_assert(tctx, result, "str_list_make_single() must not return NULL"); + torture_assert_str_equal(tctx, result[0], "foo", "element 0"); + torture_assert(tctx, result[1] == NULL, "second element in result must be NULL"); + + return true; +} + struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "STRLIST"); @@ -98,6 +130,8 @@ struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) } torture_suite_add_simple_test(suite, "list_copy", test_list_copy); + torture_suite_add_simple_test(suite, "make_empty", test_list_make_empty); + torture_suite_add_simple_test(suite, "make_single", test_list_make_single); return suite; } |