diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-07-07 14:51:17 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-07-08 10:05:39 +0200 |
commit | 9053dbbf62c7c9f4723959b557078a787ba6afec (patch) | |
tree | a6f859428ac17f47bd89e2dd72b5b11220525699 /tests/unit | |
parent | e7416cfd2bd58d256b8524f31ef22a43aa23a970 (diff) | |
download | curl-9053dbbf62c7c9f4723959b557078a787ba6afec.tar.gz |
msnprintf: return number of printed characters excluding null byte
... even when the output is "capped" by the maximum length argument.
Clarified in the docs.
Closes #7361
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/unit1398.c | 12 | ||||
-rw-r--r-- | tests/unit/unit1652.c | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/unit/unit1398.c b/tests/unit/unit1398.c index 43e1f47a5..e73ce24b0 100644 --- a/tests/unit/unit1398.c +++ b/tests/unit/unit1398.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -64,27 +64,27 @@ fail_unless(!strcmp(output, "012"), "wrong output"); /* negative width */ rc = curl_msnprintf(output, 8, "%-8s", str); -fail_unless(rc == 8, "return code should be 8"); +fail_unless(rc == 7, "return code should be 7"); fail_unless(!strcmp(output, "bug "), "wrong output"); /* larger width that string length */ rc = curl_msnprintf(output, 8, "%8s", str); -fail_unless(rc == 8, "return code should be 8"); +fail_unless(rc == 7, "return code should be 7"); fail_unless(!strcmp(output, " bu"), "wrong output"); /* output a number in a limited output */ rc = curl_msnprintf(output, 4, "%d", 10240); -fail_unless(rc == 4, "return code should be 4"); +fail_unless(rc == 3, "return code should be 3"); fail_unless(!strcmp(output, "102"), "wrong output"); /* padded strings */ rc = curl_msnprintf(output, 16, "%8s%8s", str, str); -fail_unless(rc == 16, "return code should be 16"); +fail_unless(rc == 15, "return code should be 15"); fail_unless(!strcmp(output, " bug bu"), "wrong output"); /* padded numbers */ rc = curl_msnprintf(output, 16, "%8d%8d", 1234, 5678); -fail_unless(rc == 16, "return code should be 16"); +fail_unless(rc == 15, "return code should be 15"); fail_unless(!strcmp(output, " 1234 567"), "wrong output"); UNITTEST_STOP diff --git a/tests/unit/unit1652.c b/tests/unit/unit1652.c index 26f11e483..56dad0c34 100644 --- a/tests/unit/unit1652.c +++ b/tests/unit/unit1652.c @@ -108,7 +108,7 @@ fail_unless(verify(result, "(nil)") == 0, "Passing NULL as string"); /* A string just long enough to not be truncated */ memset(input, '\0', sizeof(input)); -memset(input, 'A', 2048); +memset(input, 'A', 2047); Curl_infof(data, "%s", input); fail_unless(strlen(result) == 2048, "No truncation of infof input"); fail_unless(verify(result, input) == 0, "No truncation of infof input"); |