diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-04-21 18:34:15 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-04-21 18:34:15 +0300 |
commit | 3be3d993576fbce97cfa6068e427334deb5feb96 (patch) | |
tree | 8c5579947536487f786943b2d7892cef4497f507 /config-parser.c | |
parent | 6c4ec5c0bd46b1292d15a789560fb5acd813bbce (diff) | |
download | stdu-3be3d993576fbce97cfa6068e427334deb5feb96.tar.gz stdu-3be3d993576fbce97cfa6068e427334deb5feb96.zip |
Minor fixeswork/1.0.0
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); |