Systemd/src/test/test-replace-var.c
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00

34 lines
805 B
C

/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
Copyright 2012 Lennart Poettering
***/
#include <string.h>
#include "macro.h"
#include "replace-var.h"
#include "string-util.h"
#include "util.h"
static char *lookup(const char *variable, void *userdata) {
return strjoin("<<<", variable, ">>>");
}
int main(int argc, char *argv[]) {
char *r;
assert_se(r = replace_var("@@@foobar@xyz@HALLO@foobar@test@@testtest@TEST@...@@@", lookup, NULL));
puts(r);
assert_se(streq(r, "@@@foobar@xyz<<<HALLO>>>foobar@test@@testtest<<<TEST>>>...@@@"));
free(r);
assert_se(r = strreplace("XYZFFFFXYZFFFFXYZ", "XYZ", "ABC"));
puts(r);
assert_se(streq(r, "ABCFFFFABCFFFFABC"));
free(r);
return 0;
}