diff options
author | Moritz Schulte <mo@g10code.com> | 2005-11-26 11:52:56 +0000 |
---|---|---|
committer | Moritz Schulte <mo@g10code.com> | 2005-11-26 11:52:56 +0000 |
commit | 93c10dea2860835c10238785acbfeaf96c0ceff6 (patch) | |
tree | a59d91f1f8132a8970b51e1298c3de13e3228518 /tests | |
parent | 9d775862110c4aae359c4d8cb3ad506fc1347bc5 (diff) | |
download | libgcrypt-93c10dea2860835c10238785acbfeaf96c0ceff6.tar.gz |
2005-11-12 Moritz Schulte <moritz@g10code.com>
* ac-data.c: Added way more test cases.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ChangeLog | 4 | ||||
-rw-r--r-- | tests/ac-data.c | 40 |
2 files changed, 32 insertions, 12 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 560ae90d..a5eb7125 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2005-11-12 Moritz Schulte <moritz@g10code.com> + + * ac-data.c: Added way more test cases. + 2005-09-15 Moritz Schulte <moritz@g10code.com> * Makefile.am (TESTS): Added keygrip. diff --git a/tests/ac-data.c b/tests/ac-data.c index b210b43e..08ddba9e 100644 --- a/tests/ac-data.c +++ b/tests/ac-data.c @@ -51,15 +51,8 @@ die (const char *format, ...) } static void -check_sexp_conversion (gcry_ac_data_t data) +check_sexp_conversion (gcry_ac_data_t data, const char **identifiers) { - const char *identifiers[] = { "foo", - "bar", - "baz", - "hello", - "somemoretexthere", - "blahblahblah", - NULL }; gcry_ac_data_t data2; gcry_error_t err; gcry_sexp_t sexp; @@ -70,7 +63,7 @@ check_sexp_conversion (gcry_ac_data_t data) err = gcry_ac_data_to_sexp (data, &sexp, identifiers); assert_err (err); - + gcry_sexp_dump (sexp); err = gcry_ac_data_from_sexp (&data2, sexp, identifiers); assert_err (err); @@ -95,6 +88,14 @@ check_sexp_conversion (gcry_ac_data_t data) void check_run (void) { + const char *identifiers[] = { "foo", + "bar", + "baz", + "hello", + "somemoretexthere", + "blahblahblah", + NULL }; + const char *identifiers_null[] = { NULL }; gcry_ac_data_t data; gcry_error_t err; const char *label0; @@ -103,6 +104,8 @@ check_run (void) gcry_mpi_t mpi1; gcry_mpi_t mpi2; + /* Initialize values. */ + label0 = "thisisreallylonglabelbutsincethereisnolimitationonthelengthoflabelsitshouldworkjustfine"; mpi0 = gcry_mpi_new (0); assert (mpi0); @@ -111,13 +114,20 @@ check_run (void) err = gcry_ac_data_new (&data); assert_err (err); + check_sexp_conversion (data, identifiers); + check_sexp_conversion (data, identifiers_null); + check_sexp_conversion (data, NULL); + err = gcry_ac_data_set (data, 0, label0, mpi0); assert_err (err); err = gcry_ac_data_get_index (data, 0, 0, &label1, &mpi1); assert_err (err); assert (label0 == label1); assert (mpi0 == mpi1); - check_sexp_conversion (data); + check_sexp_conversion (data, identifiers); + check_sexp_conversion (data, identifiers_null); + check_sexp_conversion (data, NULL); + printf ("data-set-test-0 succeeded\n"); gcry_ac_data_clear (data); @@ -136,7 +146,10 @@ check_run (void) err = gcry_ac_data_set (data, GCRY_AC_FLAG_COPY | GCRY_AC_FLAG_DEALLOC, "blah1", mpi0); assert_err (err); - check_sexp_conversion (data); + check_sexp_conversion (data, identifiers); + check_sexp_conversion (data, identifiers_null); + check_sexp_conversion (data, NULL); + err = gcry_ac_data_get_name (data, 0, label0, &mpi1); assert_err (err); assert (mpi0 != mpi1); @@ -153,7 +166,10 @@ check_run (void) gcry_ac_data_clear (data); assert (! gcry_ac_data_length (data)); - check_sexp_conversion (data); + check_sexp_conversion (data, identifiers); + check_sexp_conversion (data, identifiers_null); + check_sexp_conversion (data, NULL); + printf ("data-set-test-2 succeeded\n"); gcry_ac_data_destroy (data); |