#include "strv.h"
static void test_specifier_printf(void) {
- _cleanup_free_ char *w = NULL;
-
- const Specifier table[] = {
+ static const Specifier table[] = {
{ 'a', specifier_string, (char*) "AAAA" },
{ 'b', specifier_string, (char*) "BBBB" },
- { 0, NULL, NULL }
+ { 'm', specifier_machine_id, NULL },
+ { 'B', specifier_boot_id, NULL },
+ { 'H', specifier_host_name, NULL },
+ { 'v', specifier_kernel_release, NULL },
+ {}
};
- w = specifier_printf("xxx a=%a b=%b yyy", table, NULL);
- puts(w);
+ _cleanup_free_ char *w = NULL;
+ int r;
+ r = specifier_printf("xxx a=%a b=%b yyy", table, NULL, &w);
+ assert_se(r >= 0);
assert_se(w);
+
+ puts(w);
assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
+
+ free(w);
+ r = specifier_printf("machine=%m, boot=%B, host=%H, version=%v", table, NULL, &w);
+ assert_se(r >= 0);
+ assert_se(w);
+ puts(w);
}
static const char* const input_table_multiple[] = {