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 | |
parent | 6c4ec5c0bd46b1292d15a789560fb5acd813bbce (diff) | |
download | stdu-work/1.0.0.tar.gz stdu-work/1.0.0.zip |
Minor fixeswork/1.0.0
-rw-r--r-- | config-parser.c | 25 | ||||
-rw-r--r-- | formatting.c | 8 | ||||
-rw-r--r-- | stdu.c | 1 |
3 files changed, 12 insertions, 22 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); diff --git a/formatting.c b/formatting.c index ac0222c..60f37ee 100644 --- a/formatting.c +++ b/formatting.c @@ -273,7 +273,7 @@ char* test_floored_exponent_notation() { exp_notated res = ull_floored_exponent_notation(9489345, 3); snprintf(msg, bufsize, - "ull_floored_exponent_notation(9489345, 3): expected 948*10^4, got %d*%d^%d", + "ull_floored_exponent_notation(9489345, 3): expected 948*10^4, got %llu*%d^%d", res.mantissa, res.base, res.exponent ); mt_assert( @@ -284,7 +284,7 @@ char* test_floored_exponent_notation() { res = ull_floored_exponent_notation_base(3145733, 1, 1024); snprintf(msg, bufsize, - "ull_floored_exponent_notation_base(3145733, 1, 1024): expected 3*1024^2, got %d*%d^%d", + "ull_floored_exponent_notation_base(3145733, 1, 1024): expected 3*1024^2, got %llu*%d^%d", res.mantissa, res.base, res.exponent ); mt_assert( @@ -303,7 +303,7 @@ char* test_ceiled_exponent_notation() { exp_notated res = ull_ceiled_exponent_notation(9489345, 3); snprintf(msg, bufsize, - "ull_ceiled_exponent_notation(9489345, 3): expected 949*10^4, got %d*%d^%d", + "ull_ceiled_exponent_notation(9489345, 3): expected 949*10^4, got %llu*%d^%d", res.mantissa, res.base, res.exponent ); mt_assert( @@ -314,7 +314,7 @@ char* test_ceiled_exponent_notation() { res = ull_ceiled_exponent_notation_base(3145733, 1, 1024); snprintf(msg, bufsize, - "ull_ceiled_exponent_notation_base(3145733, 1, 1024): expected 4*1024^2, got %d*%d^%d", + "ull_ceiled_exponent_notation_base(3145733, 1, 1024): expected 4*1024^2, got %llu*%d^%d", res.mantissa, res.base, res.exponent ); mt_assert( @@ -72,7 +72,6 @@ Print amount of data piped to stdin.\n\ - bytes_read; bufsize = 1024; } - size_t max_bufsize = 1048576; char* buf = malloc(bufsize); char* tmpbuf; |