libmpm

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

commit f50751ba1ea5e077e3bbb4d25780a23e1c23aad5
parent 5b38227d63ab97c3028b20a58d0895118ba23928
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 15 Feb 2017 10:28:37 +0100

Fix(Configuration): Create a subdir for tests config, add a test for handling parsing error

Diffstat:
Atests/conf/bad.conf | 3+++
Rtests/base.conf -> tests/conf/base.conf | 0
Mtests/test_config.c | 15++++++++++++++-
3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/tests/conf/bad.conf b/tests/conf/bad.conf @@ -0,0 +1,3 @@ +nonsense { + Yup +} diff --git a/tests/base.conf b/tests/conf/base.conf diff --git a/tests/test_config.c b/tests/test_config.c @@ -4,7 +4,7 @@ TEST(config_basic) { u8_t ret; config_t *conf = NULL; - conf = parse_config("base.conf", &ret); + conf = parse_config("conf/base.conf", &ret); if (ret != 0) { m_panic("%s\n", conf->err); } @@ -13,6 +13,19 @@ TEST(config_basic) { return TEST_SUCCESS; } +TEST(config_error) { + u8_t ret; + config_t *conf = NULL; + + conf = parse_config("conf/bad.conf", &ret); + TEST_ASSERT((ret != 0), "No parsing error ?"); + TEST_ASSERT((strcmp(conf->err, "conf/bad.conf:1: no such option 'nonsense'") == 0), "Error is bad."); + config_free(conf); + return TEST_SUCCESS; + +} + void register_test_config(void) { reg_test("config", config_basic); + reg_test("config", config_error); }