test-strv.c revision 5fba7bbfa47ef5c03a28000252d06ec82405d461
6ca0e6973c8176100f4a426444823ae5e777e28fsascha/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6ca0e6973c8176100f4a426444823ae5e777e28fsascha This file is part of systemd.
6ca0e6973c8176100f4a426444823ae5e777e28fsascha Copyright 2010 Lennart Poettering
6ca0e6973c8176100f4a426444823ae5e777e28fsascha Copyright 2013 Thomas H.P. Andersen
6ca0e6973c8176100f4a426444823ae5e777e28fsascha systemd is free software; you can redistribute it and/or modify it
6ca0e6973c8176100f4a426444823ae5e777e28fsascha under the terms of the GNU Lesser General Public License as published by
6ca0e6973c8176100f4a426444823ae5e777e28fsascha the Free Software Foundation; either version 2.1 of the License, or
6ca0e6973c8176100f4a426444823ae5e777e28fsascha (at your option) any later version.
6ca0e6973c8176100f4a426444823ae5e777e28fsascha systemd is distributed in the hope that it will be useful, but
6ca0e6973c8176100f4a426444823ae5e777e28fsascha WITHOUT ANY WARRANTY; without even the implied warranty of
6ca0e6973c8176100f4a426444823ae5e777e28fsascha MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6ca0e6973c8176100f4a426444823ae5e777e28fsascha Lesser General Public License for more details.
6ca0e6973c8176100f4a426444823ae5e777e28fsascha You should have received a copy of the GNU Lesser General Public License
6ca0e6973c8176100f4a426444823ae5e777e28fsascha along with systemd; If not, see <http://www.gnu.org/licenses/>.
6ca0e6973c8176100f4a426444823ae5e777e28fsaschastatic void test_specifier_printf(void) {
6ca0e6973c8176100f4a426444823ae5e777e28fsascha r = specifier_printf("xxx a=%a b=%b yyy", table, NULL, &w);
6ca0e6973c8176100f4a426444823ae5e777e28fsascha r = specifier_printf("machine=%m, boot=%B, host=%H, version=%v", table, NULL, &w);
6ca0e6973c8176100f4a426444823ae5e777e28fsaschastatic const char* const input_table_multiple[] = {
6ca0e6973c8176100f4a426444823ae5e777e28fsaschastatic const char* const input_table_one[] = {
6ca0e6973c8176100f4a426444823ae5e777e28fsaschastatic const char* const input_table_none[] = {
6ca0e6973c8176100f4a426444823ae5e777e28fsaschastatic const char* const input_table_quotes[] = {
6ca0e6973c8176100f4a426444823ae5e777e28fsascha "\"\\\"\" " \
6ca0e6973c8176100f4a426444823ae5e777e28fsascha "\"\\\'\" " \
6ca0e6973c8176100f4a426444823ae5e777e28fsascha "\"\\\"\\\"\" " \
6ca0e6973c8176100f4a426444823ae5e777e28fsascha "\"\\\\\" " \
6ca0e6973c8176100f4a426444823ae5e777e28fsascha "\"\\\\\\\\\""
6ca0e6973c8176100f4a426444823ae5e777e28fsaschastatic 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;
assert_se(p);
assert_se(p);
assert_se(s);
STRV_FOREACH(t, s) {
assert_se(*t);
split++;
_cleanup_strv_free_ char **s;
assert_se(s);
STRV_FOREACH(t, s)
static void test_strv_split(void) {
assert(l);
STRV_FOREACH(s, l) {
static void test_strv_split_newlines(void) {
assert(l);
STRV_FOREACH(s, l) {
static void test_strv_split_nulstr(void) {
assert_se(l);
static void test_strv_remove_prefix(void) {
assert(l);
assert(l);
STRV_FOREACH(s, l) {
static void test_strv_parse_nulstr(void) {
assert_se(l);
strv_print(l);
static void test_strv_overlap(void) {
const char * const input_table[] = {
const char * const input_table_overlap[] = {
const char * const input_table_unique[] = {
static void test_strv_sort(void) {
const char* input_table[] = {
static void test_strv_merge_concat(void) {
assert_se(a);
assert_se(b);
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);
assert_se(b);
assert_se(c);
static void test_strv_foreach(void) {
_cleanup_strv_free_ char **a;
char **check;
assert_se(a);
static void test_strv_foreach_backwards(void) {
_cleanup_strv_free_ char **a;
char **check;
assert_se(a);
static void test_strv_foreach_pair(void) {
NULL);
STRV_FOREACH_PAIR(x, y, a) {
static void test_strv_from_stdarg_alloca(void) {
test_strv_quote_unquote2(" foo=bar \"waldo\" zzz ", (const char*[]) { "foo=bar", "waldo", "zzz", NULL });