#include "strv.h"
static void test_specifier_printf(void) {
- char *w;
+ _cleanup_free_ char *w = NULL;
const Specifier table[] = {
{ 'a', specifier_string, (char*) "AAAA" },
};
w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
- printf("<%s>\n", w);
- free(w);
+ puts(w);
+
+ assert_se(w);
+ assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
}
static void test_strv_find(void) {
}
static void test_strv_sort(void) {
- const char * const input_table[] = {
+ const char* input_table[] = {
"durian",
"apple",
"citrus",
assert_se(streq(c[0], "test3"));
}
+static void test_strv_foreach_pair(void) {
+ _cleanup_strv_free_ char **a = NULL;
+ char **x, **y;
+
+ a = strv_new("pair_one", "pair_one",
+ "pair_two", "pair_two",
+ "pair_three", "pair_three",
+ NULL);
+
+ STRV_FOREACH_PAIR(x, y, a) {
+ assert_se(streq(*x, *y));
+ }
+}
+
int main(int argc, char *argv[]) {
test_specifier_printf();
+ test_strv_foreach_pair();
test_strv_find();
test_strv_find_prefix();
test_strv_join();