1
2#######################################################
3#
4# Test string_replace function
5#
6#######################################################
7
8body common control
9{
10      inputs => { "../../default.cf.sub" };
11      bundlesequence  => { default("$(this.promise_filename)") };
12      version => "1.0";
13}
14
15#######################################################
16
17bundle agent test
18{
19  vars:
20      "test" string => "abcdefghij\t\n";
21      "test2" string => "(){}[].*?";
22
23      # normal tests
24      "match_once" string => string_replace("abcd", "abc", "ABC");
25      "match_twice" string => string_replace("abcdabcd", "abcd", "hello");
26      "match_none" string => string_replace("abdc", "abcd", "nope");
27      "match_none2" string => string_replace($(test), "nonesuch", "TEST");
28
29      "overlap" string => string_replace("aaaa", "aaa", "yes");
30
31      "replace" string => string_replace($(test), "\t", "\r");
32      "replace2" string => string_replace($(test), "ghij\t", "tEsT");
33      "replace3" string => string_replace($(test), "abcdefghij\t\n", "no");
34
35      # tests for regex special characters
36      "special" string => string_replace($(test2), "()", "1");
37      "special2" string => string_replace($(test2), "{}", "\1");
38      "special3" string => string_replace($(test2), ".*?", "\2");
39
40      # empty cases
41      "empty" string => string_replace("", "abc", "ABC");
42      "empty2" string => string_replace("", "abc", "");
43}
44
45#######################################################
46
47bundle agent check
48{
49  methods:
50      "" usebundle => dcs_check_state(test,
51                                      "$(this.promise_filename).expected.json",
52                                       $(this.promise_filename));
53}
54