]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-replace-var.c
libudev: hide definition of struct udev_list from other libudev components
[thirdparty/systemd.git] / src / test / test-replace-var.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <stdio.h>
4
5 #include "macro.h"
6 #include "replace-var.h"
7 #include "string-util.h"
8
9 static char *lookup(const char *variable, void *userdata) {
10 return strjoin("<<<", variable, ">>>");
11 }
12
13 int main(int argc, char *argv[]) {
14 char *r;
15
16 assert_se(r = replace_var("@@@foobar@xyz@HALLO@foobar@test@@testtest@TEST@...@@@", lookup, NULL));
17 puts(r);
18 assert_se(streq(r, "@@@foobar@xyz<<<HALLO>>>foobar@test@@testtest<<<TEST>>>...@@@"));
19 free(r);
20
21 assert_se(r = strreplace("XYZFFFFXYZFFFFXYZ", "XYZ", "ABC"));
22 puts(r);
23 assert_se(streq(r, "ABCFFFFABCFFFFABC"));
24 free(r);
25
26 return 0;
27 }