From: Marcus Brinkmann Date: Mon, 22 Oct 2001 14:19:25 +0000 (+0000) Subject: 2001-10-22 Marcus Brinkmann X-Git-Tag: gpgme-0-3-0~129 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d4fb115bda4a870ad0b28c6fec34814ff07ad115;p=gpgme.git 2001-10-22 Marcus Brinkmann * t-data.c (write_test): New function. (main): Invoke write_test for all rounds except TEST_OUT_CB. --- diff --git a/tests/ChangeLog b/tests/ChangeLog index a90637f..53b9c51 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2001-10-22 Marcus Brinkmann + + * t-data.c (write_test): New function. + (main): Invoke write_test for all rounds except TEST_OUT_CB. + 2001-10-22 Marcus Brinkmann * Makefile.am (INCLUDES): Remove spurious duplicate to silence diff --git a/tests/t-data.c b/tests/t-data.c index f7d6e4c..47a8926 100644 --- a/tests/t-data.c +++ b/tests/t-data.c @@ -71,13 +71,14 @@ typedef enum } round_t; const char *text = "Just GNU it!\n"; +const char *text2 = "Just GNU it!\nJust GNU it!\n"; int read_cb (void *cb_value, char *buffer, size_t count, size_t *nread) { static int off = 0; - round_t round = *((round_t *) cb_value); int amount = strlen (text) - off; + /* round_t round = *((round_t *) cb_value); */ if (!buffer && !count && !nread) { @@ -152,6 +153,44 @@ read_test (round_t round, GpgmeData data) read_once_test (round, data); } +void +write_test (round_t round, GpgmeData data) +{ + GpgmeError err; + char buffer[1024]; + int read; + + err = gpgme_data_write (data, text, strlen (text)); + fail_if_err (err); + + read_once_test (round, data); + err = gpgme_data_rewind (data); + fail_if_err (err); + + if (round == TEST_INOUT_NONE) + read_once_test (round, data); + else + { + err = gpgme_data_read (data, buffer, sizeof (buffer), &read); + fail_if_err (err); + + if (read != strlen (text2) || strncmp (buffer, text2, strlen (text2))) + { + fprintf (stderr, "%s:%d: (%i) gpgme_data_read returned wrong data\n", + __FILE__, __LINE__, round); + exit (1); + } + + err = gpgme_data_read (data, buffer, sizeof (buffer), &read); + if (err != GPGME_EOF) + { + fprintf (stderr, "%s:%d: (%i) gpgme_data_read did not signal EOF\n", + __FILE__, __LINE__, round); + exit (1); + } + } +} + int main (int argc, char **argv ) { @@ -276,7 +315,8 @@ main (int argc, char **argv ) exit (1); } read_test (round, data); - + if (round != TEST_OUT_CB) + write_test (round, data); gpgme_data_release (data); } return 0;