diff options
author | Haru <haru@dotalux.com> | 2016-11-19 20:58:41 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-11-19 21:08:13 +0100 |
commit | 7f5a6bf8af26dc815e8c913c4917b419af86b85b (patch) | |
tree | af8fcbd937345f21694fec51577ee2128eeac76f /src/test/test_libconfig.c | |
parent | c6c30ef5e431cba1bc48900d0f558394bb112669 (diff) | |
download | hercules-7f5a6bf8af26dc815e8c913c4917b419af86b85b.tar.gz hercules-7f5a6bf8af26dc815e8c913c4917b419af86b85b.tar.bz2 hercules-7f5a6bf8af26dc815e8c913c4917b419af86b85b.tar.xz hercules-7f5a6bf8af26dc815e8c913c4917b419af86b85b.zip |
Fix various uninitialized objects in the test_libconfig suite
The config_t objects need to be initialized through libconfig->init()
before use (except when loaded through libconfig->load_file(), which
initializes the object).
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/test/test_libconfig.c')
-rw-r--r-- | src/test/test_libconfig.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/test_libconfig.c b/src/test/test_libconfig.c index 73466ec2b..639cf64e8 100644 --- a/src/test/test_libconfig.c +++ b/src/test/test_libconfig.c @@ -86,6 +86,8 @@ static const char *test_libconfig_init_destroy(void) static const char *test_libconfig_read_file_src(void) { struct config_t config; + libconfig->init(&config); + #define FILENAME "src/test/libconfig/test.conf" if (libconfig->read_file_src(&config, FILENAME) == CONFIG_FALSE) { libconfig->destroy(&config); @@ -108,6 +110,9 @@ static const char *test_libconfig_read(void) if (!fp) { return "File not found: '" FILENAME "'."; } + + libconfig->init(&config); + if (libconfig->read(&config, fp) == CONFIG_FALSE) { fclose(fp); libconfig->destroy(&config); @@ -154,6 +159,8 @@ static const char *test_libconfig_write_file(void) static const char *test_libconfig_read_string(void) { struct config_t config; + libconfig->init(&config); + if (libconfig->read_string(&config, "") == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to read from string."; @@ -180,6 +187,8 @@ static const char *test_libconfig_syntax(void) "Setting_List: ( );\n" "/* End test file */\n"; + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to read from string."; @@ -216,6 +225,8 @@ static const char *test_libconfig_lookup(void) "Setting_List: ( );\n" "/* End test file */\n"; + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -278,6 +289,8 @@ static const char *test_libconfig_setting_get(void) "Setting_List: ( );\n" "/* End test file */\n"; + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -392,6 +405,8 @@ static const char *test_libconfig_setting_lookup(void) "Setting_List: ( );\n" "/* End test file */\n"; + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -442,6 +457,8 @@ static const char *test_libconfig_setting_types(void) "Setting_List: ( );\n" "/* End test file */\n"; + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -536,6 +553,8 @@ static const char *test_libconfig_values(void) "Setting_IntSignedMax: 0x7fffffff;\n" "/* End test file */\n"; + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -599,6 +618,9 @@ static const char *test_libconfig_path_lookup(void) " 10,\n" ");\n" "/* End test file */\n"; + + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -683,6 +705,9 @@ static const char *test_libconfig_setting_names(void) "};\n" "1st_setting_with_numbers: 5;\n" "/* End test file */\n"; + + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -736,6 +761,9 @@ static const char *test_libconfig_duplicate_keys(void) " Duplicate: 4;\n" "};\n" "/* End test file */\n"; + + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; @@ -780,6 +808,9 @@ static const char *test_libconfig_special_string_syntax(void) const char *input = "/* Test File */\n" "SpecialString: <\"This is an \"Item_Script\" Special String\n\tWith a line-break inside.\">;\n" "/* End test file */\n"; + + libconfig->init(&config); + if (libconfig->read_string(&config, input) == CONFIG_FALSE) { libconfig->destroy(&config); return "Unable to parse configuration."; |