test-strv.c revision 1731e34a4ebddf6e1247ad252c7a45c2c1163f42
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
Copyright 2013 Thomas H.P. Andersen
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <string.h>
#include "util.h"
#include "specifier.h"
#include "strv.h"
static void test_specifier_printf(void) {
{}
};
_cleanup_free_ char *w = NULL;
int r;
assert_se(r >= 0);
assert_se(w);
puts(w);
free(w);
assert_se(r >= 0);
assert_se(w);
puts(w);
}
static const char* const input_table_multiple[] = {
"one",
"two",
"three",
NULL,
};
static const char* const input_table_one[] = {
"one",
NULL,
};
static const char* const input_table_none[] = {
NULL,
};
static const char* const input_table_quotes[] = {
"\"",
"'",
"\"\"",
"\\",
"\\\\",
NULL,
};
#define QUOTES_STRING \
"\"\\\"\" " \
"\"\\\'\" " \
"\"\\\"\\\"\" " \
"\"\\\\\" " \
"\"\\\\\\\\\""
static const char * const input_table_spaces[] = {
" ",
"' '",
"\" ",
" \"",
" \\\\ ",
NULL,
};
#define SPACES_STRING \
"\" \" " \
"\"\\' \\'\" " \
"\"\\\" \" " \
"\" \\\"\" " \
"\" \\\\\\\\ \""
static void test_strv_find(void) {
}
static void test_strv_find_prefix(void) {
}
static void test_strv_join(void) {
assert_se(p);
assert_se(q);
assert_se(r);
assert_se(s);
assert_se(t);
}
_cleanup_free_ char *p;
_cleanup_strv_free_ char **s;
char **t;
p = strv_join_quoted((char **)split);
assert_se(p);
s = strv_split_quoted(quoted);
assert_se(s);
STRV_FOREACH(t, s) {
assert_se(*t);
split++;
}
}
static void test_strv_split_nulstr(void) {
_cleanup_strv_free_ char **l = NULL;
const char nulstr[] = "str0\0str1\0str2\0str3\0";
l = strv_split_nulstr (nulstr);
assert_se(l);
}
static void test_strv_parse_nulstr(void) {
_cleanup_strv_free_ char **l = NULL;
const char nulstr[] = "fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx";
assert_se(l);
puts("Parse nulstr:");
strv_print(l);
}
static void test_strv_overlap(void) {
const char * const input_table[] = {
"one",
"two",
"three",
};
const char * const input_table_overlap[] = {
"two",
};
const char * const input_table_unique[] = {
"four",
"five",
"six",
};
}
static void test_strv_sort(void) {
const char* input_table[] = {
"durian",
"apple",
"citrus",
"CAPITAL LETTERS FIRST",
"banana",
};
strv_sort((char **)input_table);
}
static void test_strv_merge_concat(void) {
assert_se(a);
assert_se(b);
c = strv_merge_concat(a, b, "_suffix");
assert_se(c);
}
static void test_strv_merge(void) {
assert_se(a);
assert_se(b);
c = strv_merge(a, b);
assert_se(c);
}
static void test_strv_append(void) {
assert_se(a);
b = strv_append(a, "test2");
assert_se(b);
assert_se(c);
}
static void test_strv_foreach_pair(void) {
_cleanup_strv_free_ char **a = NULL;
char **x, **y;
"pair_two", "pair_two",
"pair_three", "pair_three",
NULL);
STRV_FOREACH_PAIR(x, y, a) {
}
}
return 0;
}