diff options
author | pengyi <pengyi37@huawei.com> | 2022-12-08 04:59:25 +0800 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2022-12-13 12:08:05 +0900 |
commit | 72e0fb3fc858301de7b200e1c08da6904ab44bc0 (patch) | |
tree | 81352eb224d123f56d25c069c5f7a6283fa30ad8 | |
parent | be94bcf6aace55e319a203c6b60e31b1c204b0dc (diff) | |
download | libgpg-error-72e0fb3fc858301de7b200e1c08da6904ab44bc0.tar.gz |
Add more tests for t-printf and t-strerror.
* tests/t-printf.c (check_fwrite): New.
(main): Add check_fwrite.
* tests/t-strerror.c (main): Add three more cases to LIST.
--
The string in check_fwrite is from the Gateless Gate, for
people who want to discuss "Niente". --- gniibe
Co-authored-by: NIIBE Yutaka <gniibe@fsij.org>
Signed-off-by: "pengyi" <pengyi37@huawei.com>
-rw-r--r-- | tests/t-printf.c | 25 | ||||
-rw-r--r-- | tests/t-strerror.c | 5 |
2 files changed, 29 insertions, 1 deletions
diff --git a/tests/t-printf.c b/tests/t-printf.c index c261838..c1ad0b0 100644 --- a/tests/t-printf.c +++ b/tests/t-printf.c @@ -489,6 +489,30 @@ check_fprintf_sf (void) gpgrt_fclose (stream); } +static void +check_fwrite (void) +{ + gpgrt_stream_t stream; + const char *expect; + char *result; + + stream = gpgrt_fopenmem (0, "w+b"); + if (!stream) + die ("fopenmem failed at line %d\n", __LINE__); + + gpgrt_fwrite ("Has the dog Buddha-nature or not?", 1, 33, stream); + expect = "Has the dog Buddha-nature or not?"; + result = stream_to_string (stream); + if (strcmp (result, expect)) + { + show ("expect: '%s'\n", expect); + show ("result: '%s'\n", result); + fail ("fprintf_sf failed at %d\n", __LINE__); + } + free (result); + gpgrt_fclose (stream); +} + int main (int argc, char **argv) @@ -535,6 +559,7 @@ main (int argc, char **argv) run_tests (); check_snprintf (); check_fprintf_sf (); + check_fwrite (); #ifdef __GLIBC__ return !!errorcount; diff --git a/tests/t-strerror.c b/tests/t-strerror.c index 9289066..5c38fca 100644 --- a/tests/t-strerror.c +++ b/tests/t-strerror.c @@ -49,7 +49,10 @@ main (int argc, char *argv[]) gpg_err_source_t src; gpg_err_code_t code; } list[] = { { 0, 0 }, { 1, 201 }, { 2, 2 }, { 3, 102 }, - { 4, 100 }, { 5, 99 }, { 6, 110 }, { 7, 7 }, { 8, 888 } }; + { 4, 100 }, { 5, 99 }, { 6, 110 }, { 7, 7 }, { 8, 888 }, + { 1, GPG_ERR_SYSTEM_ERROR | 1 }, + { 1, GPG_ERR_SYSTEM_ERROR | 35 }, + { 1, GPG_ERR_SYSTEM_ERROR | 81 } }; int i = 0; while (i < sizeof (list) / sizeof (list[0])) |