]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-replace-var.c
41468031b3a2c5c8db299ba3d0f41d1351cbbfde
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright 2012 Lennart Poettering
9 #include "replace-var.h"
10 #include "string-util.h"
13 static char *lookup(const char *variable
, void *userdata
) {
14 return strjoin("<<<", variable
, ">>>");
17 int main(int argc
, char *argv
[]) {
20 assert_se(r
= replace_var("@@@foobar@xyz@HALLO@foobar@test@@testtest@TEST@...@@@", lookup
, NULL
));
22 assert_se(streq(r
, "@@@foobar@xyz<<<HALLO>>>foobar@test@@testtest<<<TEST>>>...@@@"));
25 assert_se(r
= strreplace("XYZFFFFXYZFFFFXYZ", "XYZ", "ABC"));
27 assert_se(streq(r
, "ABCFFFFABCFFFFABC"));