diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-15 12:59:37 +0200 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-15 12:59:37 +0200 |
| commit | 802e46f8ea36c344f112d7e1dd8d64d17a4cc939 (patch) | |
| tree | cabf480269113686430053d66df3dadcd4d137a7 /lib/tests/test_ini1.c | |
| parent | a3cf9041af810770daf5d9b83f1906fa9bb0dd11 (diff) | |
| download | monitoring-plugins-802e46f8ea36c344f112d7e1dd8d64d17a4cc939.tar.gz | |
Run clang-format again
Diffstat (limited to 'lib/tests/test_ini1.c')
| -rw-r--r-- | lib/tests/test_ini1.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/lib/tests/test_ini1.c b/lib/tests/test_ini1.c index 246c1250..3792d142 100644 --- a/lib/tests/test_ini1.c +++ b/lib/tests/test_ini1.c | |||
| @@ -42,8 +42,9 @@ char *list2str(np_arg_list *optlst) { | |||
| 42 | free(optltmp); | 42 | free(optltmp); |
| 43 | } | 43 | } |
| 44 | /* Strip last whitespace */ | 44 | /* Strip last whitespace */ |
| 45 | if (strlen(optstr) > 1) | 45 | if (strlen(optstr) > 1) { |
| 46 | optstr[strlen(optstr) - 1] = '\0'; | 46 | optstr[strlen(optstr) - 1] = '\0'; |
| 47 | } | ||
| 47 | 48 | ||
| 48 | return optstr; | 49 | return optstr; |
| 49 | } | 50 | } |
| @@ -54,15 +55,18 @@ int main(int argc, char **argv) { | |||
| 54 | plan_tests(12); | 55 | plan_tests(12); |
| 55 | 56 | ||
| 56 | optstr = list2str(np_get_defaults("section@./config-tiny.ini", "check_disk")); | 57 | optstr = list2str(np_get_defaults("section@./config-tiny.ini", "check_disk")); |
| 57 | ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "config-tiny.ini's section as expected"); | 58 | ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), |
| 59 | "config-tiny.ini's section as expected"); | ||
| 58 | my_free(optstr); | 60 | my_free(optstr); |
| 59 | 61 | ||
| 60 | optstr = list2str(np_get_defaults("@./config-tiny.ini", "section")); | 62 | optstr = list2str(np_get_defaults("@./config-tiny.ini", "section")); |
| 61 | ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "Used default section name, without specific"); | 63 | ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), |
| 64 | "Used default section name, without specific"); | ||
| 62 | my_free(optstr); | 65 | my_free(optstr); |
| 63 | 66 | ||
| 64 | optstr = list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk")); | 67 | optstr = list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk")); |
| 65 | ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), "config-tiny.ini's Section Two as expected"); | 68 | ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), |
| 69 | "config-tiny.ini's Section Two as expected"); | ||
| 66 | my_free(optstr); | 70 | my_free(optstr); |
| 67 | 71 | ||
| 68 | optstr = list2str(np_get_defaults("/path/to/file.txt@./config-tiny.ini", "check_disk")); | 72 | optstr = list2str(np_get_defaults("/path/to/file.txt@./config-tiny.ini", "check_disk")); |
| @@ -70,15 +74,18 @@ int main(int argc, char **argv) { | |||
| 70 | my_free(optstr); | 74 | my_free(optstr); |
| 71 | 75 | ||
| 72 | optstr = list2str(np_get_defaults("section2@./config-tiny.ini", "check_disk")); | 76 | optstr = list2str(np_get_defaults("section2@./config-tiny.ini", "check_disk")); |
| 73 | ok(!strcmp(optstr, "--this=that"), "config-tiny.ini's section2 with whitespace before section name"); | 77 | ok(!strcmp(optstr, "--this=that"), |
| 78 | "config-tiny.ini's section2 with whitespace before section name"); | ||
| 74 | my_free(optstr); | 79 | my_free(optstr); |
| 75 | 80 | ||
| 76 | optstr = list2str(np_get_defaults("section3@./config-tiny.ini", "check_disk")); | 81 | optstr = list2str(np_get_defaults("section3@./config-tiny.ini", "check_disk")); |
| 77 | ok(!strcmp(optstr, "--this=that"), "config-tiny.ini's section3 with whitespace after section name"); | 82 | ok(!strcmp(optstr, "--this=that"), |
| 83 | "config-tiny.ini's section3 with whitespace after section name"); | ||
| 78 | my_free(optstr); | 84 | my_free(optstr); |
| 79 | 85 | ||
| 80 | optstr = list2str(np_get_defaults("check_mysql@./plugin.ini", "check_disk")); | 86 | optstr = list2str(np_get_defaults("check_mysql@./plugin.ini", "check_disk")); |
| 81 | ok(!strcmp(optstr, "--username=operator --password=secret"), "plugin.ini's check_mysql as expected"); | 87 | ok(!strcmp(optstr, "--username=operator --password=secret"), |
| 88 | "plugin.ini's check_mysql as expected"); | ||
| 82 | my_free(optstr); | 89 | my_free(optstr); |
| 83 | 90 | ||
| 84 | optstr = list2str(np_get_defaults("check_mysql2@./plugin.ini", "check_disk")); | 91 | optstr = list2str(np_get_defaults("check_mysql2@./plugin.ini", "check_disk")); |
| @@ -90,29 +97,39 @@ int main(int argc, char **argv) { | |||
| 90 | my_free(optstr); | 97 | my_free(optstr); |
| 91 | 98 | ||
| 92 | optstr = list2str(np_get_defaults("Section Two@./config-dos.ini", "check_disk")); | 99 | optstr = list2str(np_get_defaults("Section Two@./config-dos.ini", "check_disk")); |
| 93 | ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), "config-dos.ini's Section Two as expected"); | 100 | ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), |
| 101 | "config-dos.ini's Section Two as expected"); | ||
| 94 | my_free(optstr); | 102 | my_free(optstr); |
| 95 | 103 | ||
| 96 | optstr = list2str(np_get_defaults("section_twice@./plugin.ini", "check_disk")); | 104 | optstr = list2str(np_get_defaults("section_twice@./plugin.ini", "check_disk")); |
| 97 | ok(!strcmp(optstr, "--foo=bar --bar=foo"), "plugin.ini's section_twice defined twice in the file"); | 105 | ok(!strcmp(optstr, "--foo=bar --bar=foo"), |
| 106 | "plugin.ini's section_twice defined twice in the file"); | ||
| 98 | my_free(optstr); | 107 | my_free(optstr); |
| 99 | 108 | ||
| 100 | optstr = list2str(np_get_defaults("tcp_long_lines@plugins.ini", "check_tcp")); | 109 | optstr = list2str(np_get_defaults("tcp_long_lines@plugins.ini", "check_tcp")); |
| 101 | ok(!strcmp(optstr, "--escape --send=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar " | 110 | ok(!strcmp(optstr, "--escape --send=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 111 | "yadda Foo bar BAZ yadda yadda yadda Foo bar " | ||
| 102 | "BAZ yadda yadda yadda Foo bar BAZ yadda yadda " | 112 | "BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 103 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " | 113 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar " |
| 114 | "BAZ yadda yadda yadda Foo bar BAZ yadda " | ||
| 104 | "yadda yadda Foo bar BAZ yadda yadda yadda Foo " | 115 | "yadda yadda Foo bar BAZ yadda yadda yadda Foo " |
| 105 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " | 116 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " |
| 117 | "yadda yadda Foo bar BAZ yadda yadda " | ||
| 106 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " | 118 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " |
| 107 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda --expect=Foo bar BAZ yadda yadda " | 119 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 120 | "yadda --expect=Foo bar BAZ yadda yadda " | ||
| 108 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " | 121 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " |
| 109 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo " | 122 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 123 | "yadda Foo bar BAZ yadda yadda yadda Foo " | ||
| 110 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " | 124 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 111 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " | 125 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar " |
| 126 | "BAZ yadda yadda yadda Foo bar BAZ yadda " | ||
| 112 | "yadda yadda Foo bar BAZ yadda yadda yadda Foo " | 127 | "yadda yadda Foo bar BAZ yadda yadda yadda Foo " |
| 113 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " | 128 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " |
| 129 | "yadda yadda Foo bar BAZ yadda yadda " | ||
| 114 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " | 130 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " |
| 115 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo " | 131 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 132 | "yadda Foo bar BAZ yadda yadda yadda Foo " | ||
| 116 | "bar BAZ yadda yadda yadda --jail"), | 133 | "bar BAZ yadda yadda yadda --jail"), |
| 117 | "Long options"); | 134 | "Long options"); |
| 118 | my_free(optstr); | 135 | my_free(optstr); |
