const char *list[5];
};
-struct test_list_element test_lists_strings[] = {
+const struct test_list_element test_lists_strings[] = {
{
.list_as_string = "",
.list = { NULL }
}
};
-struct test_list_element test_lists_shell_strings[] = {
+const struct test_list_element test_lists_shell_strings[] = {
{
.list_as_string = "",
.list = { NULL }
}
};
-static bool test_lists_shell(struct torture_context *tctx,
- const void *data)
+static bool test_lists_shell(struct torture_context *tctx, const void *data)
{
const struct test_list_element *element = data;
- const char **ret1, **ret2, *tmp;
+
+ char **ret1, **ret2, *tmp;
bool match = true;
TALLOC_CTX *mem_ctx = tctx;
ret1 = str_list_make_shell(mem_ctx, element->list_as_string, element->seperators);
torture_assert(tctx, ret1, "str_list_make_shell() must not return NULL");
- tmp = str_list_join_shell(mem_ctx, ret1, element->seperators ? *element->seperators : ' ');
+ tmp = str_list_join_shell(mem_ctx, (const char **) ret1, element->seperators ? *element->seperators : ' ');
ret2 = str_list_make_shell(mem_ctx, tmp, element->seperators);
if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) {
torture_assert(tctx, match, talloc_asprintf(tctx,
"str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", element->list_as_string, tmp));
- torture_assert(tctx, str_list_equal(ret1, element->list),
+ torture_assert(tctx, str_list_equal((const char * const *) ret1,
+ element->list),
talloc_asprintf(tctx,
"str_list_make_shell(%s) failed to create correct list",
element->list_as_string));
static bool test_list_make(struct torture_context *tctx, const void *data)
{
const struct test_list_element *element = data;
+
char **result;
result = str_list_make(tctx, element->list_as_string, element->seperators);
torture_assert(tctx, result, "str_list_make() must not return NULL");
- torture_assert(tctx, str_list_equal((const char **)result, element->list),
+ torture_assert(tctx, str_list_equal((const char * const *) result,
+ element->list),
talloc_asprintf(tctx,
"str_list_make(%s) failed to create correct list",
element->list_as_string));
static bool test_list_add(struct torture_context *tctx)
{
- char **result, **result2;
+ const char **result, **result2;
const char *list[] = {
"element_0",
"element_1",
"element_3",
NULL
};
- result = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+ result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
torture_assert(tctx, result, "str_list_make() must not return NULL");
- result2 = str_list_add(result, "element_3");
+ result2 = str_list_add((const char **) result, "element_3");
torture_assert(tctx, result2, "str_list_add() must not return NULL");
torture_assert(tctx, str_list_equal(result2, list),
"str_list_add() failed");
static bool test_list_add_const(struct torture_context *tctx)
{
- char **result, **result2;
+ const char **result, **result2;
const char *list[] = {
"element_0",
"element_1",
"element_3",
NULL
};
- result = str_list_make(tctx, "element_0, element_1, element_2", NULL);
+ result = (const char **) str_list_make(tctx, "element_0, element_1, element_2", NULL);
torture_assert(tctx, result, "str_list_make() must not return NULL");
result2 = str_list_add_const(result, "element_3");
torture_assert(tctx, result2, "str_list_add_const() must not return NULL");
static bool test_list_remove(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
"element_3",
NULL
};
- result = str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
+ result = (const char **) str_list_make(tctx, "element_0, element_1, element_2, element_3", NULL);
torture_assert(tctx, result, "str_list_make() must not return NULL");
str_list_remove(result, "element_2");
torture_assert(tctx, str_list_equal(result, list),
static bool test_list_unique(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
"element_2",
NULL
};
- result = str_list_copy(tctx, list_dup);
+ result = (const char **) str_list_copy(tctx, list_dup);
/* We must copy the list, as str_list_unique does a talloc_realloc() on it's parameter */
result = str_list_unique(result);
torture_assert(tctx, result, "str_list_unique() must not return NULL");
static bool test_list_append(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
"element_5",
NULL
};
- result = str_list_copy(tctx, list);
+ result = (const char **) str_list_copy(tctx, list);
torture_assert(tctx, result, "str_list_copy() must not return NULL");
result = str_list_append(result, list2);
torture_assert(tctx, result, "str_list_append() must not return NULL");
static bool test_list_append_const(struct torture_context *tctx)
{
- char **result;
+ const char **result;
const char *list[] = {
"element_0",
"element_1",
"element_5",
NULL
};
- result = str_list_copy(tctx, list);
+ result = (const char **) str_list_copy(tctx, list);
torture_assert(tctx, result, "str_list_copy() must not return NULL");
result = str_list_append_const(result, list2);
torture_assert(tctx, result, "str_list_append_const() must not return NULL");
for (i = 0; i < ARRAY_SIZE(test_lists_shell_strings); i++) {
torture_suite_add_simple_tcase_const(suite, "lists_shell",
- test_lists_shell, &test_lists_shell_strings[i]);
+ test_lists_shell, &test_lists_shell_strings[i]);
}
for (i = 0; i < ARRAY_SIZE(test_lists_strings); i++) {
- torture_suite_add_simple_tcase_const(suite, "lists",
- test_list_make, &test_lists_strings[i]);
+ torture_suite_add_simple_tcase_const(suite, "list_make",
+ test_list_make, &test_lists_strings[i]);
}
torture_suite_add_simple_test(suite, "list_copy", test_list_copy);