diff options
Diffstat (limited to 'config-parser.c')
-rw-r--r-- | config-parser.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/config-parser.c b/config-parser.c index 0ef0a47..e10275f 100644 --- a/config-parser.c +++ b/config-parser.c @@ -166,8 +166,7 @@ Result parse_config(int argc, char* argv[]) { snprintf( error_msg, 53, - "the precision may not contain non-numeric characters", - precision + "the precision may not contain non-numeric characters" ); res.result = error_msg; return res; @@ -184,7 +183,7 @@ Result parse_config(int argc, char* argv[]) { } } - Config* conf = malloc(sizeof(int) + sizeof(bool)); + Config* conf = malloc(sizeof(Config)); conf->help = tmp.help; conf->human_readable = tmp.human_readable; conf->multiline = tmp.multiline; @@ -246,15 +245,11 @@ char* test_precision_parsing() { } char* test_human_readability_parsing() { - int argc; - Result res; - Config* conf; - char* error_msg; - - argc = 2; + int argc = 2; char* argv[] = { "stdu", "--human-readable" }; - res = parse_config(argc, argv); - conf = (Config*) res.result; + Result res = parse_config(argc, argv); + Config* conf = (Config*) res.result; + mt_assert_eq(res.success, true); mt_assert_eq(conf->human_readable, true); free(conf); @@ -263,14 +258,10 @@ char* test_human_readability_parsing() { } char* test_multioption_parsing() { - Result res; - Config* conf; - char* error_msg; - int argc = 3; char* argv[] = { "stdu", "-mh?p", "3"}; - res = parse_config(argc, argv); - conf = (Config*) res.result; + Result res = parse_config(argc, argv); + Config* conf = (Config*) res.result; mt_assert_eq(res.success, true); mt_assert_eq(conf->help, true); mt_assert_eq(conf->human_readable, true); |