libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit a7c3c7463e6c01a8d4479a5f1f450fef32f64c3f
parent 7d01617563034673f1147f7f38e614e3ca8880c1
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue,  7 Mar 2017 19:26:15 +0100

Add(Tests): Add a test case for config

Diffstat:
Msrc/config.c | 2+-
Mtests/test_config.c | 5+++++
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/config.c b/src/config.c @@ -122,7 +122,7 @@ void config_free(config_t **ptr) { } void config_get_error_string(config_t *ptr) { - if (strlen(g_error) == 0) + if (strlen(g_error) == 0 || ptr == NULL) return ; asprintf(&ptr->err, "%s:%d: %s", ptr->fn, ptr->ptr->line, g_error); diff --git a/tests/test_config.c b/tests/test_config.c @@ -22,10 +22,15 @@ TEST(config_error) { TEST_ASSERT((strcmp(conf->err, "conf/bad.conf:1: no such option 'nonsense'") == 0), "Error is bad."); config_free(&conf); return TEST_SUCCESS; +} +TEST(config_get_error_string) { + config_get_error_string(NULL); + return TEST_SUCCESS; } void register_test_config(void) { reg_test("config", config_basic); reg_test("config", config_error); + reg_test("config", config_get_error_string); }