aboutsummaryrefslogtreecommitdiffstats
path: root/tests/t-printf.c
diff options
context:
space:
mode:
authorpengyi <[email protected]>2022-12-07 20:59:25 +0000
committerNIIBE Yutaka <[email protected]>2022-12-13 03:08:05 +0000
commit72e0fb3fc858301de7b200e1c08da6904ab44bc0 (patch)
tree81352eb224d123f56d25c069c5f7a6283fa30ad8 /tests/t-printf.c
parentHandle strerror_r failure on non-GNU systems. (diff)
downloadlibgpg-error-72e0fb3fc858301de7b200e1c08da6904ab44bc0.tar.gz
libgpg-error-72e0fb3fc858301de7b200e1c08da6904ab44bc0.zip
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 <[email protected]> Signed-off-by: "pengyi" <[email protected]>
Diffstat (limited to 'tests/t-printf.c')
-rw-r--r--tests/t-printf.c25
1 files changed, 25 insertions, 0 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;