diff options
Diffstat (limited to 'lib/tests/test_ini1.c')
| -rw-r--r-- | lib/tests/test_ini1.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/lib/tests/test_ini1.c b/lib/tests/test_ini1.c index 246c1250..de983764 100644 --- a/lib/tests/test_ini1.c +++ b/lib/tests/test_ini1.c | |||
| @@ -42,27 +42,30 @@ 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 | } |
| 50 | 51 | ||
| 51 | int main(int argc, char **argv) { | 52 | int main(int argc, char **argv) { |
| 52 | char *optstr = NULL; | ||
| 53 | 53 | ||
| 54 | plan_tests(12); | 54 | plan_tests(12); |
| 55 | 55 | ||
| 56 | optstr = list2str(np_get_defaults("section@./config-tiny.ini", "check_disk")); | 56 | char *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"); | 57 | ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), |
| 58 | "config-tiny.ini's section as expected"); | ||
| 58 | my_free(optstr); | 59 | my_free(optstr); |
| 59 | 60 | ||
| 60 | optstr = list2str(np_get_defaults("@./config-tiny.ini", "section")); | 61 | 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"); | 62 | ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), |
| 63 | "Used default section name, without specific"); | ||
| 62 | my_free(optstr); | 64 | my_free(optstr); |
| 63 | 65 | ||
| 64 | optstr = list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk")); | 66 | 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"); | 67 | ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), |
| 68 | "config-tiny.ini's Section Two as expected"); | ||
| 66 | my_free(optstr); | 69 | my_free(optstr); |
| 67 | 70 | ||
| 68 | optstr = list2str(np_get_defaults("/path/to/file.txt@./config-tiny.ini", "check_disk")); | 71 | optstr = list2str(np_get_defaults("/path/to/file.txt@./config-tiny.ini", "check_disk")); |
| @@ -70,15 +73,18 @@ int main(int argc, char **argv) { | |||
| 70 | my_free(optstr); | 73 | my_free(optstr); |
| 71 | 74 | ||
| 72 | optstr = list2str(np_get_defaults("section2@./config-tiny.ini", "check_disk")); | 75 | 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"); | 76 | ok(!strcmp(optstr, "--this=that"), |
| 77 | "config-tiny.ini's section2 with whitespace before section name"); | ||
| 74 | my_free(optstr); | 78 | my_free(optstr); |
| 75 | 79 | ||
| 76 | optstr = list2str(np_get_defaults("section3@./config-tiny.ini", "check_disk")); | 80 | 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"); | 81 | ok(!strcmp(optstr, "--this=that"), |
| 82 | "config-tiny.ini's section3 with whitespace after section name"); | ||
| 78 | my_free(optstr); | 83 | my_free(optstr); |
| 79 | 84 | ||
| 80 | optstr = list2str(np_get_defaults("check_mysql@./plugin.ini", "check_disk")); | 85 | 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"); | 86 | ok(!strcmp(optstr, "--username=operator --password=secret"), |
| 87 | "plugin.ini's check_mysql as expected"); | ||
| 82 | my_free(optstr); | 88 | my_free(optstr); |
| 83 | 89 | ||
| 84 | optstr = list2str(np_get_defaults("check_mysql2@./plugin.ini", "check_disk")); | 90 | optstr = list2str(np_get_defaults("check_mysql2@./plugin.ini", "check_disk")); |
| @@ -90,29 +96,39 @@ int main(int argc, char **argv) { | |||
| 90 | my_free(optstr); | 96 | my_free(optstr); |
| 91 | 97 | ||
| 92 | optstr = list2str(np_get_defaults("Section Two@./config-dos.ini", "check_disk")); | 98 | 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"); | 99 | ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), |
| 100 | "config-dos.ini's Section Two as expected"); | ||
| 94 | my_free(optstr); | 101 | my_free(optstr); |
| 95 | 102 | ||
| 96 | optstr = list2str(np_get_defaults("section_twice@./plugin.ini", "check_disk")); | 103 | 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"); | 104 | ok(!strcmp(optstr, "--foo=bar --bar=foo"), |
| 105 | "plugin.ini's section_twice defined twice in the file"); | ||
| 98 | my_free(optstr); | 106 | my_free(optstr); |
| 99 | 107 | ||
| 100 | optstr = list2str(np_get_defaults("tcp_long_lines@plugins.ini", "check_tcp")); | 108 | 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 " | 109 | ok(!strcmp(optstr, "--escape --send=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 110 | "yadda Foo bar BAZ yadda yadda yadda Foo bar " | ||
| 102 | "BAZ yadda yadda yadda Foo bar BAZ yadda yadda " | 111 | "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 " | 112 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar " |
| 113 | "BAZ yadda yadda yadda Foo bar BAZ yadda " | ||
| 104 | "yadda yadda Foo bar BAZ yadda yadda yadda Foo " | 114 | "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 " | 115 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " |
| 116 | "yadda yadda Foo bar BAZ yadda yadda " | ||
| 106 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " | 117 | "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 " | 118 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 119 | "yadda --expect=Foo bar BAZ yadda yadda " | ||
| 108 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " | 120 | "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 " | 121 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 122 | "yadda Foo bar BAZ yadda yadda yadda Foo " | ||
| 110 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " | 123 | "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 " | 124 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar " |
| 125 | "BAZ yadda yadda yadda Foo bar BAZ yadda " | ||
| 112 | "yadda yadda Foo bar BAZ yadda yadda yadda Foo " | 126 | "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 " | 127 | "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " |
| 128 | "yadda yadda Foo bar BAZ yadda yadda " | ||
| 114 | "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " | 129 | "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 " | 130 | "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " |
| 131 | "yadda Foo bar BAZ yadda yadda yadda Foo " | ||
| 116 | "bar BAZ yadda yadda yadda --jail"), | 132 | "bar BAZ yadda yadda yadda --jail"), |
| 117 | "Long options"); | 133 | "Long options"); |
| 118 | my_free(optstr); | 134 | my_free(optstr); |
